diff --git a/test/util-test.cc b/test/util-test.cc index 8b8a20a1..59dfddff 100644 --- a/test/util-test.cc +++ b/test/util-test.cc @@ -699,8 +699,11 @@ void test_count_digits() { } TEST(UtilTest, StringRef) { - char space[100] = "some string"; - EXPECT_EQ(std::strlen(space), StringRef(space).size()); + // Test that StringRef::size() returns string length, not buffer size. + enum {BUFFER_SIZE = 100}; + char str[BUFFER_SIZE] = "some string"; + EXPECT_EQ(std::strlen(str), StringRef(str).size()); + EXPECT_LT(std::strlen(str), BUFFER_SIZE); } TEST(UtilTest, CountDigits) {