summaryrefslogtreecommitdiff
path: root/src/keltest
diff options
context:
space:
mode:
authorClaudius Holeksa <mail@keldu.de>2023-05-09 17:58:30 +0200
committerClaudius Holeksa <mail@keldu.de>2023-05-09 17:58:30 +0200
commit2e8ee05aee8c03aaf1f991b8403a6980eeb1f4fc (patch)
tree14aabbe752f00f218eb3a01df2e1f155fde3e409 /src/keltest
parenta178b64a681dc0a381835ab567853c132753902f (diff)
downloadmini-test-2e8ee05aee8c03aaf1f991b8403a6980eeb1f4fc.tar.gz
Fixed build and install issues. Confirmed install and build on nix
Diffstat (limited to 'src/keltest')
-rw-r--r--src/keltest/test.cpp15
-rw-r--r--src/keltest/test.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/keltest/test.cpp b/src/keltest/test.cpp
index 1178b20..d8c5886 100644
--- a/src/keltest/test.cpp
+++ b/src/keltest/test.cpp
@@ -3,6 +3,7 @@
#include <chrono>
#include <iostream>
#include <string_view>
+#include <variant>
namespace keltest {
@@ -12,7 +13,7 @@ constexpr bool always_false = false;
test_case* test_case_head = nullptr;
test_case** test_case_tail = &test_case_head;
-test_case::test_case(std::string file_, uint32_t line_, std::string& description_):
+test_case::test_case(std::string file_, uint32_t line_, std::string description_):
file{std::move(file_)},
line{line_},
description{std::move(description_)},
@@ -87,8 +88,8 @@ public:
size_t failed_count = 0;
for(test_case* test = test_case_head; test != nullptr; test = test->next){
- std::string name = test->fil + std::string{":"} + std::to_string(test->line) + std::string{":"} + test->description;
- write(colour::blue, "[ TEST ] ", name);
+ std::string name = test->file + std::string{":"} + std::to_string(test->line) + std::string{":"} + test->description;
+ write(colour::blue{}, "[ TEST ] ", name);
bool failed = true;
std::string fail_message;
@@ -110,17 +111,17 @@ public:
std::string message = name + std::string{" ("} + std::to_string(runtime_duration.count()) + std::string{" µs) "};
if( failed ){
- write(colour::red, "[ FAIL ] ", message + std::string{" "} + fail_message);
+ write(colour::red{}, "[ FAIL ] ", message + std::string{" "} + fail_message);
++failed_count;
}else{
- write(colour::green, "[ PASS ] ", message);
+ write(colour::green{}, "[ PASS ] ", message);
++passed_count;
}
}
- if( passed_count > 0 ) write(colour::green, std::to_string(passed_count) + std::string{" test(s) passed"}, "");
+ if( passed_count > 0 ) write(colour::green{}, std::to_string(passed_count) + std::string{" test(s) passed"}, "");
- if( failed_count > 0 ) write(colour::red, std::to_string(failed_count) + std::string{" test(s) failed"}, "");
+ if( failed_count > 0 ) write(colour::red{}, std::to_string(failed_count) + std::string{" test(s) failed"}, "");
return failed_count > 0 ? -1 : 0;
}
diff --git a/src/keltest/test.h b/src/keltest/test.h
index 24f008f..cd23f28 100644
--- a/src/keltest/test.h
+++ b/src/keltest/test.h
@@ -12,6 +12,8 @@ private:
std::string description;
test_case* next;
test_case** prev;
+
+ friend class test_runner;
public:
test_case(std::string file_, uint32_t line_, std::string description_);
~test_case();