diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2012-06-07 20:34:34 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2012-06-07 20:34:34 +0000 |
commit | a88c9a88e49e90ec414175543b2b7ff2f70866a7 (patch) | |
tree | 617807532cbbd68ce8e684a570791231b1b9cd92 /test/gtest-port_test.cc | |
parent | a3b859162dd7a4a1798cf8753a03098f2cbdb62e (diff) | |
download | googletest-a88c9a88e49e90ec414175543b2b7ff2f70866a7.tar.gz googletest-a88c9a88e49e90ec414175543b2b7ff2f70866a7.tar.bz2 googletest-a88c9a88e49e90ec414175543b2b7ff2f70866a7.zip |
Improves gtest's failure messages. In particulars, char pointers and
char arrays are not escapped properly.
Diffstat (limited to 'test/gtest-port_test.cc')
-rw-r--r-- | test/gtest-port_test.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/gtest-port_test.cc b/test/gtest-port_test.cc index 75471c39..dfbf029f 100644 --- a/test/gtest-port_test.cc +++ b/test/gtest-port_test.cc @@ -61,6 +61,43 @@ using std::pair; namespace testing { namespace internal { +TEST(IsXDigitTest, WorksForNarrowAscii) { + EXPECT_TRUE(IsXDigit('0')); + EXPECT_TRUE(IsXDigit('9')); + EXPECT_TRUE(IsXDigit('A')); + EXPECT_TRUE(IsXDigit('F')); + EXPECT_TRUE(IsXDigit('a')); + EXPECT_TRUE(IsXDigit('f')); + + EXPECT_FALSE(IsXDigit('-')); + EXPECT_FALSE(IsXDigit('g')); + EXPECT_FALSE(IsXDigit('G')); +} + +TEST(IsXDigitTest, ReturnsFalseForNarrowNonAscii) { + EXPECT_FALSE(IsXDigit(static_cast<char>(0x80))); + EXPECT_FALSE(IsXDigit(static_cast<char>('0' | 0x80))); +} + +TEST(IsXDigitTest, WorksForWideAscii) { + EXPECT_TRUE(IsXDigit(L'0')); + EXPECT_TRUE(IsXDigit(L'9')); + EXPECT_TRUE(IsXDigit(L'A')); + EXPECT_TRUE(IsXDigit(L'F')); + EXPECT_TRUE(IsXDigit(L'a')); + EXPECT_TRUE(IsXDigit(L'f')); + + EXPECT_FALSE(IsXDigit(L'-')); + EXPECT_FALSE(IsXDigit(L'g')); + EXPECT_FALSE(IsXDigit(L'G')); +} + +TEST(IsXDigitTest, ReturnsFalseForWideNonAscii) { + EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(0x80))); + EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(L'0' | 0x80))); + EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(L'0' | 0x100))); +} + class Base { public: // Copy constructor and assignment operator do exactly what we need, so we |