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 | #include "gtest/gtest.h" |
7 | |
8 | using fml::AsciiTrie; |
9 | |
10 | TEST(AsciiTableTest, Simple) { |
11 | AsciiTrie trie; |
12 | auto entries = std::vector<std::string>{"foo"}; |
13 | trie.Fill(entries); |
14 | ASSERT_TRUE(trie.Query("foobar")); |
15 | ASSERT_FALSE(trie.Query("google")); |
16 | } |
17 | |
18 | TEST(AsciiTableTest, ExactMatch) { |
19 | AsciiTrie trie; |
20 | auto entries = std::vector<std::string>{"foo"}; |
21 | trie.Fill(entries); |
22 | ASSERT_TRUE(trie.Query("foo")); |
23 | } |
24 | |
25 | TEST(AsciiTableTest, Empty) { |
26 | AsciiTrie trie; |
27 | ASSERT_TRUE(trie.Query("foo")); |
28 | } |
29 | |
30 | TEST(AsciiTableTest, MultipleEntries) { |
31 | AsciiTrie trie; |
32 | auto entries = std::vector<std::string>{"foo", "bar"}; |
33 | trie.Fill(entries); |
34 | ASSERT_TRUE(trie.Query("foozzz")); |
35 | ASSERT_TRUE(trie.Query("barzzz")); |
36 | } |
37 |