diff options
author | Josh Blum <josh@joshknows.com> | 2011-06-28 11:11:04 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-06-28 11:11:04 -0700 |
commit | 4888233252d58f0df3c8773ec3268a0ed7bea1d2 (patch) | |
tree | 33daab577ff64117e647bb5d6e97397c89ff6b11 /host/tests | |
parent | 3a6187515677b277489df4ec59f9cf21f1ed62bc (diff) | |
download | uhd-4888233252d58f0df3c8773ec3268a0ed7bea1d2.tar.gz uhd-4888233252d58f0df3c8773ec3268a0ed7bea1d2.tar.bz2 uhd-4888233252d58f0df3c8773ec3268a0ed7bea1d2.zip |
uhd: re-work to make the properties easier to use
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/property_test.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/host/tests/property_test.cpp b/host/tests/property_test.cpp index b579e5213..6c80cea70 100644 --- a/host/tests/property_test.cpp +++ b/host/tests/property_test.cpp @@ -16,7 +16,6 @@ // #include <boost/test/unit_test.hpp> -#include <uhd/property.hpp> #include <uhd/property_tree.hpp> #include <boost/bind.hpp> #include <iostream> @@ -36,50 +35,50 @@ struct setter_type{ }; BOOST_AUTO_TEST_CASE(test_prop_simple){ - uhd::property<int> prop; - prop.set(42); - BOOST_CHECK_EQUAL(prop.get(), 42); - prop.set(34); - BOOST_CHECK_EQUAL(prop.get(), 34); + uhd::property<int>::sptr prop = uhd::property<int>::make(); + prop->set(42); + BOOST_CHECK_EQUAL(prop->get(), 42); + prop->set(34); + BOOST_CHECK_EQUAL(prop->get(), 34); } BOOST_AUTO_TEST_CASE(test_prop_with_subscriber){ - uhd::property<int> prop; + uhd::property<int>::sptr prop = uhd::property<int>::make(); setter_type setter; - prop.subscribe(boost::bind(&setter_type::doit, &setter, _1)); + prop->subscribe(boost::bind(&setter_type::doit, &setter, _1)); - prop.set(42); - BOOST_CHECK_EQUAL(prop.get(), 42); + prop->set(42); + BOOST_CHECK_EQUAL(prop->get(), 42); BOOST_CHECK_EQUAL(setter._x, 42); - prop.set(34); - BOOST_CHECK_EQUAL(prop.get(), 34); + prop->set(34); + BOOST_CHECK_EQUAL(prop->get(), 34); BOOST_CHECK_EQUAL(setter._x, 34); } BOOST_AUTO_TEST_CASE(test_prop_with_coercion){ - uhd::property<int> prop; + uhd::property<int>::sptr prop = uhd::property<int>::make(); setter_type setter; - prop.subscribe(boost::bind(&setter_type::doit, &setter, _1)); + prop->subscribe(boost::bind(&setter_type::doit, &setter, _1)); coercer_type coercer; - prop.subscribe_master(boost::bind(&coercer_type::doit, &coercer, _1)); + prop->subscribe_master(boost::bind(&coercer_type::doit, &coercer, _1)); - prop.set(42); - BOOST_CHECK_EQUAL(prop.get(), 40); + prop->set(42); + BOOST_CHECK_EQUAL(prop->get(), 40); BOOST_CHECK_EQUAL(setter._x, 40); - prop.set(34); - BOOST_CHECK_EQUAL(prop.get(), 32); + prop->set(34); + BOOST_CHECK_EQUAL(prop->get(), 32); BOOST_CHECK_EQUAL(setter._x, 32); } BOOST_AUTO_TEST_CASE(test_prop_tree){ uhd::property_tree::sptr tree = uhd::property_tree::make(); - tree->create("/test/prop0", uhd::property<int>()); + tree->create<int>("/test/prop0"); tree->create<int>("/test/prop1"); BOOST_CHECK(tree->exists("/test")); @@ -89,6 +88,9 @@ BOOST_AUTO_TEST_CASE(test_prop_tree){ tree->access<int>("/test/prop0").set(42); tree->access<int>("/test/prop1").set(34); + BOOST_CHECK_EQUAL(tree->access<int>("/test/prop0").get(), 42); + BOOST_CHECK_EQUAL(tree->access<int>("/test/prop1").get(), 34); + tree->remove("/test/prop0"); BOOST_CHECK(not tree->exists("/test/prop0")); BOOST_CHECK(tree->exists("/test/prop1")); |