OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "../../../testing/fx_string_testhelpers.h" | 6 #include "../../../testing/fx_string_testhelpers.h" |
7 #include "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
8 | 8 |
9 TEST(fxcrt, WideStringOperatorSubscript) { | 9 TEST(fxcrt, WideStringOperatorSubscript) { |
10 // CFX_WideString includes the NUL terminator for non-empty strings. | 10 // CFX_WideString includes the NUL terminator for non-empty strings. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 { L"\xaabb\xccdd", ByteStringLiteral("\xbb\xaa\xdd\xcc\0\0") }, | 59 { L"\xaabb\xccdd", ByteStringLiteral("\xbb\xaa\xdd\xcc\0\0") }, |
60 { L"\x3132\x6162", ByteStringLiteral("\x32\x31\x62\x61\0\0") }, | 60 { L"\x3132\x6162", ByteStringLiteral("\x32\x31\x62\x61\0\0") }, |
61 }; | 61 }; |
62 | 62 |
63 for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) { | 63 for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) { |
64 EXPECT_EQ(utf16le_encode_cases[i].bs, | 64 EXPECT_EQ(utf16le_encode_cases[i].bs, |
65 utf16le_encode_cases[i].ws.UTF16LE_Encode()) | 65 utf16le_encode_cases[i].ws.UTF16LE_Encode()) |
66 << " for case number " << i; | 66 << " for case number " << i; |
67 } | 67 } |
68 } | 68 } |
| 69 |
| 70 TEST(fxcrt, WideStringCOperatorSubscript) { |
| 71 // CFX_WideStringC includes the NUL terminator for non-empty strings. |
| 72 CFX_WideStringC abc(L"abc"); |
| 73 EXPECT_EQ(L'a', abc[0]); |
| 74 EXPECT_EQ(L'b', abc[1]); |
| 75 EXPECT_EQ(L'c', abc[2]); |
| 76 EXPECT_EQ(L'\0', abc[3]); |
| 77 } |
| 78 |
| 79 TEST(fxcrt, WideStringCOperatorLT) { |
| 80 CFX_WideStringC empty; |
| 81 CFX_WideStringC a(L"a"); |
| 82 CFX_WideStringC abc(L"\x0110qq"); // Comes before despite endianness. |
| 83 CFX_WideStringC def(L"\x1001qq"); // Comes after despite endianness. |
| 84 |
| 85 EXPECT_FALSE(empty < empty); |
| 86 EXPECT_FALSE(a < a); |
| 87 EXPECT_FALSE(abc < abc); |
| 88 EXPECT_FALSE(def < def); |
| 89 |
| 90 EXPECT_TRUE(empty < a); |
| 91 EXPECT_FALSE(a < empty); |
| 92 |
| 93 EXPECT_TRUE(empty < abc); |
| 94 EXPECT_FALSE(abc < empty); |
| 95 |
| 96 EXPECT_TRUE(empty < def); |
| 97 EXPECT_FALSE(def < empty); |
| 98 |
| 99 EXPECT_TRUE(a < abc); |
| 100 EXPECT_FALSE(abc < a); |
| 101 |
| 102 EXPECT_TRUE(a < def); |
| 103 EXPECT_FALSE(def < a); |
| 104 |
| 105 EXPECT_TRUE(abc < def); |
| 106 EXPECT_FALSE(def < abc); |
| 107 } |
| 108 |
OLD | NEW |