-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Filter down posts not tagged as en, no, nb, nn, se or empty
We don't want posts tagged as other languages
- Loading branch information
Showing
3 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package firehose_test | ||
|
||
import ( | ||
"norsky/firehose" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestHasEnoughNorwegianLetters(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
text string | ||
expected bool | ||
}{ | ||
{ | ||
name: "empty string", | ||
text: "", | ||
expected: false, | ||
}, | ||
{ | ||
name: "only special characters", | ||
text: "!@#$%^&*()", | ||
expected: false, | ||
}, | ||
{ | ||
name: "few letters", | ||
text: "hi! :) 123456789", | ||
expected: false, | ||
}, | ||
{ | ||
name: "enough regular letters", | ||
text: "Dette er en normal norsk tekst", | ||
expected: true, | ||
}, | ||
{ | ||
name: "enough letters with Norwegian characters", | ||
text: "Blåbær og røde æbler på trærne", | ||
expected: true, | ||
}, | ||
{ | ||
name: "mixed content with enough letters", | ||
text: "Hei! 😊 Dette er en fin dag å være ute! 🌞", | ||
expected: true, | ||
}, | ||
{ | ||
name: "mixed content with too few letters", | ||
text: "Hi! 😊 🌞 123 !!! ???", | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
result := firehose.HasEnoughNorwegianLetters(tt.text) | ||
assert.Equal(t, tt.expected, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters