conf/conf_test.v

44 lines
811 B
V

module conf
struct SimpleConf {
some_int int
some_string string
}
struct SimpleConfDefaults {
some_int int = 3
some_string string = 'hi'
}
fn test_simple() {
conf := load<SimpleConf>(default_path: 'test/test_simple.toml')!
assert conf == SimpleConf{
some_int: 2
some_string: 'hi'
}
}
fn test_zeroed() {
conf := load<SimpleConf>(default_path: 'test/test_zeroed.toml')!
assert conf == SimpleConf{
some_int: 0
some_string: ''
}
}
fn test_zeroed_defaults() {
conf := load<SimpleConfDefaults>(default_path: 'test/test_zeroed.toml')!
assert conf == SimpleConfDefaults{
some_int: 0
some_string: ''
}
}
fn test_defaults() {
conf := load<SimpleConfDefaults>(default_path: 'test/test_single_value.toml')!
assert conf == SimpleConfDefaults{
some_int: 3
some_string: 'hi'
}
}