| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 RefPtr<const StringImpl> constRef = testStringImpl->isolatedCopy(); | 93 RefPtr<const StringImpl> constRef = testStringImpl->isolatedCopy(); |
| 94 DCHECK(constRef->hasOneRef()); | 94 DCHECK(constRef->hasOneRef()); |
| 95 EXPECT_TRUE(equal( | 95 EXPECT_TRUE(equal( |
| 96 StringImpl::create(testWithNonASCII, 2).get(), | 96 StringImpl::create(testWithNonASCII, 2).get(), |
| 97 StringImpl::create(testWithNonASCIICapitalized, 2)->lowerASCII().get())); | 97 StringImpl::create(testWithNonASCIICapitalized, 2)->lowerASCII().get())); |
| 98 EXPECT_FALSE(equal( | 98 EXPECT_FALSE(equal( |
| 99 StringImpl::create(testWithNonASCII, 2).get(), | 99 StringImpl::create(testWithNonASCII, 2).get(), |
| 100 StringImpl::create(testWithNonASCIIComparison, 2)->lowerASCII().get())); | 100 StringImpl::create(testWithNonASCIIComparison, 2)->lowerASCII().get())); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST(StringImplTest, UpperASCII) { |
| 104 RefPtr<StringImpl> testStringImpl = StringImpl::create("LINK"); |
| 105 EXPECT_TRUE(testStringImpl->is8Bit()); |
| 106 EXPECT_TRUE(StringImpl::create("a\xE1")->is8Bit()); |
| 107 |
| 108 EXPECT_TRUE(equal(testStringImpl.get(), |
| 109 StringImpl::create("link")->upperASCII().get())); |
| 110 EXPECT_TRUE(equal(testStringImpl.get(), |
| 111 StringImpl::create("LINK")->upperASCII().get())); |
| 112 EXPECT_TRUE(equal(testStringImpl.get(), |
| 113 StringImpl::create("lInk")->upperASCII().get())); |
| 114 |
| 115 EXPECT_TRUE(equal(StringImpl::create("LINK")->upper().get(), |
| 116 StringImpl::create("LINK")->upperASCII().get())); |
| 117 EXPECT_TRUE(equal(StringImpl::create("lInk")->upper().get(), |
| 118 StringImpl::create("lInk")->upperASCII().get())); |
| 119 |
| 120 EXPECT_TRUE(equal(StringImpl::create("A\xE1").get(), |
| 121 StringImpl::create("a\xE1")->upperASCII().get())); |
| 122 EXPECT_TRUE(equal(StringImpl::create("A\xC1").get(), |
| 123 StringImpl::create("a\xC1")->upperASCII().get())); |
| 124 |
| 125 EXPECT_FALSE(equal(StringImpl::create("A\xE1").get(), |
| 126 StringImpl::create("a\xC1")->upperASCII().get())); |
| 127 EXPECT_FALSE(equal(StringImpl::create("A\xE1").get(), |
| 128 StringImpl::create("A\xC1")->upperASCII().get())); |
| 129 |
| 130 static const UChar test[5] = {0x006c, 0x0069, 0x006e, 0x006b, 0}; // link |
| 131 static const UChar testCapitalized[5] = {0x004c, 0x0049, 0x004e, 0x004b, |
| 132 0}; // LINK |
| 133 |
| 134 RefPtr<StringImpl> testStringImpl16 = StringImpl::create(testCapitalized, 4); |
| 135 EXPECT_FALSE(testStringImpl16->is8Bit()); |
| 136 |
| 137 EXPECT_TRUE(equal(testStringImpl16.get(), |
| 138 StringImpl::create(test, 4)->upperASCII().get())); |
| 139 EXPECT_TRUE( |
| 140 equal(testStringImpl16.get(), |
| 141 StringImpl::create(testCapitalized, 4)->upperASCII().get())); |
| 142 |
| 143 static const UChar testWithNonASCII[3] = {0x0061, 0x00e1, 0}; // a\xE1 |
| 144 static const UChar testWithNonASCIIComparison[3] = {0x0061, 0x00c1, |
| 145 0}; // a\xC1 |
| 146 static const UChar testWithNonASCIICapitalized[3] = {0x0041, 0x00e1, |
| 147 0}; // A\xE1 |
| 148 |
| 149 // Make sure we support RefPtr<const StringImpl>. |
| 150 RefPtr<const StringImpl> constRef = testStringImpl->isolatedCopy(); |
| 151 DCHECK(constRef->hasOneRef()); |
| 152 EXPECT_TRUE( |
| 153 equal(StringImpl::create(testWithNonASCIICapitalized, 2).get(), |
| 154 StringImpl::create(testWithNonASCII, 2)->upperASCII().get())); |
| 155 EXPECT_FALSE(equal( |
| 156 StringImpl::create(testWithNonASCIICapitalized, 2).get(), |
| 157 StringImpl::create(testWithNonASCIIComparison, 2)->upperASCII().get())); |
| 158 } |
| 159 |
| 103 } // namespace WTF | 160 } // namespace WTF |
| OLD | NEW |