Commit 1e691dcc authored by Kenton Varda's avatar Kenton Varda

Make sure ArrayPtr<char> stringifies the same as ArrayPtr<const char> (without…

Make sure ArrayPtr<char> stringifies the same as ArrayPtr<const char> (without commas after each character)
parent f478b0f5
...@@ -34,6 +34,15 @@ TEST(String, Str) { ...@@ -34,6 +34,15 @@ TEST(String, Str) {
EXPECT_EQ("foo", str('f', 'o', 'o')); EXPECT_EQ("foo", str('f', 'o', 'o'));
EXPECT_EQ("123 234 -123 e7", EXPECT_EQ("123 234 -123 e7",
str((int8_t)123, " ", (uint8_t)234, " ", (int8_t)-123, " ", hex((uint8_t)0xe7))); str((int8_t)123, " ", (uint8_t)234, " ", (int8_t)-123, " ", hex((uint8_t)0xe7)));
char buf[3] = {'f', 'o', 'o'};
kj::ArrayPtr<char> a = buf;
kj::ArrayPtr<const char> ca = a;
EXPECT_EQ("foo", str(a));
EXPECT_EQ("foo", str(ca));
EXPECT_EQ("foo", str(mv(a)));
EXPECT_EQ("foo", str(mv(ca)));
} }
TEST(String, StartsEndsWith) { TEST(String, StartsEndsWith) {
......
...@@ -260,6 +260,7 @@ struct Stringifier { ...@@ -260,6 +260,7 @@ struct Stringifier {
// anything. // anything.
inline ArrayPtr<const char> operator*(ArrayPtr<const char> s) const { return s; } inline ArrayPtr<const char> operator*(ArrayPtr<const char> s) const { return s; }
inline ArrayPtr<const char> operator*(ArrayPtr<char> s) const { return s; }
inline ArrayPtr<const char> operator*(const Array<const char>& s) const { return s; } inline ArrayPtr<const char> operator*(const Array<const char>& s) const { return s; }
inline ArrayPtr<const char> operator*(const Array<char>& s) const { return s; } inline ArrayPtr<const char> operator*(const Array<char>& s) const { return s; }
template<size_t n> template<size_t n>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment