Skip to content

Commit

Permalink
test: add test for normalizeName
Browse files Browse the repository at this point in the history
  • Loading branch information
maeb committed May 6, 2024
1 parent 6d4eb9f commit d845893
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions headerfielddef_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,33 @@ func TestValidateHeader(t *testing.T) {
})
}
}

func TestNormalizeName(t *testing.T) {
type test struct {
name string
want string
}
var tests []test

// Add all known headers as test cases
for fieldName, def := range lcHdrNameToDef {
tests = append(tests, test{fieldName, def.name})
}

tests = append(tests,
test{
// Test that unknown headers are normalized to title case
name: "WARC-SOME-UNKNOWN-HEADER",
want: "Warc-Some-Unknown-Header",
},
)

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, _ := normalizeName(tt.name)
if got != tt.want {
t.Errorf("normalizeName() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit d845893

Please sign in to comment.