diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-13 02:01:30 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-13 02:01:30 +0100 |
commit | dcf154aaf037ac67260abcec0b0ed3db32bc65ac (patch) | |
tree | 94dd32865be508d70617c351c609f398c9ec6f06 /test/core/common/FunctionTest.cpp | |
parent | 742b76b006daf27ea19b2834e56696cb3c5a0e18 (diff) |
allowing validated methods
Diffstat (limited to 'test/core/common/FunctionTest.cpp')
-rw-r--r-- | test/core/common/FunctionTest.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/core/common/FunctionTest.cpp b/test/core/common/FunctionTest.cpp index 7225f9c..ed20695 100644 --- a/test/core/common/FunctionTest.cpp +++ b/test/core/common/FunctionTest.cpp @@ -29,10 +29,10 @@ public: void visit() { visited = true; } }; -TEST(Method, simpleTest) +TEST(Method, simple) { Method<MethodTestClass> m{ - [](const Variant::arrayType &args, MethodTestClass *thisRef) { + [](Variant::arrayType &args, MethodTestClass *thisRef) { thisRef->visit(); return Variant{}; }}; @@ -40,5 +40,18 @@ TEST(Method, simpleTest) MethodTestClass inst; m.call({}, &inst); } + +TEST(Method, validation) +{ + Method<void> m{{Argument::Int("a"), Argument::Int("b")}, + [](Variant::arrayType &args, void *thisRef) { + return Variant{args[0].asInt() + args[1].asInt()}; + }}; + + MethodTestClass inst; + ASSERT_EQ(3, m.call({1, 2}, &inst).asInt()); + ASSERT_THROW(m.call({1}, &inst), LoggableException); + ASSERT_THROW(m.call({1, "bla"}, &inst), LoggableException); +} } |