Update microunit test.

This commit is contained in:
davidjacnogueira
2016-11-25 13:17:45 +00:00
parent 0a636416ed
commit af9496de65

14
deps/microunit.h vendored
View File

@@ -1,5 +1,6 @@
/** /**
* @file microunit.h * @file microunit.h
* @version 0.1
* @author Sebastiao Salvador de Miranda (ssm) * @author Sebastiao Salvador de Miranda (ssm)
* @brief Tiny library for cpp unit testing. Should work on any c++11 compiler. * @brief Tiny library for cpp unit testing. Should work on any c++11 compiler.
* *
@@ -59,7 +60,6 @@
#ifndef _MICROUNIT_MICROUNIT_H_ #ifndef _MICROUNIT_MICROUNIT_H_
#define _MICROUNIT_MICROUNIT_H_ #define _MICROUNIT_MICROUNIT_H_
#include <string.h> #include <string.h>
#include <unordered_map>
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -224,7 +224,7 @@ public:
* @returns True if all tests pass, false otherwise. * @returns True if all tests pass, false otherwise.
*/ */
static bool Run() { static bool Run() {
std::vector<std::string> failures; std::vector<std::string> failures, sucesses;
// Iterate all registered unit tests // Iterate all registered unit tests
for (auto& unit : Instance().unitfunction_map_) { for (auto& unit : Instance().unitfunction_map_) {
@@ -240,12 +240,20 @@ public:
failures.push_back(unit.first); failures.push_back(unit.first);
} else { } else {
TERMINAL_GOOD << "Passed test"; TERMINAL_GOOD << "Passed test";
sucesses.push_back(unit.first);
} }
} }
std::cout std::cout
<< MICROUNIT_SEPARATOR << std::endl << MICROUNIT_SEPARATOR << std::endl
<< 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 // Output result summary
if (failures.empty()) { if (failures.empty()) {
TERMINAL_GOOD << "All tests passed"; TERMINAL_GOOD << "All tests passed";
@@ -303,7 +311,7 @@ private:
static UnitTester instance; static UnitTester instance;
return instance; return instance;
} }
std::unordered_map<std::string, UnitFunction> unitfunction_map_; std::map<std::string, UnitFunction> unitfunction_map_;
}; };
} }