• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ljacqu / wordeval / 14552398690

19 Apr 2025 07:59PM UTC coverage: 52.924% (+2.3%) from 50.591%
14552398690

push

github

ljacqu
Write sanitizer tests that don't require the dictionary file

268 of 576 branches covered (46.53%)

1 of 2 new or added lines in 1 file covered. (50.0%)

36 existing lines in 9 files now uncovered.

724 of 1368 relevant lines covered (52.92%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.5
/src/main/java/ch/jalu/wordeval/appdata/DictionarySettingsStore.java
1
package ch.jalu.wordeval.appdata;
2

3
import ch.jalu.wordeval.dictionary.Dictionary;
4
import ch.jalu.wordeval.dictionary.sanitizer.FrSanitizer;
5
import ch.jalu.wordeval.dictionary.sanitizer.HuSanitizer;
6
import ch.jalu.wordeval.dictionary.sanitizer.ItSanitizer;
7
import ch.jalu.wordeval.language.Language;
8

9
/**
10
 * Stores {@link Dictionary} objects.
11
 */
12
class DictionarySettingsStore extends ObjectStore<String, Dictionary> {
13

14
  private static final String DICT_PATH = "dict/";
15

16
  private final LanguageStore languageStore;
17

18
  DictionarySettingsStore(LanguageStore languageStore) {
2✔
19
    this.languageStore = languageStore;
3✔
20
    addAll(buildEntries());
4✔
21
  }
1✔
22

23
  private Dictionary[] buildEntries() {
24
    return new Dictionary[] {
7✔
25
      newDictionary("af").delimiters('/').skipSequences(".", "µ", "Ð", "ø").build(),
33✔
26
      newDictionary("bg").delimiters('/').build(),
14✔
27
      newDictionary("da").delimiters('/').build(),
14✔
28
      newDictionary("de-de").delimiters('/', '#').build(),
18✔
29
      newDictionary("en-us").delimiters('/').build(),
14✔
30
      newDictionary("en-test").delimiters('/').build(),
14✔
31
      // TODO #62: Some Basque entries have _ but most parts seem to be present alone
32
      newDictionary("es").delimiters('/').build(),
14✔
33
      newDictionary("eu").delimiters('/').skipSequences(".", "+", "_").build(),
29✔
34
      newDictionary("fr").sanitizerCreator(FrSanitizer::new)
13✔
35
          .delimiters('/', '\t')
75✔
36
          .skipSequences(".", "&", "µ", "₂", "₃", "₄", "₅","₆","₇","₈","₉","ᵈ","ᵉ","ᵍ","ˡ","ᵐ","ʳ","ˢ")
1✔
37
          .build(),
6✔
38
      newDictionary("hu").sanitizerCreator(HuSanitizer::new).delimiters('/', '\t').skipSequences(".", "+", "±", "ø", "ʻ", "’", "­").build(),
51✔
39
      newDictionary("it").sanitizerCreator(ItSanitizer::new).delimiters('/').build(),
16✔
40
      newDictionary("nb").delimiters('/').build(),
14✔
41
      // TODO: The nl dictionary uses the digraph symbol 'ij' instead of 'i'+'j'
42
      newDictionary("nl").delimiters('/').build(),
14✔
43
      newDictionary("nn").delimiters('/').build(),
14✔
44
      newDictionary("pl").delimiters('/').build(),
14✔
45
      newDictionary("pt-br").delimiters('/').build(),
14✔
46
      newDictionary("pt-pt").delimiters('/', '[').build(),
18✔
47
      newDictionary("ru").delimiters('/').skipSequences(".").build(),
21✔
48
      newDictionary("sr-cyrl").build(),
7✔
49
      newDictionary("sr-latn").delimiters('/').build(),
14✔
50
      newDictionary("tr").delimiters(' ').build()
10✔
51
    };
52
  }
53

54
  @Override
55
  protected String getKey(Dictionary settings) {
56
    return settings.getIdentifier();
3✔
57
  }
58

59
  private Dictionary.Builder newDictionary(String identifier) {
60
    return Dictionary.builder()
3✔
61
        .identifier(identifier)
3✔
62
        .file(DICT_PATH + identifier + ".dic")
3✔
63
        .language(getLanguage(identifier));
2✔
64
  }
65

66
  private Language getLanguage(String identifier) {
67
    Language language = languageStore.getLanguageOrNull(identifier);
5✔
68
    if (language == null) {
2✔
69
      if (identifier.indexOf('-') != -1) {
5!
70
        return getLanguage(identifier.substring(0, identifier.indexOf('-')));
9✔
71
      }
UNCOV
72
      throw new IllegalStateException("No language stored for code '" + identifier + "'");
×
73
    }
74
    return languageStore.get(identifier);
6✔
75
  }
76

77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc