mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 16:51:21 -06:00
Catch2 test framework integration into tm_sla_tests.
This commit is contained in:
parent
2edd5abf06
commit
5ca962a1da
20 changed files with 22469 additions and 36 deletions
38
tests/timeutils/timeutils_tests_main.cpp
Normal file
38
tests/timeutils/timeutils_tests_main.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "libslic3r/Time.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
|
||||
namespace {
|
||||
|
||||
void test_time_fmt(Slic3r::Utils::TimeFormat fmt) {
|
||||
using namespace Slic3r::Utils;
|
||||
time_t t = get_current_time_utc();
|
||||
|
||||
std::string tstr = time2str(t, TimeZone::local, fmt);
|
||||
time_t parsedtime = str2time(tstr, TimeZone::local, fmt);
|
||||
REQUIRE(t == parsedtime);
|
||||
|
||||
tstr = time2str(t, TimeZone::utc, fmt);
|
||||
parsedtime = str2time(tstr, TimeZone::utc, fmt);
|
||||
REQUIRE(t == parsedtime);
|
||||
|
||||
parsedtime = str2time("not valid string", TimeZone::local, fmt);
|
||||
REQUIRE(parsedtime == time_t(-1));
|
||||
|
||||
parsedtime = str2time("not valid string", TimeZone::utc, fmt);
|
||||
REQUIRE(parsedtime == time_t(-1));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("ISO8601Z", "[Timeutils]") {
|
||||
test_time_fmt(Slic3r::Utils::TimeFormat::iso8601Z);
|
||||
}
|
||||
|
||||
TEST_CASE("Slic3r_UTC_Time_Format", "[Timeutils]") {
|
||||
test_time_fmt(Slic3r::Utils::TimeFormat::gcode);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue