summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosh Blum2013-07-05 14:53:22 -0700
committerJosh Blum2013-07-05 14:53:22 -0700
commite23e5f43a97c72f1bf0dd240376bf89ff19f356c (patch)
tree0b41a6808f714eccc380d84d772f3f634eecd53e /tests
parent086cf85eca88941819909f5877d9558aaa761b72 (diff)
downloadsandhi-e23e5f43a97c72f1bf0dd240376bf89ff19f356c.tar.gz
sandhi-e23e5f43a97c72f1bf0dd240376bf89ff19f356c.tar.bz2
sandhi-e23e5f43a97c72f1bf0dd240376bf89ff19f356c.zip
gras: save callable work compiling w/ minor unit test
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/callable_test.cpp53
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index bc3815e..bb3f3c8 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,6 +14,7 @@ if (NOT Boost_FOUND)
endif()
set(test_sources
+ callable_test.cpp
chrono_time_test.cpp
block_props_test.cpp
serialize_tags_test.cpp
diff --git a/tests/callable_test.cpp b/tests/callable_test.cpp
new file mode 100644
index 0000000..1753f79
--- /dev/null
+++ b/tests/callable_test.cpp
@@ -0,0 +1,53 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#include <boost/test/unit_test.hpp>
+#include <iostream>
+
+#include <gras/callable.hpp>
+
+
+struct MyClass : gras::Callable
+{
+ MyClass(void)
+ {
+ this->register_call("foo", &MyClass::foo);
+ this->register_call("bar", &MyClass::bar);
+ this->register_call("baz", &MyClass::baz);
+ //this->register_call("example_setter", &MyClass::example_setter);
+ }
+
+ 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)
+{
+ MyClass my_class;
+ size_t my_foo = my_class.call<size_t>("foo");
+ BOOST_CHECK_EQUAL(my_foo, size_t(42));
+
+ size_t my_bar = my_class.call<size_t>("bar", "hello");
+ BOOST_CHECK_EQUAL(my_bar, size_t(5));
+
+ signed my_baz = my_class.call<signed>("baz", "hello", false);
+ BOOST_CHECK_EQUAL(my_baz, signed(-1));
+
+ //my_class.call("example_setter", 123);
+}