OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/stringprintf.h" |
9 #include "base/string_split.h" | 10 #include "base/string_split.h" |
10 #include "base/string_util.h" | |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" | 12 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 struct TestCase { | 17 struct TestCase { |
18 const char* language; | 18 const char* language; |
19 bool allow_contraction; | 19 bool allow_contraction; |
20 const wchar_t* expected_words; | 20 const wchar_t* expected_words; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 L"\x0e23\x0e31\x0e1a" | 106 L"\x0e23\x0e31\x0e1a" |
107 }, { | 107 }, { |
108 // Korean | 108 // Korean |
109 "ko-KR", true, | 109 "ko-KR", true, |
110 L"\x110b\x1161\x11ab\x1102\x1167\x11bc\x1112\x1161" | 110 L"\x110b\x1161\x11ab\x1102\x1167\x11bc\x1112\x1161" |
111 L"\x1109\x1166\x110b\x116d" | 111 L"\x1109\x1166\x110b\x116d" |
112 }, | 112 }, |
113 }; | 113 }; |
114 | 114 |
115 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | 115 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
116 SCOPED_TRACE(StringPrintf("kTestCases[%" PRIuS "]: language=%s", i, | 116 SCOPED_TRACE(base::StringPrintf("kTestCases[%" PRIuS "]: language=%s", i, |
117 kTestCases[i].language)); | 117 kTestCases[i].language)); |
118 | 118 |
119 SpellcheckCharAttribute attributes; | 119 SpellcheckCharAttribute attributes; |
120 attributes.SetDefaultLanguage(kTestCases[i].language); | 120 attributes.SetDefaultLanguage(kTestCases[i].language); |
121 | 121 |
122 string16 input(WideToUTF16(kTestText)); | 122 string16 input(WideToUTF16(kTestText)); |
123 SpellcheckWordIterator iterator; | 123 SpellcheckWordIterator iterator; |
124 EXPECT_TRUE(iterator.Initialize(&attributes, input.c_str(), input.length(), | 124 EXPECT_TRUE(iterator.Initialize(&attributes, input.c_str(), input.length(), |
125 kTestCases[i].allow_contraction)); | 125 kTestCases[i].allow_contraction)); |
126 | 126 |
127 std::vector<string16> expected_words; | 127 std::vector<string16> expected_words; |
(...skipping 28 matching lines...) Expand all Loading... |
156 | 156 |
157 // When SpellcheckWordIterator uses an inconsistent ICU ruleset, the following | 157 // When SpellcheckWordIterator uses an inconsistent ICU ruleset, the following |
158 // iterator.GetNextWord() call gets stuck in an infinite loop. Therefore, this | 158 // iterator.GetNextWord() call gets stuck in an infinite loop. Therefore, this |
159 // test succeeds if this call returns without timeouts. | 159 // test succeeds if this call returns without timeouts. |
160 string16 actual_word; | 160 string16 actual_word; |
161 int actual_start, actual_end; | 161 int actual_start, actual_end; |
162 EXPECT_FALSE(iterator.GetNextWord(&actual_word, &actual_start, &actual_end)); | 162 EXPECT_FALSE(iterator.GetNextWord(&actual_word, &actual_start, &actual_end)); |
163 EXPECT_EQ(0, actual_start); | 163 EXPECT_EQ(0, actual_start); |
164 EXPECT_EQ(0, actual_end); | 164 EXPECT_EQ(0, actual_end); |
165 } | 165 } |
OLD | NEW |