Add subtitle to Hype Chats (#4715)

* feat: more hype chat

* Add `std::chrono::seconds` overload to formatTime

* Move & rename it to HypeChat + some other mini things

* Add changelog entry

* fix formattime test

---------

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-07-30 18:54:42 +02:00
committed by GitHub
parent 71594ad0d8
commit 703847c9ba
8 changed files with 207 additions and 8 deletions
+75
View File
@@ -2,7 +2,10 @@
#include <gtest/gtest.h>
#include <chrono>
using namespace chatterino;
using namespace std::chrono_literals;
TEST(FormatTime, Int)
{
@@ -131,3 +134,75 @@ TEST(FormatTime, QString)
<< ") did not match expected value " << qUtf8Printable(expected);
}
}
TEST(FormatTime, chrono)
{
struct TestCase {
std::chrono::seconds input;
QString expectedOutput;
};
std::vector<TestCase> tests{
{
0s,
"",
},
{
1337s,
"22m 17s",
},
{
{22min + 17s},
"22m 17s",
},
{
623452s,
"7d 5h 10m 52s",
},
{
8345s,
"2h 19m 5s",
},
{
314034s,
"3d 15h 13m 54s",
},
{
27s,
"27s",
},
{
34589s,
"9h 36m 29s",
},
{
9h + 36min + 29s,
"9h 36m 29s",
},
{
3659s,
"1h 59s",
},
{
1h + 59s,
"1h 59s",
},
{
1045345s,
"12d 2h 22m 25s",
},
{
86432s,
"1d 32s",
},
};
for (const auto &[input, expected] : tests)
{
const auto actual = formatTime(input);
EXPECT_EQ(actual, expected)
<< qUtf8Printable(actual) << " did not match expected value "
<< qUtf8Printable(expected);
}
}