| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.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 base::string16 input(base::WideToUTF16(kTestText)); | 122 base::string16 input(base::WideToUTF16(kTestText)); |
| 123 SpellcheckWordIterator iterator; | 123 SpellcheckWordIterator iterator; |
| 124 EXPECT_TRUE(iterator.Initialize(&attributes, | 124 EXPECT_TRUE(iterator.Initialize(&attributes, |
| 125 kTestCases[i].allow_contraction)); | 125 kTestCases[i].allow_contraction)); |
| 126 EXPECT_TRUE(iterator.SetText(input.c_str(), input.length())); | 126 EXPECT_TRUE(iterator.SetText(input.c_str(), input.length())); |
| 127 | 127 |
| 128 std::vector<base::string16> expected_words; | 128 std::vector<base::string16> expected_words = base::SplitString( |
| 129 base::SplitString( | 129 base::WideToUTF16(kTestCases[i].expected_words), |
| 130 base::WideToUTF16(kTestCases[i].expected_words), ' ', &expected_words); | 130 base::string16(1, ' '), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 131 | 131 |
| 132 base::string16 actual_word; | 132 base::string16 actual_word; |
| 133 int actual_start, actual_end; | 133 int actual_start, actual_end; |
| 134 size_t index = 0; | 134 size_t index = 0; |
| 135 while (iterator.GetNextWord(&actual_word, &actual_start, &actual_end)) { | 135 while (iterator.GetNextWord(&actual_word, &actual_start, &actual_end)) { |
| 136 EXPECT_TRUE(index < expected_words.size()); | 136 EXPECT_TRUE(index < expected_words.size()); |
| 137 if (index < expected_words.size()) | 137 if (index < expected_words.size()) |
| 138 EXPECT_EQ(expected_words[index], actual_word); | 138 EXPECT_EQ(expected_words[index], actual_word); |
| 139 ++index; | 139 ++index; |
| 140 } | 140 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 // Test initialization fails when no default language is set. | 290 // Test initialization fails when no default language is set. |
| 291 { | 291 { |
| 292 SpellcheckCharAttribute attributes; | 292 SpellcheckCharAttribute attributes; |
| 293 | 293 |
| 294 SpellcheckWordIterator iterator; | 294 SpellcheckWordIterator iterator; |
| 295 EXPECT_FALSE(iterator.Initialize(&attributes, true)); | 295 EXPECT_FALSE(iterator.Initialize(&attributes, true)); |
| 296 } | 296 } |
| 297 } | 297 } |
| OLD | NEW |