From af9496de655d9d53407c0b936c68b66aefd45188 Mon Sep 17 00:00:00 2001 From: davidjacnogueira Date: Fri, 25 Nov 2016 13:17:45 +0000 Subject: [PATCH] Update microunit test. --- deps/microunit.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/deps/microunit.h b/deps/microunit.h index a389e21..64d43b3 100644 --- a/deps/microunit.h +++ b/deps/microunit.h @@ -1,5 +1,6 @@ /** * @file microunit.h +* @version 0.1 * @author Sebastiao Salvador de Miranda (ssm) * @brief Tiny library for cpp unit testing. Should work on any c++11 compiler. * @@ -59,7 +60,6 @@ #ifndef _MICROUNIT_MICROUNIT_H_ #define _MICROUNIT_MICROUNIT_H_ #include -#include #include #include #include @@ -111,7 +111,7 @@ void SetTerminalColor(int color_code) { CONSOLE_SCREEN_BUFFER_INFO buffer_info; GetConsoleScreenBufferInfo(handler, &buffer_info); SetConsoleTextAttribute(handler, ((buffer_info.wAttributes & 0xFFF0) | - (WORD)color_code)); + (WORD)color_code)); #else std::cout << ColorCodeToANSI(color_code); #endif @@ -224,7 +224,7 @@ public: * @returns True if all tests pass, false otherwise. */ static bool Run() { - std::vector failures; + std::vector failures, sucesses; // Iterate all registered unit tests for (auto& unit : Instance().unitfunction_map_) { @@ -240,12 +240,20 @@ public: failures.push_back(unit.first); } else { TERMINAL_GOOD << "Passed test"; + sucesses.push_back(unit.first); } } std::cout << MICROUNIT_SEPARATOR << std::endl << MICROUNIT_SEPARATOR << std::endl; + TERMINAL_GOOD << "Passed " << sucesses.size() + << " test cases:"; + for (const auto& success_t : sucesses) { + TERMINAL_GOOD << success_t; + } + std::cout << MICROUNIT_SEPARATOR << std::endl; + // Output result summary if (failures.empty()) { TERMINAL_GOOD << "All tests passed"; @@ -303,7 +311,7 @@ private: static UnitTester instance; return instance; } - std::unordered_map unitfunction_map_; + std::map unitfunction_map_; }; } @@ -329,7 +337,7 @@ private: #define UNIT(FUNCTION) \ void FUNCTION(microunit::UnitFunctionResult*); \ REGISTER_UNIT(FUNCTION); \ -void FUNCTION(microunit::UnitFunctionResult *__microunit_testresult) +void FUNCTION(microunit::UnitFunctionResult *__microunit_testresult) /** * @brief Pass the test and return from the test case. @@ -359,11 +367,11 @@ FAIL(); \ } /** -* @brief Check a particular test condition. If the condition holds, fail the +* @brief Check a particular test condition. If the condition holds, fail the * test and return. */ #define ASSERT_FALSE(condition) if((condition)) { \ LOG_BAD << "Assert-false failed: " #condition << std::endl; \ FAIL(); \ } -#endif +#endif \ No newline at end of file