MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / TestBytesLiteral

Function TestBytesLiteral

internal/strings_test.cc:89–104  ·  view source on GitHub ↗

takes a byte literal of the form b'...', b'''...'''

Source from the content-addressed store, hash-verified

87
88// <quoted> takes a byte literal of the form b'...', b'''...'''
89void TestBytesLiteral(const std::string& quoted) {
90 // Parse the literal.
91 ASSERT_OK_AND_ASSIGN(auto unquoted, ParseBytesLiteral(quoted));
92
93 // Take the parsed literal and turn it back to a literal.
94 std::string requoted = FormatBytesLiteral(unquoted);
95 // Parse it again.
96 ASSERT_OK_AND_ASSIGN(auto unquoted2, ParseBytesLiteral(requoted));
97 // Test the parsed literal forms for equality, not the unparsed forms.
98 // This is because the unparsed forms can have different representations for
99 // the same data, i.e., \000 and \x00.
100 EXPECT_EQ(unquoted, unquoted2)
101 << "unquoted : " << unquoted << "\nunquoted2: " << unquoted2;
102
103 TestBytesEscaping(unquoted, quoted);
104}
105
106// <quoted> takes a raw byte literal of the form rb'...', br'...', rb'''...'''
107// or br'''...'''. <unquoted> is the expected parsed form of <quoted>.

Callers 2

TestUnescapedBytesFunction · 0.85
TESTFunction · 0.85

Calls 2

FormatBytesLiteralFunction · 0.85
TestBytesEscapingFunction · 0.85

Tested by

no test coverage detected