1
- #include < src/library/colorizer/ colors.h>
1
+ #include " colors.h"
2
2
3
- #include < src/library/testing/unittest/registar.h>
4
3
#include < ydb-cpp-sdk/util/stream/str.h>
5
-
6
4
#include < ydb-cpp-sdk/util/string/escape.h>
7
5
6
+ #include < src/library/testing/unittest/registar.h>
7
+
8
8
Y_UNIT_TEST_SUITE (ColorizerTest) {
9
9
Y_UNIT_TEST (BasicTest) {
10
10
NColorizer::TColors colors;
11
11
colors.Enable ();
12
12
UNIT_ASSERT_STRINGS_EQUAL (EscapeC (colors.BlueColor ()), " \\ x1B[22;34m" );
13
13
UNIT_ASSERT_STRINGS_EQUAL (EscapeC (colors.ForeBlue ()), " \\ x1B[34m" );
14
14
colors.Disable ();
15
- UNIT_ASSERT (colors.BlueColor ().Empty ());
15
+ UNIT_ASSERT (colors.BlueColor ().empty ());
16
16
}
17
17
18
18
Y_UNIT_TEST (ResettingTest) {
@@ -28,24 +28,22 @@ Y_UNIT_TEST_SUITE(ColorizerTest) {
28
28
Y_UNIT_TEST (PrintAnsi) {
29
29
UNIT_ASSERT_STRINGS_EQUAL (EscapeC (ToString (NColorizer::BLUE)), " \\ x1B[0m\\ x1B[0;34m" );
30
30
{
31
- std::string str;
32
- std::stringOutput sink{str};
31
+ std::ostringstream sink;
33
32
34
33
sink << NColorizer::BLUE << " foo!" << NColorizer::RESET;
35
34
36
- UNIT_ASSERT_STRINGS_EQUAL (EscapeC (str) , " foo!" ); // std::stringOutput is not tty
35
+ UNIT_ASSERT_STRINGS_EQUAL (EscapeC (sink. str ()) , " foo!" ); // std::ostringstream is not tty
37
36
}
38
37
{
39
- std::string str;
40
- std::stringOutput sink{str};
38
+ std::ostringstream sink;
41
39
42
40
// Enable this for test purposes. If you're making output of the `AutoColors` constant and this
43
41
// test does not compile, you're free to remove it.
44
42
NColorizer::AutoColors (sink).Enable ();
45
43
46
44
sink << NColorizer::BLUE << " foo!" << NColorizer::RESET;
47
45
48
- UNIT_ASSERT_STRINGS_EQUAL (EscapeC (str) , " \\ x1B[0m\\ x1B[0;34mfoo!\\ x1B[0m" ); // std::stringOutput is not tty
46
+ UNIT_ASSERT_STRINGS_EQUAL (EscapeC (sink. str ()) , " \\ x1B[0m\\ x1B[0;34mfoo!\\ x1B[0m" ); // std::ostringstream is not tty
49
47
}
50
48
}
51
49
0 commit comments