OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/string_piece.h" | 7 #include "base/string_piece.h" |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
| 11 using namespace base; |
| 12 |
11 TEST(StringPieceTest, CheckComparisonOperators) { | 13 TEST(StringPieceTest, CheckComparisonOperators) { |
12 #define CMP_Y(op, x, y) \ | 14 #define CMP_Y(op, x, y) \ |
13 ASSERT_TRUE( (StringPiece((x)) op StringPiece((y)))); \ | 15 ASSERT_TRUE( (StringPiece((x)) op StringPiece((y)))); \ |
14 ASSERT_TRUE( (StringPiece((x)).compare(StringPiece((y))) op 0)) | 16 ASSERT_TRUE( (StringPiece((x)).compare(StringPiece((y))) op 0)) |
15 | 17 |
16 #define CMP_N(op, x, y) \ | 18 #define CMP_N(op, x, y) \ |
17 ASSERT_FALSE(StringPiece((x)) op StringPiece((y))); \ | 19 ASSERT_FALSE(StringPiece((x)) op StringPiece((y))); \ |
18 ASSERT_FALSE(StringPiece((x)).compare(StringPiece((y))) op 0) | 20 ASSERT_FALSE(StringPiece((x)).compare(StringPiece((y))) op 0) |
19 | 21 |
20 CMP_Y(==, "", ""); | 22 CMP_Y(==, "", ""); |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 533 |
532 TEST(StringPieceTest, StringCompareNotAmbiguous) { | 534 TEST(StringPieceTest, StringCompareNotAmbiguous) { |
533 ASSERT_TRUE("hello" == std::string("hello")); | 535 ASSERT_TRUE("hello" == std::string("hello")); |
534 ASSERT_TRUE("hello" < std::string("world")); | 536 ASSERT_TRUE("hello" < std::string("world")); |
535 } | 537 } |
536 | 538 |
537 TEST(StringPieceTest, HeterogenousStringPieceEquals) { | 539 TEST(StringPieceTest, HeterogenousStringPieceEquals) { |
538 ASSERT_TRUE(StringPiece("hello") == std::string("hello")); | 540 ASSERT_TRUE(StringPiece("hello") == std::string("hello")); |
539 ASSERT_TRUE("hello" == StringPiece("hello")); | 541 ASSERT_TRUE("hello" == StringPiece("hello")); |
540 } | 542 } |
OLD | NEW |