Test ability to copy union and to set union type 18/31218/5
authorMateusz Malicki <m.malicki2@samsung.com>
Tue, 2 Dec 2014 15:17:13 +0000 (16:17 +0100)
committerJan Olszak <j.olszak@samsung.com>
Mon, 8 Dec 2014 17:06:54 +0000 (09:06 -0800)
[Bug/Feature]   Test ability to copy union and to set union type
[Cause]         Need to copy and add new union elements
[Solution]      1) Clear vector with unions; 2) set, copy and move elements
[Verification]  Build, install, tests

Change-Id: Iea2d7eca36edcfd34f768d1e99a3da970300afd8

tests/unit_tests/config/ut-configuration.cpp

index 7f9703b..8aab028 100644 (file)
@@ -382,9 +382,18 @@ BOOST_AUTO_TEST_CASE(ConfigUnion)
     BOOST_CHECK_EQUAL(subConfig.intVal, 54321);
     BOOST_CHECK(testConfig.unions[0].is<int>());
     BOOST_CHECK(testConfig.unions[1].is<TestConfig::SubConfig>());
-
     std::string out = saveToString(testConfig);
     BOOST_CHECK_EQUAL(out, jsonTestString);
+
+    //Check move and copy
+    std::vector<TestConfig::SubConfigOption> unions(2);
+    unions[0].set<int>(2);
+    unions[1].set(std::move(testConfig.unions[1].as<TestConfig::SubConfig>()));
+    BOOST_CHECK(testConfig.unions[1].as<TestConfig::SubConfig>().intVector.empty());
+    testConfig.unions.clear();
+    testConfig.unions = unions;
+    out = saveToString(testConfig);
+    BOOST_CHECK_EQUAL(out, jsonTestString);
 }
 
 BOOST_AUTO_TEST_SUITE_END()