mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +00:00
151 using-directives, using-declarations, type aliases and namespace aliases in source and test files that nothing refers to: the name is never used, it duplicates a using already in scope, or the code sits inside the namespace it names. Each one was removed on its own and the file still compiled, both as it is and with every header-level using taken away, so none of them was only redundant because a header leaks the same name. With the using gone, 28 #include lines and one forward declaration had no other reference left in their file (boost/optional.hpp without any optional, property_tree headers without any ptree) and go with it. No header is touched.
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#include <catch2/catch_all.hpp>
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include "libslic3r/Time.hpp"
|
|
|
|
#include <ctime>
|
|
#include <sstream>
|
|
#include <iomanip>
|
|
#include <locale>
|
|
#include <string>
|
|
|
|
static 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);
|
|
|
|
std::string mydate = "20190710T085000Z";
|
|
time_t t = Slic3r::Utils::parse_iso_utc_timestamp(mydate);
|
|
std::string date = Slic3r::Utils::iso_utc_timestamp(t);
|
|
|
|
REQUIRE(date == mydate);
|
|
}
|
|
|
|
TEST_CASE("Slic3r_UTC_Time_Format", "[Timeutils]") {
|
|
using namespace Slic3r::Utils;
|
|
test_time_fmt(TimeFormat::gcode);
|
|
|
|
std::string mydate = "2019-07-10 at 08:50:00 UTC";
|
|
time_t t = Slic3r::Utils::str2time(mydate, TimeZone::utc, TimeFormat::gcode);
|
|
std::string date = Slic3r::Utils::utc_timestamp(t);
|
|
|
|
REQUIRE(date == mydate);
|
|
}
|