diff --git a/qa/common/libeval/test_numeric_evaluator.cpp b/qa/common/libeval/test_numeric_evaluator.cpp index b550e6c1c1..3eeb9aef97 100644 --- a/qa/common/libeval/test_numeric_evaluator.cpp +++ b/qa/common/libeval/test_numeric_evaluator.cpp @@ -26,8 +26,7 @@ * Test suite for #NUMERIC_EVALUATOR */ -#include -#include +#include #include @@ -161,17 +160,20 @@ BOOST_AUTO_TEST_CASE( Results ) { for( const auto& c : eval_cases_valid ) { - // Clear for new string input - m_eval.Clear(); + BOOST_TEST_CONTEXT( KI_TEST::InOutString( c.input, c.exp_result ) ) + { + // Clear for new string input + m_eval.Clear(); - m_eval.Process( c.input ); + m_eval.Process( c.input ); - // These are all valid - BOOST_CHECK_EQUAL( m_eval.IsValid(), true ); - BOOST_CHECK_EQUAL( m_eval.Result(), c.exp_result ); + // These are all valid + BOOST_CHECK_EQUAL( m_eval.IsValid(), true ); + BOOST_CHECK_EQUAL( m_eval.Result(), c.exp_result ); - // Does original text still match? - BOOST_CHECK_EQUAL( m_eval.OriginalText(), c.input ); + // Does original text still match? + BOOST_CHECK_EQUAL( m_eval.OriginalText(), c.input ); + } } } @@ -214,16 +216,19 @@ BOOST_AUTO_TEST_CASE( ResultsInvalid ) { for( const auto& c : eval_cases_invalid ) { - // Clear for new string input - m_eval.Clear(); + BOOST_TEST_CONTEXT( c.input ) + { + // Clear for new string input + m_eval.Clear(); - m_eval.Process( c.input ); + m_eval.Process( c.input ); - // These are all valid - BOOST_CHECK_EQUAL( m_eval.IsValid(), false ); + // These are all valid + BOOST_CHECK_EQUAL( m_eval.IsValid(), false ); - // Does original text still match? - BOOST_CHECK_EQUAL( m_eval.OriginalText(), c.input ); + // Does original text still match? + BOOST_CHECK_EQUAL( m_eval.OriginalText(), c.input ); + } } } diff --git a/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h b/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h index 53f6b1fbed..87c3f90733 100644 --- a/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h +++ b/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h @@ -230,6 +230,27 @@ void CheckUnorderedMatches( } } + +/** + * Get a simple string "aIn -> aOut". + * + * Useful for BOOST_TEST_CONTEXT blocks as a brief description where a full + * case name would be a bit too much. + * + * @tparam IN the input type + * @tparam OUT the output type + * @param aIn the input + * @param aOut the output + * @return "aIn -> aOut" + */ +template +std::string InOutString( const IN& aIn, const OUT& aOut ) +{ + std::stringstream ss; + ss << aIn << " -> " << aOut; + return ss.str(); +} + } // namespace KI_TEST #endif // UNIT_TEST_UTILS__H \ No newline at end of file