From ddd8c3c44a01fc2eb852981e3e06bcd47e607e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 4 Jan 2018 10:18:55 +0100 Subject: [PATCH] [apps] Add tests on Ans behaviour in Calculation --- apps/calculation/test/calculation_store.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/calculation/test/calculation_store.cpp b/apps/calculation/test/calculation_store.cpp index aae3cfc8b..260fd9d97 100644 --- a/apps/calculation/test/calculation_store.cpp +++ b/apps/calculation/test/calculation_store.cpp @@ -45,4 +45,16 @@ QUIZ_CASE(calculation_store) { /* Store is now {0, 2, 4, 6, 8, 5, 6, 7, 8, 9} */ const char * result3[10] = {"1", "3", "5", "7", "9", "5", "6", "7", "8", "9"}; assert_store_is(&store, result3); + + store.deleteAll(); + store.push("1+3/4", &globalContext); + store.push("ans+2/3", &globalContext); + ::Calculation::Calculation * lastCalculation = store.calculationAtIndex(1); + assert(lastCalculation->shouldDisplayApproximateOutput(&globalContext) == false); + assert(strcmp(lastCalculation->exactOutputText(),"29/12") == 0); + + store.push("ans+0.22", &globalContext); + lastCalculation = store.calculationAtIndex(2); + assert(lastCalculation->shouldDisplayApproximateOutput(&globalContext) == true); + assert(strcmp(lastCalculation->approximateOutputText(),"2.6366666666667") == 0); }