diff options
author | Christian Glöckner <cgloeckner@freenet.de> | 2016-03-31 10:44:08 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-03-31 21:15:45 +0200 |
commit | ba8f8ed02dc666d405c60804fbae87101ccf6bba (patch) | |
tree | 1dd102f23f76aef5818c7a2b7da4e3bbbe072e35 /test/syncedsettings.cc | |
parent | 8bbb15566e1025fe5784190fa0f594cc837c2673 (diff) |
Improved mimicRealUse() test case
Diffstat (limited to 'test/syncedsettings.cc')
-rw-r--r-- | test/syncedsettings.cc | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/test/syncedsettings.cc b/test/syncedsettings.cc index 7de7c42..62bd8c6 100644 --- a/test/syncedsettings.cc +++ b/test/syncedsettings.cc @@ -160,54 +160,41 @@ class SyncedSettingsTest void mimicRealUse() { struct Settings { struct Foo { - int a, b; - bool enabled; + float a{5}; + float b{3}; + bool enabled{true}; }; struct Bar { - float a, b; - bool enabled; - }; - struct Idk { - std::string label; - float bla; + std::string label{"empty"}; + float bla{0.f}; }; Group<Foo> foo; Group<Bar> bar; - Group<Idk> idk; }; Settings s; - // set some settings - { - Accessor<Settings::Foo> tmp{s.foo}; - tmp.data.enabled = true; - tmp.data.a = 3; - } + // set bar settings { Accessor<Settings::Bar> tmp{s.bar}; - tmp.data.enabled = false; - tmp.data.a = 0.f; - tmp.data.b = 0.f; - } - { - Accessor<Settings::Idk> tmp{s.idk}; tmp.data.label = "hello world"; tmp.data.bla = 3.14f; } - // read some settings + // read foo settings { Accessor<Settings::Foo> tmp{s.foo}; if (tmp.data.enabled) { // do some while locked } } - Settings::Bar copy = s.bar; + // or: + Settings::Foo copy = s.foo; if (copy.enabled) { // do some stuff without locking } + CPPUNIT_ASSERT(copy.enabled); } }; |