aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/dict_test.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2015-01-24 01:46:22 +0100
committerMartin Braun <martin.braun@ettus.com>2015-01-27 09:58:02 +0100
commitbefbaf97d09f1c36437bb285d7a1dc70a34ef6ab (patch)
treeffa325e837c6ecbf7664c4747cce8903c824050a /host/tests/dict_test.cpp
parentec957da3209bb8291446c17b77dde8dd7ad67ab6 (diff)
downloaduhd-befbaf97d09f1c36437bb285d7a1dc70a34ef6ab.tar.gz
uhd-befbaf97d09f1c36437bb285d7a1dc70a34ef6ab.tar.bz2
uhd-befbaf97d09f1c36437bb285d7a1dc70a34ef6ab.zip
uhd: Added an update() method for dicts
Very similar to Python's dict.update().
Diffstat (limited to 'host/tests/dict_test.cpp')
-rw-r--r--host/tests/dict_test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/host/tests/dict_test.cpp b/host/tests/dict_test.cpp
index 7b388d090..333aadbba 100644
--- a/host/tests/dict_test.cpp
+++ b/host/tests/dict_test.cpp
@@ -70,3 +70,28 @@ BOOST_AUTO_TEST_CASE(test_dict_pop){
BOOST_CHECK(d.keys()[0] == -1);
BOOST_CHECK(d.keys()[1] == 1);
}
+
+BOOST_AUTO_TEST_CASE(test_dict_update)
+{
+ uhd::dict<std::string, std::string> d1 = boost::assign::map_list_of
+ ("key1", "val1")
+ ("key2", "val2")
+ ;
+ uhd::dict<std::string, std::string> d2 = boost::assign::map_list_of
+ ("key2", "val2x")
+ ("key3", "val3")
+ ;
+
+ d1.update(d2, false /* don't throw cause of conflict */);
+ BOOST_CHECK_EQUAL(d1["key1"], "val1");
+ BOOST_CHECK_EQUAL(d1["key2"], "val2x");
+ BOOST_CHECK_EQUAL(d1["key3"], "val3");
+
+ uhd::dict<std::string, std::string> d3 = boost::assign::map_list_of
+ ("key1", "val1")
+ ("key2", "val2")
+ ;
+ BOOST_CHECK_THROW(d3.update(d2), uhd::value_error);
+}
+
+