improved unit test feedback

This commit is contained in:
itsmattkc
2022-01-02 13:34:57 -08:00
parent 2da492f79f
commit 74f379b162
3 changed files with 14 additions and 12 deletions
+2 -2
View File
@@ -17,13 +17,13 @@
function(olive_add_test GROUP NAME SOURCE)
file(READ "${SOURCE}" TEST_FILE_CONTENT)
string(REGEX MATCHALL "OLIVE_ADD_TEST\(.[A-Za-z0-9_]+\)" TEST_FUNCTIONS ${TEST_FILE_CONTENT})
set(TEST_BODY "int main(int argc, char** argv)\n{\n")
set(TEST_BODY "int main(int argc, char** argv)\n{\n int ret;(void)ret;")
set(TEST_INDEX 1)
list(LENGTH TEST_FUNCTIONS TEST_COUNT)
foreach (TEST_FUNC ${TEST_FUNCTIONS})
string(REPLACE "OLIVE_ADD_TEST(" "" TEST_FUNC "${TEST_FUNC}")
string(APPEND TEST_BODY " std::cout << \"[${TEST_INDEX}/${TEST_COUNT}] ${GROUP} - ${TEST_FUNC}\";\n")
string(APPEND TEST_BODY " if (olive::Test${TEST_FUNC}()) {std::cout << \" - PASSED\" << std::endl;}else{std::cout << \" - FAILED\" << std::endl;return 1;}\n")
string(APPEND TEST_BODY " if ((ret = olive::Test${TEST_FUNC}()) == OLIVE_TEST_SUCCESS) {std::cout << \" - PASSED\" << std::endl;}else{std::cout << \" - FAILED AT LINE \" << ret << std::endl;return 1;}\n")
MATH(EXPR TEST_INDEX "${TEST_INDEX}+1")
endforeach()
string(APPEND TEST_BODY " return 0;\n}")
+7 -5
View File
@@ -20,9 +20,11 @@
#include <iostream>
#define OLIVE_ASSERT(x) if (!(x)) return false
#define OLIVE_ASSERT_EQUAL(x, y) if (x != y) {std::cout << " - Equal assert failed on line " << __LINE__ << ": " << x << " != " << y; return false;}void()
#define OLIVE_TEST_END return true
#define OLIVE_TEST_SUCCESS -1
#define OLIVE_ADD_TEST(x) bool Test##x()
#define OLIVE_ADD_DISABLED_TEST(x) bool Test##x()
#define OLIVE_ASSERT(x) if (!(x)) return __LINE__
#define OLIVE_ASSERT_EQUAL(x, y) if (x != y) {std::cout << " - Equal assert failed: " << x << " != " << y; return __LINE__;}void()
#define OLIVE_TEST_END return OLIVE_TEST_SUCCESS
#define OLIVE_ADD_TEST(x) int Test##x()
#define OLIVE_ADD_DISABLED_TEST(x) int Test##x()
+5 -5
View File
@@ -553,11 +553,11 @@ OLIVE_ADD_TEST(InsertGaps_SingleTrack)
command.undo_now();
OLIVE_ASSERT(track->Blocks().size() == 3);
OLIVE_ASSERT(track->Blocks().at(0) == a);
OLIVE_ASSERT(track->Blocks().at(0)->length() = 1);
OLIVE_ASSERT(track->Blocks().at(1) == b);
OLIVE_ASSERT(track->Blocks().at(2) == c);
OLIVE_ASSERT_EQUAL(track->Blocks().size(), 3);
OLIVE_ASSERT_EQUAL(track->Blocks().at(0), a);
OLIVE_ASSERT_EQUAL(track->Blocks().at(0)->length(), 1);
OLIVE_ASSERT_EQUAL(track->Blocks().at(1), b);
OLIVE_ASSERT_EQUAL(track->Blocks().at(2), c);
}
{