--- nono/lib/test_mystring.cpp 2026/04/29 17:05:08 1.1.1.3 +++ nono/lib/test_mystring.cpp 2026/04/29 17:05:56 1.1.1.4 @@ -202,6 +202,8 @@ class Test_MyString : public TestClass TESTDEF(string_split_1); TESTDEF(string_split_2); TESTDEF(format_number_1); + TESTDEF(SecToStr_1); + TESTDEF(TimeToStr_1); } void string_ltrim_1() { @@ -401,6 +403,56 @@ class Test_MyString : public TestClass xp_eq(exp, format_number(val), t); } } + + void SecToStr_1() { + TestTable table = { + { 0, "0.000'000'000" }, + { 1, "0.000'000'001" }, + { 999999999, "0.999'999'999" }, + { 4300020001, "4.300'020'001" }, + { 9999999999, "9.999'999'999" }, + { 10000000001, "10.000'000'001" }, + { 100000000002, "100.000'000'002" }, + { 1000000000003, "1000.000'000'003" }, + { 10000000000004, "10000.000'000'004" }, + { 100000000000005, "100000.000'000'005" }, + { 1000000000000006, "1000000.000'000'006" }, + { 10000000000000007, "10000000.000'000'007" }, + { 100000000000000008, "100000000.000'000'008" }, + }; + + for (const auto& t : table) { + auto val = t.get<0>(); + const auto& exp = t.get<1>(); + + xp_eq(exp, SecToStr(val), t); + } + } + + void TimeToStr_1() { + TestTable table = { + { 0, "0.000'000'000" }, + { 1, "0.000'000'001" }, + { 999999999, "0.999'999'999" }, + { 4300020001, "4.300'020'001" }, + { 9999999999, "9.999'999'999" }, + { 10000000001, "10.000'000'001" }, + { 100000000002, " 1:40.000'000'002" }, + { 1000000000003, "16:40.000'000'003" }, + { 10000000000004, " 2:46:40.000'000'004" }, + { 100000000000005, " 1d 03:46:40.000'000'005" }, + { 1000000000000006, " 11d 13:46:40.000'000'006" }, + { 10000000000000007, "115d 17:46:40.000'000'007" }, + { 100000000000000008, "1157d 09:46:40.000'000'008" }, + }; + + for (const auto& t : table) { + auto val = t.get<0>(); + const auto& exp = t.get<1>(); + + xp_eq(exp, TimeToStr(val), t); + } + } }; int