Attempt to improve the multicharacter detection code.
This commit is contained in:
1 parent
6fc3416a1b
commit
3cf41e662c
12 files changed
+1135
-843
No files matched your search
@@ -28,13 +28,17 @@ func TestTextSubstitutionsAndBoundaries(t *testing.T) {
|
||||
{"#### ####", "4 number 4 number"},
|
||||
{"##### title #####", "5 number title 5 number"},
|
||||
{"////", "4 slash"},
|
||||
{"[#####]", " 5 number "},
|
||||
{"(#####)", " 5 number "},
|
||||
{"{#####}", " 5 number "},
|
||||
{"<#####>", " 5 number "},
|
||||
{"Oo", "WTF?"},
|
||||
} {
|
||||
if got := processor.Process_text(trial.text, "some", options); got != trial.want {
|
||||
t.Errorf("%q: %q, want %q", trial.text, got, trial.want)
|
||||
}
|
||||
}
|
||||
for _, text := range []string{"hello :)!", "path/to:)file", "https://example.invalid/:)", "https://example.invalid/:-/", "(o_O)", "###", "##--##", "a####b", "../....", "https://example.invalid/####", "10000", "aaaa", "🙂🙂🙂🙂", ""} {
|
||||
for _, text := range []string{"hello :)!", "path/to:)file", "https://example.invalid/:)", "https://example.invalid/:-/", "(o_O)", "###", "##--##", "a####b", "../....", "https://example.invalid/####", "10000", "aaaa", "🙂🙂🙂🙂", "", "[]", "[###]", "[####)", "[##--##]", "[a####b]", "[../....]", "[https://example.invalid/####]"} {
|
||||
for _, level := range Levels() {
|
||||
if got, want := processor.Process_text(text, level, options), processor.Text(text, level); got != want {
|
||||
t.Errorf("%q, %s changed ordinary processing: %q, want %q", text, level, got, want)
|
||||
@@ -101,6 +105,30 @@ func TestSubstitutionOptionsAndProfileNames(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBracketedRepeatedSymbolsRespectOptionsAndLevels(t *testing.T) {
|
||||
processor, _, err := Load([]string{"../../config/punctuation/default.toml"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, level := range Levels() {
|
||||
for _, options := range []TextOptions{
|
||||
{},
|
||||
{Emoticons: true},
|
||||
{RepeatedSymbols: true, RepeatedSymbolsMin: 1},
|
||||
{RepeatedSymbols: true, RepeatedSymbolsMin: 6},
|
||||
{RepeatedSymbols: true, RepeatedSymbolsMin: 4},
|
||||
} {
|
||||
want := processor.Text("[#####]", level)
|
||||
if options.RepeatedSymbols && options.RepeatedSymbolsMin == 4 && level != "none" {
|
||||
want = processor.Text("[", level) + "5 number" + processor.Text("]", level)
|
||||
}
|
||||
if got := processor.Process_text("[#####]", level, options); got != want {
|
||||
t.Errorf("level %s, options %+v: got %q, want %q", level, options, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTextSubstitutionTranslationsAndFieldOrder(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
directory := filepath.Join(root, "xx", "LC_MESSAGES")
|
||||
|
||||
Reference in new issue
Block a user