Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/SmallCapsIteratorTest.cpp

Issue 2668903003: Replace WTF::emptyString{16Bit}() with a static global (Closed)
Patch Set: Replace WTF::emptyString{16Bit}() with a static global Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/fonts/SmallCapsIterator.h" 5 #include "platform/fonts/SmallCapsIterator.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include <string> 8 #include <string>
9 9
10 namespace blink { 10 namespace blink {
11 11
12 struct TestRun { 12 struct TestRun {
13 std::string text; 13 std::string text;
14 SmallCapsIterator::SmallCapsBehavior code; 14 SmallCapsIterator::SmallCapsBehavior code;
15 }; 15 };
16 16
17 struct ExpectedRun { 17 struct ExpectedRun {
18 unsigned limit; 18 unsigned limit;
19 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior; 19 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior;
20 20
21 ExpectedRun(unsigned theLimit, 21 ExpectedRun(unsigned theLimit,
22 SmallCapsIterator::SmallCapsBehavior theSmallCapsBehavior) 22 SmallCapsIterator::SmallCapsBehavior theSmallCapsBehavior)
23 : limit(theLimit), smallCapsBehavior(theSmallCapsBehavior) {} 23 : limit(theLimit), smallCapsBehavior(theSmallCapsBehavior) {}
24 }; 24 };
25 25
26 class SmallCapsIteratorTest : public testing::Test { 26 class SmallCapsIteratorTest : public testing::Test {
27 protected: 27 protected:
28 void CheckRuns(const Vector<TestRun>& runs) { 28 void CheckRuns(const Vector<TestRun>& runs) {
29 String text(emptyString16Bit()); 29 String text(emptyString16Bit);
30 Vector<ExpectedRun> expect; 30 Vector<ExpectedRun> expect;
31 for (auto& run : runs) { 31 for (auto& run : runs) {
32 text.append(String::fromUTF8(run.text.c_str())); 32 text.append(String::fromUTF8(run.text.c_str()));
33 expect.push_back(ExpectedRun(text.length(), run.code)); 33 expect.push_back(ExpectedRun(text.length(), run.code));
34 } 34 }
35 SmallCapsIterator smallCapsIterator(text.characters16(), text.length()); 35 SmallCapsIterator smallCapsIterator(text.characters16(), text.length());
36 VerifyRuns(&smallCapsIterator, expect); 36 VerifyRuns(&smallCapsIterator, expect);
37 } 37 }
38 38
39 void VerifyRuns(SmallCapsIterator* smallCapsIterator, 39 void VerifyRuns(SmallCapsIterator* smallCapsIterator,
(...skipping 15 matching lines...) Expand all
55 #define DECLARE_RUNSVECTOR(...) \ 55 #define DECLARE_RUNSVECTOR(...) \
56 static const TestRun runsArray[] = __VA_ARGS__; \ 56 static const TestRun runsArray[] = __VA_ARGS__; \
57 Vector<TestRun> runs; \ 57 Vector<TestRun> runs; \
58 runs.append(runsArray, sizeof(runsArray) / sizeof(*runsArray)); 58 runs.append(runsArray, sizeof(runsArray) / sizeof(*runsArray));
59 59
60 #define CHECK_RUNS(...) \ 60 #define CHECK_RUNS(...) \
61 DECLARE_RUNSVECTOR(__VA_ARGS__); \ 61 DECLARE_RUNSVECTOR(__VA_ARGS__); \
62 CheckRuns(runs); 62 CheckRuns(runs);
63 63
64 TEST_F(SmallCapsIteratorTest, Empty) { 64 TEST_F(SmallCapsIteratorTest, Empty) {
65 String empty(emptyString16Bit()); 65 String empty(emptyString16Bit);
66 SmallCapsIterator smallCapsIterator(empty.characters16(), empty.length()); 66 SmallCapsIterator smallCapsIterator(empty.characters16(), empty.length());
67 unsigned limit = 0; 67 unsigned limit = 0;
68 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior = 68 SmallCapsIterator::SmallCapsBehavior smallCapsBehavior =
69 SmallCapsIterator::SmallCapsInvalid; 69 SmallCapsIterator::SmallCapsInvalid;
70 ASSERT(!smallCapsIterator.consume(&limit, &smallCapsBehavior)); 70 ASSERT(!smallCapsIterator.consume(&limit, &smallCapsBehavior));
71 ASSERT_EQ(limit, 0u); 71 ASSERT_EQ(limit, 0u);
72 ASSERT_EQ(smallCapsBehavior, SmallCapsIterator::SmallCapsInvalid); 72 ASSERT_EQ(smallCapsBehavior, SmallCapsIterator::SmallCapsInvalid);
73 } 73 }
74 74
75 TEST_F(SmallCapsIteratorTest, UppercaseA) { 75 TEST_F(SmallCapsIteratorTest, UppercaseA) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 TEST_F(SmallCapsIteratorTest, Armenian) { 107 TEST_F(SmallCapsIteratorTest, Armenian) {
108 CHECK_RUNS({{"աբգդ", SmallCapsIterator::SmallCapsUppercaseNeeded}, 108 CHECK_RUNS({{"աբգդ", SmallCapsIterator::SmallCapsUppercaseNeeded},
109 {"ԵԶԷԸ", SmallCapsIterator::SmallCapsSameCase}}); 109 {"ԵԶԷԸ", SmallCapsIterator::SmallCapsSameCase}});
110 } 110 }
111 111
112 TEST_F(SmallCapsIteratorTest, CombiningCharacterSequence) { 112 TEST_F(SmallCapsIteratorTest, CombiningCharacterSequence) {
113 CHECK_RUNS({{"èü", SmallCapsIterator::SmallCapsUppercaseNeeded}}); 113 CHECK_RUNS({{"èü", SmallCapsIterator::SmallCapsUppercaseNeeded}});
114 } 114 }
115 115
116 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698