custom_dictionary_engine_unittest.cc 1018 B

12345678910111213141516171819202122232425262728
  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.
  4. #include "base/strings/utf_string_conversions.h"
  5. #include "components/spellcheck/renderer/custom_dictionary_engine.h"
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. TEST(CustomDictionaryTest, HandlesEmptyWordWithInvalidSubstring) {
  8. CustomDictionaryEngine engine;
  9. std::set<std::string> custom_words;
  10. engine.Init(custom_words);
  11. EXPECT_FALSE(engine.SpellCheckWord(std::u16string(), 15, 23));
  12. }
  13. TEST(CustomDictionaryTest, Basic) {
  14. CustomDictionaryEngine engine;
  15. EXPECT_FALSE(engine.SpellCheckWord(u"helllo", 0, 6));
  16. std::set<std::string> custom_words;
  17. custom_words.insert("helllo");
  18. engine.Init(custom_words);
  19. EXPECT_TRUE(engine.SpellCheckWord(u"helllo", 0, 6));
  20. }
  21. TEST(CustomDictionaryTest, HandlesNullCharacters) {
  22. char16_t data[4] = {'a', 0, 'b', 'c'};
  23. EXPECT_FALSE(CustomDictionaryEngine().SpellCheckWord(data, 1, 1));
  24. }