Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / renderer / spellchecker / custom_dictionary_engine_unittest.cc
blob2e9f61e9cc36dad9918b323fe9d33581b83959f0
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/renderer/spellchecker/custom_dictionary_engine.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 TEST(CustomDictionaryTest, HandlesEmptyWordWithInvalidSubstring) {
10 CustomDictionaryEngine engine;
11 std::set<std::string> custom_words;
12 engine.Init(custom_words);
13 EXPECT_FALSE(engine.SpellCheckWord(base::string16().c_str(), 15, 23));
16 TEST(CustomDictionaryTest, Basic) {
17 CustomDictionaryEngine engine;
18 EXPECT_FALSE(engine.SpellCheckWord(base::ASCIIToUTF16("helllo").c_str(),
19 0, 6));
20 std::set<std::string> custom_words;
21 custom_words.insert("helllo");
22 engine.Init(custom_words);
23 EXPECT_TRUE(engine.SpellCheckWord(base::ASCIIToUTF16("helllo").c_str(),
24 0, 6));
27 TEST(CustomDictionaryTest, HandlesNullCharacters) {
28 base::char16 data[4] = {'a', 0, 'b', 'c'};
29 EXPECT_FALSE(CustomDictionaryEngine().SpellCheckWord(data, 1, 1));