32class ValueWithDefaultTests :
public UnitTest
36 : UnitTest (
"ValueWithDefault", UnitTestCategories::values)
39 void runTest()
override
41 beginTest (
"default constructor");
44 expect (
vwd.isUsingDefault());
45 expect (
vwd.get() == var());
48 beginTest (
"missing property");
51 ValueWithDefault
vwd (
t,
"testKey",
nullptr,
"default");
53 expect (
vwd.isUsingDefault());
54 expectEquals (
vwd.get().toString(), String (
"default"));
57 beginTest (
"non-empty property");
60 t.setProperty (
"testKey",
"non-default",
nullptr);
62 ValueWithDefault
vwd (
t,
"testKey",
nullptr,
"default");
64 expect (!
vwd.isUsingDefault());
65 expectEquals (
vwd.get().toString(), String (
"non-default"));
68 beginTest (
"set default");
72 ValueWithDefault
vwd (
t,
"testkey",
nullptr);
73 vwd.setDefault (
"default");
75 expect (
vwd.isUsingDefault());
76 expectEquals (
vwd.get().toString(), String (
"default"));
79 beginTest (
"set value");
82 t.setProperty (
"testkey",
"testvalue",
nullptr);
84 ValueWithDefault
vwd (
t,
"testkey",
nullptr,
"default");
87 expect (!
vwd.isUsingDefault());
88 expectEquals (
t[
"testkey"].toString(), String (
"newvalue"));
92 expect (
vwd.isUsingDefault());
93 expect (
t[
"testkey"] == var());
98static ValueWithDefaultTests valueWithDefaultTests;