Skip to content

Commit 26afe0f

Browse files
committed
test(file-logger): guard timestamp tests for c++11
1 parent 189835f commit 26afe0f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/file_logger_rotation_naming_timestamp_ms_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22
#include <regex>
33
#include <string>
44
#include <vector>
5+
#if __cplusplus >= 201703L
56
#include <filesystem>
7+
#else
8+
#include <cstdlib>
9+
#endif
610

711
int main() {
12+
#if __cplusplus >= 201703L
813
std::filesystem::remove_all(logit::get_exec_dir() + "/rotation_tms");
14+
#else
15+
#ifdef _WIN32
16+
std::string clean = logit::get_exec_dir() + "\\rotation_tms";
17+
std::string cmd = "rmdir /s /q \"" + clean + "\"";
18+
#else
19+
std::string clean = logit::get_exec_dir() + "/rotation_tms";
20+
std::string cmd = "rm -rf \"" + clean + "\"";
21+
#endif
22+
std::system(cmd.c_str());
23+
#endif
924
const std::string dir = logit::get_exec_dir() + "/rotation_tms";
1025
logit::FileLogger::Config cfg;
1126
cfg.directory = "rotation_tms";

tests/file_logger_rotation_naming_timestamp_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22
#include <regex>
33
#include <string>
44
#include <vector>
5+
#if __cplusplus >= 201703L
56
#include <filesystem>
7+
#else
8+
#include <cstdlib>
9+
#endif
610

711
int main() {
12+
#if __cplusplus >= 201703L
813
std::filesystem::remove_all(logit::get_exec_dir() + "/rotation_ts");
14+
#else
15+
#ifdef _WIN32
16+
std::string clean = logit::get_exec_dir() + "\\rotation_ts";
17+
std::string cmd = "rmdir /s /q \"" + clean + "\"";
18+
#else
19+
std::string clean = logit::get_exec_dir() + "/rotation_ts";
20+
std::string cmd = "rm -rf \"" + clean + "\"";
21+
#endif
22+
std::system(cmd.c_str());
23+
#endif
924
const std::string dir = logit::get_exec_dir() + "/rotation_ts";
1025
logit::FileLogger::Config cfg;
1126
cfg.directory = "rotation_ts";

0 commit comments

Comments
 (0)