summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-01 12:35:34 -0800
committerJosh Blum <josh@joshknows.com>2010-02-01 12:35:34 -0800
commitcc8caeb1230fbaed4a6bc64848a584d51b69362a (patch)
tree086264364fe1d9d1f790a077cd7d9f3219cc369a /test
parent5e455ca92280e3c22f5484cb81a2aef0cdfb5de4 (diff)
downloaduhd-cc8caeb1230fbaed4a6bc64848a584d51b69362a.tar.gz
uhd-cc8caeb1230fbaed4a6bc64848a584d51b69362a.tar.bz2
uhd-cc8caeb1230fbaed4a6bc64848a584d51b69362a.zip
Work on the properties framwork with wax::obj.
Now the obj handles all 3 things in 1, properties, polymorphic container, proxy.
Diffstat (limited to 'test')
-rw-r--r--test/device_test.cpp2
-rw-r--r--test/gain_handler_test.cpp12
-rw-r--r--test/wax_test.cpp16
3 files changed, 16 insertions, 14 deletions
diff --git a/test/device_test.cpp b/test/device_test.cpp
index 863be4351..328ea9c0c 100644
--- a/test/device_test.cpp
+++ b/test/device_test.cpp
@@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(test_device){
std::cout << wax::cast<std::string>((*dev)[DEVICE_PROP_NAME]) << std::endl;
std::cout << "Access the mboard" << std::endl;
- wax::proxy mb0 = (*dev)[DEVICE_PROP_MBOARD];
+ wax::obj mb0 = (*dev)[DEVICE_PROP_MBOARD];
std::cout << wax::cast<std::string>(mb0[MBOARD_PROP_NAME]) << std::endl;
BOOST_CHECK_EQUAL(
device_addr.virtual_args.num_dboards,
diff --git a/test/gain_handler_test.cpp b/test/gain_handler_test.cpp
index 26141ab21..074a67ec8 100644
--- a/test/gain_handler_test.cpp
+++ b/test/gain_handler_test.cpp
@@ -49,11 +49,11 @@ public:
~gainful_obj(void){}
private:
- void get(const wax::type &key_, wax::type &val){
+ void get(const wax::obj &key_, wax::obj &val){
if (_gain_handler->intercept_get(key_, val)) return;
- wax::type key; std::string name;
- tie(key, name) = extract_named_prop(key_);
+ wax::obj key; std::string name;
+ boost::tie(key, name) = extract_named_prop(key_);
//handle the get request conditioned on the key
switch(wax::cast<prop_t>(key)){
@@ -79,11 +79,11 @@ private:
}
}
- void set(const wax::type &key_, const wax::type &val){
+ void set(const wax::obj &key_, const wax::obj &val){
if (_gain_handler->intercept_set(key_, val)) return;
- wax::type key; std::string name;
- tie(key, name) = extract_named_prop(key_);
+ wax::obj key; std::string name;
+ boost::tie(key, name) = extract_named_prop(key_);
//handle the get request conditioned on the key
switch(wax::cast<prop_t>(key)){
diff --git a/test/wax_test.cpp b/test/wax_test.cpp
index 4c3ec0635..b329788f2 100644
--- a/test/wax_test.cpp
+++ b/test/wax_test.cpp
@@ -22,7 +22,7 @@ enum opt_a_t{OPTION_A_0, OPTION_A_1};
enum opt_b_t{OPTION_B_0, OPTION_B_1};
BOOST_AUTO_TEST_CASE(test_enums){
- wax::type opta = OPTION_A_0;
+ wax::obj opta = OPTION_A_0;
BOOST_CHECK_THROW(wax::cast<opt_b_t>(opta), wax::bad_cast);
BOOST_CHECK_EQUAL(wax::cast<opt_a_t>(opta), OPTION_A_0);
}
@@ -46,14 +46,14 @@ public:
~wax_demo(void){
/* NOP */
}
- void get(const wax::type &key, wax::type &value){
+ void get(const wax::obj &key, wax::obj &value){
if (d_subs.size() == 0){
value = d_nums[wax::cast<size_t>(key)];
}else{
- value = obj::cast(&d_subs[wax::cast<size_t>(key)]);
+ value = d_subs[wax::cast<size_t>(key)].get_link();
}
}
- void set(const wax::type &key, const wax::type &value){
+ void set(const wax::obj &key, const wax::obj &value){
if (d_subs.size() == 0){
d_nums[wax::cast<size_t>(key)] = wax::cast<float>(value);
}else{
@@ -71,6 +71,8 @@ BOOST_AUTO_TEST_CASE(test_chaining){
wd[size_t(0)][size_t(0)];
std::cout << "chain 3" << std::endl;
wd[size_t(0)][size_t(0)][size_t(0)];
+ std::cout << "cast proxy with link" << std::endl;
+ wax::cast<wax::obj::ptr>(wd[size_t(0)][size_t(0)]);
}
BOOST_AUTO_TEST_CASE(test_set_get){
@@ -89,16 +91,16 @@ BOOST_AUTO_TEST_CASE(test_set_get){
BOOST_AUTO_TEST_CASE(test_proxy){
std::cout << "store proxy" << std::endl;
- wax::proxy p = wd[size_t(0)][size_t(0)];
+ wax::obj p = wd[size_t(0)][size_t(0)];
p[size_t(0)] = float(5);
std::cout << "assign proxy" << std::endl;
- wax::type a = p[size_t(0)];
+ wax::obj a = p[size_t(0)];
BOOST_CHECK_EQUAL(wax::cast<float>(a), float(5));
}
BOOST_AUTO_TEST_CASE(test_print){
std::cout << "print type" << std::endl;
- wax::type test_type = float(3.33);
+ wax::obj test_type = float(3.33);
std::cout << test_type << std::endl;
}