[keel] Cleanup
This commit is contained in:
11
src/keel/test/CMakeLists.txt
Normal file
11
src/keel/test/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
add_executable(
|
||||
KeelTest
|
||||
tests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
KeelTest
|
||||
Keel
|
||||
)
|
||||
|
||||
add_test("[keel] KeelTest writeUuidHeader" KeelTest writeUuidHeader)
|
40
src/keel/test/tests.cpp
Normal file
40
src/keel/test/tests.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#undef NDEBUG
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
|
||||
static std::map<std::string, ox::Error(*)()> tests = {
|
||||
{
|
||||
"writeUuidHeader",
|
||||
[] {
|
||||
constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db";
|
||||
constexpr ox::StringView hdr = "K1;8d814442-f46e-4cc3-8edc-ca3c01cc86db;";
|
||||
oxRequire(uuid, ox::UUID::fromString(uuidStr));
|
||||
ox::Array<char, hdr.len()> buff;
|
||||
ox::CharBuffWriter bw(buff);
|
||||
oxReturnError(keel::writeUuidHeader(bw, uuid));
|
||||
oxExpect(ox::StringView(buff.data(), buff.size()), hdr);
|
||||
return OxError(0);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
int main(int argc, const char **args) {
|
||||
int retval = -1;
|
||||
if (argc > 0) {
|
||||
auto testName = args[1];
|
||||
if (tests.find(testName) != tests.end()) {
|
||||
retval = static_cast<int>(tests[testName]());
|
||||
} else {
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
Reference in New Issue
Block a user