Browse files

do not compare raw pointers

If you compare string literals, their addresses are compared.  This
can fail if the compiler decides not to share .data space between string
literals with the same values.
  • Loading branch information...
1 parent 6f6f992 commit 0adc5d1cf80419559aabb974474d5edb62d6c357 @milkie milkie committed Jul 16, 2012
Showing with 0 additions and 4 deletions.
  1. +0 −4 src/mongo/unittest/unittest_test.cpp
@@ -45,19 +45,15 @@ namespace {
TEST(UnitTestSelfTest, TestStringComparisons) {
- ASSERT_EQUALS("hello", "hello");
ASSERT_EQUALS(std::string("hello"), "hello");
ASSERT_EQUALS("hello", std::string("hello"));
- ASSERT_NOT_EQUALS("hello", "good bye!");
ASSERT_NOT_EQUALS(std::string("hello"), "good bye!");
ASSERT_NOT_EQUALS("hello", std::string("good bye!"));
ASSERT_TEST_FAILS(ASSERT_NOT_EQUALS(std::string("hello"), "hello"));
ASSERT_TEST_FAILS(ASSERT_NOT_EQUALS("hello", std::string("hello")));
- ASSERT_TEST_FAILS(ASSERT_EQUALS("hello", "good bye!"));
ASSERT_TEST_FAILS(ASSERT_EQUALS(std::string("hello"), "good bye!"));
ASSERT_TEST_FAILS(ASSERT_EQUALS("hello", std::string("good bye!")));

0 comments on commit 0adc5d1

Please sign in to comment.