From 6c5b0def7b2bbbc92c314cf1ee310cff9961a655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 19 Nov 2018 15:05:04 +0100 Subject: [PATCH] [apps/calculation] Test on equal/approximate display --- apps/calculation/test/calculation_store.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/calculation/test/calculation_store.cpp b/apps/calculation/test/calculation_store.cpp index 5e2a541d5..d67bceb8c 100644 --- a/apps/calculation/test/calculation_store.cpp +++ b/apps/calculation/test/calculation_store.cpp @@ -48,6 +48,12 @@ QUIZ_CASE(calculation_store) { assert_store_is(&store, result3); store.deleteAll(); +} + +QUIZ_CASE(calculation_display_exact_approximate) { + GlobalContext globalContext; + CalculationStore store; + store.push("1+3/4", &globalContext); store.push("ans+2/3", &globalContext); ::Calculation::Calculation * lastCalculation = store.calculationAtIndex(1); @@ -58,4 +64,18 @@ QUIZ_CASE(calculation_store) { lastCalculation = store.calculationAtIndex(2); quiz_assert(lastCalculation->shouldOnlyDisplayApproximateOutput(&globalContext) == true); quiz_assert(strcmp(lastCalculation->approximateOutputText(),"2.6366666666667") == 0); + + store.deleteAll(); + store.push("1/2", &globalContext); + lastCalculation = store.calculationAtIndex(1); + quiz_assert(lastCalculation->exactAndApproximateDisplayedOutputsAreEqual(&globalContext) == ::Calculation::Calculation::EqualSign::Equal); + quiz_assert(lastCalculation->shouldOnlyDisplayApproximateOutput(&globalContext) == false); + + store.deleteAll(); + store.push("1/3", &globalContext); + lastCalculation = store.calculationAtIndex(1); + quiz_assert(lastCalculation->exactAndApproximateDisplayedOutputsAreEqual(&globalContext) == ::Calculation::Calculation::EqualSign::Approximation); + quiz_assert(lastCalculation->shouldOnlyDisplayApproximateOutput(&globalContext) == false); + + store.deleteAll(); }