|
1 | 1 | /*
|
2 |
| - * Copyright 2013, 2014 Pascal Christoph, hbz |
| 2 | + * Copyright 2013, 2020 Pascal Christoph, hbz and others |
3 | 3 | * Licensed under the Apache License, Version 2.0 the "License";
|
4 | 4 | * you may not use this file except in compliance with the License.
|
5 | 5 | * You may obtain a copy of the License at
|
|
21 | 21 | /**
|
22 | 22 | * tests {@link SimpleRegexTrie}
|
23 | 23 | *
|
24 |
| - * @author Pascal Christoph |
| 24 | + * @author Pascal Christoph, Fabian Steeg |
25 | 25 | *
|
26 | 26 | */
|
27 | 27 | public final class SimpleRegexTrieTest {
|
28 |
| - private static final String SCC = "aacbb|a[ab]bb"; |
| 28 | + |
29 | 29 | private static final String AACBB = "aacbb";
|
| 30 | + private static final String ABCBB = "abcbb"; |
30 | 31 |
|
31 | 32 | @Test
|
32 | 33 | public void testWithSimpleCharacterClass() {
|
33 | 34 | final SimpleRegexTrie<String> trie = new SimpleRegexTrie<String>();
|
34 |
| - trie.put(SCC, SCC); |
35 |
| - assertTrue(AACBB, trie.get(AACBB).size() == 1); |
| 35 | + trie.put("a[ab]cbb", "value"); |
| 36 | + assertTrue("Expecting to find: " + AACBB, trie.get(AACBB).size() == 1); |
| 37 | + assertTrue("Expecting to find: " + ABCBB, trie.get(ABCBB).size() == 1); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void testWithEmptyCharacterClass() { |
| 42 | + final SimpleRegexTrie<String> trie = new SimpleRegexTrie<String>(); |
| 43 | + // Should not be treated as character class (used for JSON arrays): |
| 44 | + trie.put("a[].1", "value"); |
| 45 | + assertTrue("Expecting to find: a[].1", trie.get("a[].1").size() == 1); |
36 | 46 | }
|
37 | 47 | }
|
0 commit comments