Flutter Engine
ascii_trie_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 
5 #include "flutter/fml/ascii_trie.h"
6 
7 #include "gtest/gtest.h"
8 
9 using fml::AsciiTrie;
10 
11 TEST(AsciiTableTest, Simple) {
12  AsciiTrie trie;
13  auto entries = std::vector<std::string>{"foo"};
14  trie.Fill(entries);
15  ASSERT_TRUE(trie.Query("foobar"));
16  ASSERT_FALSE(trie.Query("google"));
17 }
18 
19 TEST(AsciiTableTest, ExactMatch) {
20  AsciiTrie trie;
21  auto entries = std::vector<std::string>{"foo"};
22  trie.Fill(entries);
23  ASSERT_TRUE(trie.Query("foo"));
24 }
25 
26 TEST(AsciiTableTest, Empty) {
27  AsciiTrie trie;
28  ASSERT_TRUE(trie.Query("foo"));
29 }
30 
31 TEST(AsciiTableTest, MultipleEntries) {
32  AsciiTrie trie;
33  auto entries = std::vector<std::string>{"foo", "bar"};
34  trie.Fill(entries);
35  ASSERT_TRUE(trie.Query("foozzz"));
36  ASSERT_TRUE(trie.Query("barzzz"));
37 }
TEST(AsciiTableTest, Simple)
bool Query(const char *argument)
Returns true if argument is prefixed by the contents of the trie.
Definition: ascii_trie.h:26
void Fill(const std::vector< std::string > &entries)
Clear and insert all the entries into the trie.
Definition: ascii_trie.cc:34
A trie for looking for ASCII prefixes.
Definition: ascii_trie.h:15