mirror of
https://github.com/davidalbertonogueira/MLP.git
synced 2025-12-18 12:54:41 +03:00
Update microunit test.
This commit is contained in:
16
deps/microunit.h
vendored
16
deps/microunit.h
vendored
@@ -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>
|
||||||
@@ -111,7 +111,7 @@ void SetTerminalColor(int color_code) {
|
|||||||
CONSOLE_SCREEN_BUFFER_INFO buffer_info;
|
CONSOLE_SCREEN_BUFFER_INFO buffer_info;
|
||||||
GetConsoleScreenBufferInfo(handler, &buffer_info);
|
GetConsoleScreenBufferInfo(handler, &buffer_info);
|
||||||
SetConsoleTextAttribute(handler, ((buffer_info.wAttributes & 0xFFF0) |
|
SetConsoleTextAttribute(handler, ((buffer_info.wAttributes & 0xFFF0) |
|
||||||
(WORD)color_code));
|
(WORD)color_code));
|
||||||
#else
|
#else
|
||||||
std::cout << ColorCodeToANSI(color_code);
|
std::cout << ColorCodeToANSI(color_code);
|
||||||
#endif
|
#endif
|
||||||
@@ -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_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user