diff --git a/Examples/test-suite/c/operator_overload_runme.c b/Examples/test-suite/c/operator_overload_runme.c new file mode 100644 index 000000000..fc27fd5b5 --- /dev/null +++ b/Examples/test-suite/c/operator_overload_runme.c @@ -0,0 +1,25 @@ +#include + +#include "operator_overload/operator_overload_proxy.h" + +#define assert(x,msg) if (!x) { printf("%d: %s\n", x, msg); SWIG_exit(0); } + +SWIG_MAKE_DELETE(delete_Ops, Op); + +int main() { + Op_sanity_check(); + + Op *op1 = new_Op_i(1), *op2 = new_Op_i(2), *op3 = copy_Op(op1); + + assert(Op_NotEqual(op1, op2), "neq failed"); + Op_PlusPlusPrefix(op3); + assert(Op_EqualEqual(op2, op3), "eqeq failed"); + assert(Op_GreaterThanEqual(op2, op1), "geq failed"); + Op_PlusEqual(op3, op1); + assert(Op_LessThan(op1, op2) && Op_LessThan(op2, op3), "lt failed"); + assert(3 == *Op_IndexInto(op3, Op_IndexIntoConst(op2, Op_Functor_pOp(op1))), "[] or () failed"); + assert(5 == Op_Functor_pOp_i(op3, 2), "f(x) failed"); + + delete_Ops(op1, op2, op3, 0); + SWIG_exit(0); +}