| 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/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 128 SplitString(WideToUTF16(kTestCases[i].expected_words), ' ', | 128 base::SplitString( |
| 129 &expected_words); | 129 WideToUTF16(kTestCases[i].expected_words), ' ', &expected_words); |
| 130 | 130 |
| 131 string16 actual_word; | 131 string16 actual_word; |
| 132 int actual_start, actual_end; | 132 int actual_start, actual_end; |
| 133 size_t index = 0; | 133 size_t index = 0; |
| 134 while (iterator.GetNextWord(&actual_word, &actual_start, &actual_end)) { | 134 while (iterator.GetNextWord(&actual_word, &actual_start, &actual_end)) { |
| 135 EXPECT_TRUE(index < expected_words.size()); | 135 EXPECT_TRUE(index < expected_words.size()); |
| 136 if (index < expected_words.size()) | 136 if (index < expected_words.size()) |
| 137 EXPECT_EQ(expected_words[index], actual_word); | 137 EXPECT_EQ(expected_words[index], actual_word); |
| 138 ++index; | 138 ++index; |
| 139 } | 139 } |
| (...skipping 16 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 |