diff options
Diffstat (limited to 'meowpp_unittest/utility/operation.cpp')
-rw-r--r-- | meowpp_unittest/utility/operation.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/meowpp_unittest/utility/operation.cpp b/meowpp_unittest/utility/operation.cpp new file mode 100644 index 0000000..def8d84 --- /dev/null +++ b/meowpp_unittest/utility/operation.cpp @@ -0,0 +1,54 @@ +#include <meowpp/utility/operation.h> +#include <meowpp/utility/operation.h> +#include <meowpp/utility/operation.h> + +#include <meowpp/debug/assert.h> + +namespace meow { +class OperationTest { + private: + class States : public State { + public: + static const int CASE1 = 1; + static const int CASE2 = 1; + }; + class Oper1 : public Operation { + public: + int id; + Oper1(int k) : Operation(3, 5), id(k) {} + Object* Copy() const { return new Oper1(id); } + State Operate(Pointer<Object const> const * inputs, + Pointer<Object> const* outputs) const { + return States::CASE1; + } + }; + class Oper2 : public Operation { + public: + Oper2() : Operation(2, 7) {} + State Operate(Pointer<Object const> const * inputs, + Pointer<Object> const* outputs) const { + return States::CASE2; + } + }; + public: + OperationTest() { + Oper1 op1(30); + Oper2 op2; + Assert(op1.inputs_size() == 3, ""); + Assert(op1.outputs_size() == 5, ""); + Assert(op2.inputs_size() == 2, ""); + Assert(op2.outputs_size() == 7, ""); + Oper1* nw = dynamic_cast<Oper1*>(op1.Copy()); + Assert(nw->id == op1.id, ""); + Assert(nw->inputs_size() == 3, ""); + Assert(nw->outputs_size() == 5, ""); + Assert(op1.Operate(NULL, NULL) == States::CASE1, ""); + Assert(op2.Operate(NULL, NULL) == States::CASE2, ""); + } +} _; + +} + +int main() { + return 0; +} |