summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosh Blum2013-07-04 19:46:58 -0700
committerJosh Blum2013-07-04 19:46:58 -0700
commit1298bcd1e421ccfefafa78c6d33760818902f399 (patch)
treee4c57bbcf98f9e7502850e5ab481ba7b9d4c11fc /tests
parentfbec0c405a1fec4e8ee82d065fdc657cdd333f52 (diff)
downloadsandhi-1298bcd1e421ccfefafa78c6d33760818902f399.tar.gz
sandhi-1298bcd1e421ccfefafa78c6d33760818902f399.tar.bz2
sandhi-1298bcd1e421ccfefafa78c6d33760818902f399.zip
gras: function registry is more flexible
Diffstat (limited to 'tests')
-rw-r--r--tests/block_props_test.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/block_props_test.cpp b/tests/block_props_test.cpp
index f53a1c3..ad1c5e2 100644
--- a/tests/block_props_test.cpp
+++ b/tests/block_props_test.cpp
@@ -68,3 +68,53 @@ BOOST_AUTO_TEST_CASE(test_property_errors)
//wrong type for property
BOOST_CHECK_THROW(my_block.set("foo", "a string"), std::exception);
}
+
+struct MyBlockNewShit : gras::Block
+{
+ MyBlockNewShit(void):
+ gras::Block("MyBlockNewShit")
+ {
+ this->register_call("foo", &MyBlockNewShit::foo);
+ this->register_call("bar", &MyBlockNewShit::bar);
+ this->register_call("baz", &MyBlockNewShit::baz);
+ //this->register_call("example_setter", &MyBlockNewShit::example_setter);
+ }
+
+ //dummy work
+ void work(const InputItems &, const OutputItems &){}
+
+ int foo(void)
+ {
+ return 42;
+ }
+
+ int bar(const std::string &a0)
+ {
+ return a0.size();
+ }
+
+ int baz(const std::string &a0, const bool &a1)
+ {
+ return a1?a0.size():-1;
+ }
+
+ void example_setter(const long &)
+ {
+
+ }
+};
+
+BOOST_AUTO_TEST_CASE(test_property_newshit)
+{
+ MyBlockNewShit my_block;
+ size_t my_foo = my_block.call<size_t>("foo");
+ BOOST_CHECK_EQUAL(my_foo, size_t(42));
+
+ size_t my_bar = my_block.call<size_t>("bar", "hello");
+ BOOST_CHECK_EQUAL(my_bar, size_t(5));
+
+ signed my_baz = my_block.call<signed>("baz", "hello", false);
+ BOOST_CHECK_EQUAL(my_baz, signed(-1));
+
+ //my_block.call<int>("example_setter", 123);
+}