aboutsummaryrefslogtreecommitdiff
path: root/v2/classifier_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'v2/classifier_test.go')
-rw-r--r--v2/classifier_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/v2/classifier_test.go b/v2/classifier_test.go
index e4cab30..cb613e5 100644
--- a/v2/classifier_test.go
+++ b/v2/classifier_test.go
@@ -309,3 +309,37 @@ func TestLicenseName(t *testing.T) {
})
}
}
+
+func TestNormalize(t *testing.T) {
+ tests := []struct {
+ input string
+ want string
+ }{
+ {
+ input: "Words With Extra Spaces are flattened out, preserving case",
+ want: "Words With Extra Spaces are flattened out preserving case",
+ },
+ {
+ input: "",
+ want: "",
+ },
+ {
+ input: " License ",
+ want: "License",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.input, func(t *testing.T) {
+ c, err := classifier()
+ if err != nil {
+ t.Fatalf("couldn't instantiate standard Google classifier: %v", err)
+ }
+
+ got := c.Normalize([]byte(tt.input))
+ if diff := cmp.Diff(tt.want, string(got)); diff != "" {
+ t.Errorf("Unexpected result; diff %v", diff)
+ }
+ })
+ }
+
+}