diff --git a/poincare/Makefile b/poincare/Makefile index 74e0c30d5..76e9d0861 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -245,9 +245,10 @@ tests += $(addprefix poincare/test/,\ tree/pair_node.cpp\ tree/tree_by_value.cpp\ tree/tree_by_reference.cpp\ - expression.cpp\ addition.cpp\ + arithmetic.cpp\ division.cpp\ + expression.cpp\ factorial.cpp\ function.cpp\ helper.cpp\ diff --git a/poincare/test/arithmetic.cpp b/poincare/test/arithmetic.cpp index 823c3b91f..9f938ce8b 100644 --- a/poincare/test/arithmetic.cpp +++ b/poincare/test/arithmetic.cpp @@ -3,6 +3,7 @@ #include #include #include +#include "helper.h" #if POINCARE_TESTS_PRINT_EXPRESSIONS #include "../src/expression_debug.h" @@ -18,7 +19,7 @@ void assert_gcd_equals_to(Integer a, Integer b, Integer c) { cout << "gcd(" << a.approximate(); cout << ", " << b.approximate() << ") = "; #endif - Integer gcd = Arithmetic::GCD(&a, &b); + Integer gcd = Arithmetic::GCD(a, b); #if POINCARE_TESTS_PRINT_EXPRESSIONS cout << gcd.approximate() << endl; #endif @@ -31,7 +32,7 @@ void assert_lcm_equals_to(Integer a, Integer b, Integer c) { cout << "lcm(" << a.approximate(); cout << ", " << b.approximate() << ") = "; #endif - Integer lcm = Arithmetic::LCM(&a, &b); + Integer lcm = Arithmetic::LCM(a, b); #if POINCARE_TESTS_PRINT_EXPRESSIONS cout << lcm.approximate() << endl; #endif @@ -39,13 +40,14 @@ void assert_lcm_equals_to(Integer a, Integer b, Integer c) { } void assert_prime_factorization_equals_to(Integer a, int * factors, int * coefficients, int length) { + GlobalContext context; Integer outputFactors[100]; Integer outputCoefficients[100]; #if POINCARE_TESTS_PRINT_EXPRESSIONS cout << "---- Primes factorization ----" << endl; cout << "Decomp(" << a.approximate() << ") = "; #endif - Arithmetic::PrimeFactorization(&a, outputFactors, outputCoefficients, 10); + Arithmetic::PrimeFactorization(a, outputFactors, outputCoefficients, 10); #if POINCARE_TESTS_PRINT_EXPRESSIONS print_prime_factorization(outputFactors, outputCoefficients, 10); #endif @@ -57,8 +59,8 @@ void assert_prime_factorization_equals_to(Integer a, int * factors, int * coeffi * (the relation between integers and their approximation is a surjection, * however different integers are really likely to have different * approximations... */ - quiz_assert(outputFactors[index].approximate() == Integer(factors[index]).approximate()); - quiz_assert(outputCoefficients[index].approximate() == Integer(coefficients[index]).approximate()); + quiz_assert(outputFactors[index].approximateToScalar(context, Degree) == Integer(factors[index]).approximateToScalar(context, Degree)); + quiz_assert(outputCoefficients[index].approximateToScalar(context, Degree) == Integer(coefficients[index]).approximateToScalar(context, Degree)); } } @@ -66,12 +68,12 @@ QUIZ_CASE(poincare_arithmetic) { assert_gcd_equals_to(Integer(11), Integer(121), Integer(11)); assert_gcd_equals_to(Integer(-256), Integer(321), Integer(1)); assert_gcd_equals_to(Integer(-8), Integer(-40), Integer(8)); - assert_gcd_equals_to(Integer("1234567899876543456", true), Integer("234567890098765445678"), Integer(2)); + assert_gcd_equals_to(Integer("1234567899876543456"), Integer("234567890098765445678"), Integer(2)); assert_gcd_equals_to(Integer("45678998789"), Integer("1461727961248"), Integer("45678998789")); assert_lcm_equals_to(Integer(11), Integer(121), Integer(121)); assert_lcm_equals_to(Integer(-31), Integer(52), Integer(1612)); assert_lcm_equals_to(Integer(-8), Integer(-40), Integer(40)); - assert_lcm_equals_to(Integer("1234567899876543456", true), Integer("234567890098765445678"), Integer("144794993728852353909143567804987191584")); + assert_lcm_equals_to(Integer("1234567899876543456"), Integer("234567890098765445678"), Integer("144794993728852353909143567804987191584")); assert_lcm_equals_to(Integer("45678998789"), Integer("1461727961248"), Integer("1461727961248")); int factors0[5] = {2,3,5,79,1319}; int coefficients0[5] = {2,1,1,1,1};