Skip to content

Commit

Permalink
fix: cstr and std::string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Dec 19, 2023
1 parent 57b1f3a commit 6b12dde
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions push/tests/internal/label_encoder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ class LabelEncoderTest : public testing::Test {
// test cases taken from https://github.com/prometheus/pushgateway#url

TEST_F(LabelEncoderTest, regular) {
EXPECT_EQ("/foo/bar", Encode(Label{"foo", "bar"}));
EXPECT_EQ(std::string{"/foo/bar"}, Encode(Label{"foo", "bar"}));
}

TEST_F(LabelEncoderTest, empty) {
EXPECT_EQ("/first_label@base64/=", Encode(Label{"first_label", ""}));
EXPECT_EQ(std::string{"/first_label@base64/="},
Encode(Label{"first_label", ""}));
}

TEST_F(LabelEncoderTest, path) {
EXPECT_EQ("/path@base64/L3Zhci90bXA=", Encode(Label{"path", "/var/tmp"}));
EXPECT_EQ(std::string{"/path@base64/L3Zhci90bXA="},
Encode(Label{"path", "/var/tmp"}));
}

TEST_F(LabelEncoderTest, unicode) {
const char unicodeText[] =
"\xce\xa0\xcf\x81\xce\xbf\xce\xbc\xce\xb7\xce\xb8\xce\xb5\xcf\x8d\xcf"
"\x82"; // Προμηθεύς
EXPECT_EQ("/name@base64/zqDPgc6_zrzOt864zrXPjc-C",
EXPECT_EQ(std::string{"/name@base64/zqDPgc6_zrzOt864zrXPjc-C"},
Encode(Label{"name", unicodeText}));
}

Expand Down

0 comments on commit 6b12dde

Please sign in to comment.