Skip to content

Commit c4e28dc

Browse files
committed
Fix tests (#171)
1 parent e71d020 commit c4e28dc

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/library/colorizer/colors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,5 @@ namespace NColorizer {
226226

227227
std::string_view ToStringBuf(NColorizer::EAnsiCode x);
228228
std::string ToString(NColorizer::EAnsiCode x);
229+
230+
std::ostream& operator<<(std::ostream& os, NColorizer::EAnsiCode x);

src/library/colorizer/output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Consider printing elements of `EAnsiCode` directly.
77

88
namespace NColorizer {
9-
typedef std::string_view (TColors::*TColorFunc)() const;
9+
using TColorFunc = std::string_view (TColors::*)() const;
1010

1111
struct TColorHandle {
1212
const TColors* C;

tests/library/colorizer/ut.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#include <src/library/colorizer/colors.h>
1+
#include "colors.h"
22

3-
#include <src/library/testing/unittest/registar.h>
43
#include <ydb-cpp-sdk/util/stream/str.h>
5-
64
#include <ydb-cpp-sdk/util/string/escape.h>
75

6+
#include <src/library/testing/unittest/registar.h>
7+
88
Y_UNIT_TEST_SUITE(ColorizerTest) {
99
Y_UNIT_TEST(BasicTest) {
1010
NColorizer::TColors colors;
1111
colors.Enable();
1212
UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.BlueColor()), "\\x1B[22;34m");
1313
UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.ForeBlue()), "\\x1B[34m");
1414
colors.Disable();
15-
UNIT_ASSERT(colors.BlueColor().Empty());
15+
UNIT_ASSERT(colors.BlueColor().empty());
1616
}
1717

1818
Y_UNIT_TEST(ResettingTest) {
@@ -28,24 +28,22 @@ Y_UNIT_TEST_SUITE(ColorizerTest) {
2828
Y_UNIT_TEST(PrintAnsi) {
2929
UNIT_ASSERT_STRINGS_EQUAL(EscapeC(ToString(NColorizer::BLUE)), "\\x1B[0m\\x1B[0;34m");
3030
{
31-
std::string str;
32-
std::stringOutput sink{str};
31+
std::ostringstream sink;
3332

3433
sink << NColorizer::BLUE << "foo!" << NColorizer::RESET;
3534

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
3736
}
3837
{
39-
std::string str;
40-
std::stringOutput sink{str};
38+
std::ostringstream sink;
4139

4240
// Enable this for test purposes. If you're making output of the `AutoColors` constant and this
4341
// test does not compile, you're free to remove it.
4442
NColorizer::AutoColors(sink).Enable();
4543

4644
sink << NColorizer::BLUE << "foo!" << NColorizer::RESET;
4745

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
4947
}
5048
}
5149

0 commit comments

Comments
 (0)