From 5b0a9bbe852c6912f83f1924c095346fed8dc3ef Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 17 Feb 2015 06:45:45 -0800 Subject: [PATCH] Improve StringRef test --- test/util-test.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) {