From ba8f8ed02dc666d405c60804fbae87101ccf6bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gl=C3=B6ckner?= Date: Thu, 31 Mar 2016 10:44:08 +0200 Subject: Improved mimicRealUse() test case --- test/syncedsettings.cc | 33 ++++++++++----------------------- 1 file 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; Group bar; - Group idk; }; Settings s; - // set some settings - { - Accessor tmp{s.foo}; - tmp.data.enabled = true; - tmp.data.a = 3; - } + // set bar settings { Accessor tmp{s.bar}; - tmp.data.enabled = false; - tmp.data.a = 0.f; - tmp.data.b = 0.f; - } - { - Accessor tmp{s.idk}; tmp.data.label = "hello world"; tmp.data.bla = 3.14f; } - // read some settings + // read foo settings { Accessor 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); } }; -- cgit v1.2.3