diff --git a/poincare/Makefile b/poincare/Makefile index 7d0515d35..bc593d3b3 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -19,8 +19,11 @@ objs += $(addprefix poincare/src/layout/,\ exponent_layout.o\ string_layout.o) tests += $(addprefix poincare/test/,\ + addition.cpp\ + fraction.cpp\ integer.cpp\ - product.cpp) + product.cpp\ + subtraction.cpp) # Even though flex and bison will generate both implementation and headers at # once, we don't declare it in the Makefile. If we did, "make -jN" with N>1 may diff --git a/poincare/test/addition.cpp b/poincare/test/addition.cpp new file mode 100644 index 000000000..5c6768c3d --- /dev/null +++ b/poincare/test/addition.cpp @@ -0,0 +1,12 @@ +#include +#include +#include + +QUIZ_CASE(poincare_addition_approximate) { + Context context; + // Note: these have to be heap allocated. + Integer *a = new Integer(1); + Integer *b = new Integer(2); + assert(Addition(a, b).approximate(context) == 3.0f); +} + diff --git a/poincare/test/fraction.cpp b/poincare/test/fraction.cpp new file mode 100644 index 000000000..586489660 --- /dev/null +++ b/poincare/test/fraction.cpp @@ -0,0 +1,12 @@ +#include +#include +#include + +QUIZ_CASE(poincare_fraction_approximate) { + Context context; + // Note: these have to be heap allocated. + Integer *a = new Integer(1); + Integer *b = new Integer(2); + assert(Fraction(a, b).approximate(context) == 0.5f); +} + diff --git a/poincare/test/integer.cpp b/poincare/test/integer.cpp index 1f5e9606e..082276189 100644 --- a/poincare/test/integer.cpp +++ b/poincare/test/integer.cpp @@ -37,7 +37,7 @@ QUIZ_CASE(poincare_integer_subtract) { QUIZ_CASE(poincare_integer_multiply) { assert(Integer(12) * Integer(34) == Integer(408)); - //assert(Integer(56) * Integer(0) == Integer(0)); + assert(Integer(56) * Integer(0) == Integer(0)); assert(Integer(-12) * Integer(34) == Integer(-408)); assert(Integer(-12) * Integer(-34) == Integer(408)); assert(Integer(999999) * Integer(999999) == Integer("999998000001")); diff --git a/poincare/test/product.cpp b/poincare/test/product.cpp index c74f39408..a74e24c3c 100644 --- a/poincare/test/product.cpp +++ b/poincare/test/product.cpp @@ -2,8 +2,10 @@ #include #include -QUIZ_CASE(poincare_multiply_approximate) { - //Context context; - //Integer a(1), b(2); - //assert(Product(&a, &b).approximate(context) == 2); +QUIZ_CASE(poincare_procuct_approximate) { + Context context; + // Note: these have to be heap allocated. + Integer *a = new Integer(1); + Integer *b = new Integer(2); + assert(Product(a, b).approximate(context) == 2.0f); } diff --git a/poincare/test/subtraction.cpp b/poincare/test/subtraction.cpp new file mode 100644 index 000000000..013f7948a --- /dev/null +++ b/poincare/test/subtraction.cpp @@ -0,0 +1,11 @@ +#include +#include +#include + +QUIZ_CASE(poincare_subtraction_approximate) { + Context context; + // Note: these have to be heap allocated. + Integer *a = new Integer(1); + Integer *b = new Integer(2); + assert(Subtraction(a, b).approximate(context) == -1.0f); +}