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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user