Adds tests for SkipPrefix().
This commit is contained in:
parent
38e1465902
commit
985a30360c
@ -607,7 +607,7 @@ GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
|
||||
// If *pstr starts with the given prefix, modifies *pstr to be right
|
||||
// past the prefix and returns true; otherwise leaves *pstr unchanged
|
||||
// and returns false. None of pstr, *pstr, and prefix can be NULL.
|
||||
bool SkipPrefix(const char* prefix, const char** pstr);
|
||||
GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
|
||||
|
||||
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
|
||||
|
||||
|
@ -178,6 +178,7 @@ using testing::internal::ShouldShard;
|
||||
using testing::internal::ShouldUseColor;
|
||||
using testing::internal::Shuffle;
|
||||
using testing::internal::ShuffleRange;
|
||||
using testing::internal::SkipPrefix;
|
||||
using testing::internal::StreamableToString;
|
||||
using testing::internal::String;
|
||||
using testing::internal::TestEventListenersAccessor;
|
||||
@ -7075,3 +7076,29 @@ TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
|
||||
ASSERT_EQ(2U, na.size());
|
||||
EXPECT_EQ(a, na.begin());
|
||||
}
|
||||
|
||||
// Tests SkipPrefix().
|
||||
|
||||
TEST(SkipPrefixTest, SkipsWhenPrefixMatches) {
|
||||
const char* const str = "hello";
|
||||
|
||||
const char* p = str;
|
||||
EXPECT_TRUE(SkipPrefix("", &p));
|
||||
EXPECT_EQ(str, p);
|
||||
|
||||
p = str;
|
||||
EXPECT_TRUE(SkipPrefix("hell", &p));
|
||||
EXPECT_EQ(str + 4, p);
|
||||
}
|
||||
|
||||
TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
|
||||
const char* const str = "world";
|
||||
|
||||
const char* p = str;
|
||||
EXPECT_FALSE(SkipPrefix("W", &p));
|
||||
EXPECT_EQ(str, p);
|
||||
|
||||
p = str;
|
||||
EXPECT_FALSE(SkipPrefix("world!", &p));
|
||||
EXPECT_EQ(str, p);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user