Skip to content

Commit

Permalink
Add time print mode to test application
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Nov 24, 2024
1 parent 5f49b30 commit a687dc1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/test-sample/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
#include <fstream>
#include <thread>
#include <atomic>
#include <optional>
#include <vector>
#include <optional>
#include <string_view>

#include <Windows.h>

using namespace std::literals;

// Externally visible and potentially modifiable state
// to trick compiler optimizations
__declspec(dllexport) bool do_the_task = true;
Expand Down Expand Up @@ -178,6 +182,12 @@ bool test_native_exceptions()
}
}

void print_time()
{
const auto epoch_time = std::chrono::system_clock::now().time_since_epoch();
printf("Time: %lld\n", epoch_time.count());
}

#define RUN_TEST(func, name) \
{ \
printf("Running test '" name "': "); \
Expand All @@ -186,8 +196,14 @@ bool test_native_exceptions()
puts(res ? "Success" : "Fail"); \
}

int main(int /*argc*/, const char* /*argv*/[])
int main(int argc, const char* argv[])
{
if(argc == 2 && argv[1] == "-time"sv)
{
print_time();
return 0;
}

bool valid = true;

RUN_TEST(test_io, "I/O")
Expand Down

0 comments on commit a687dc1

Please sign in to comment.