Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
985a3036
Commit
985a3036
authored
Jun 08, 2010
by
zhanyong.wan
Browse files
Adds tests for SkipPrefix().
parent
38e14659
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
include/gtest/internal/gtest-internal.h
include/gtest/internal/gtest-internal.h
+1
-1
test/gtest_unittest.cc
test/gtest_unittest.cc
+27
-0
No files found.
include/gtest/internal/gtest-internal.h
View file @
985a3036
...
...
@@ -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
...
...
test/gtest_unittest.cc
View file @
985a3036
...
...
@@ -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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment