From 7298a16e0a51860e2045e7c24a87918987bc4ca5 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Wed, 20 Jan 2016 12:32:37 +1000 Subject: [PATCH] ircmap: Fix tests for new interface, add tests for RFC3454 --- ircmap/istring.go | 2 +- ircmap/istring_test.go | 44 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ircmap/istring.go b/ircmap/istring.go index 1392630..391b013 100644 --- a/ircmap/istring.go +++ b/ircmap/istring.go @@ -25,7 +25,7 @@ const ( ) var ( - // Mappings is a mapping of ISUPPORT CASEMAP value to our MappingTypes. + // Mappings is a mapping of ISUPPORT CASEMAP strings to our MappingTypes. Mappings = map[string]MappingType{ "ascii": ASCII, "rfc1459": RFC1459, diff --git a/ircmap/istring_test.go b/ircmap/istring_test.go index a11fe4b..4da06cb 100644 --- a/ircmap/istring_test.go +++ b/ircmap/istring_test.go @@ -19,10 +19,22 @@ var equalRFC1459Tests = []testcase{ {"#rK03j\\mn0r-4GD", "#rk03j|mn0r-4gd"}, } +var equalRFC3454Tests = []testcase{ + {"#TeStChAn", "#testchan"}, + {"#beßtchannEL", "#besstchannel"}, +} + func TestASCII(t *testing.T) { for _, pair := range equalASCIITests { - val := Casefold(ASCII, pair.raw) + val, err := Casefold(ASCII, pair.raw) + if err != nil { + t.Error( + "For", pair.raw, + "expected", pair.folded, + "but we got an error:", err.Error(), + ) + } if val != pair.folded { t.Error( "For", pair.raw, @@ -35,8 +47,36 @@ func TestASCII(t *testing.T) { func TestRFC1459(t *testing.T) { for _, pair := range equalRFC1459Tests { - val := Casefold(RFC1459, pair.raw) + val, err := Casefold(RFC1459, pair.raw) + if err != nil { + t.Error( + "For", pair.raw, + "expected", pair.folded, + "but we got an error:", err.Error(), + ) + } + if val != pair.folded { + t.Error( + "For", pair.raw, + "expected", pair.folded, + "got", val, + ) + } + } +} + +func TestRFC3454(t *testing.T) { + for _, pair := range equalRFC3454Tests { + val, err := Casefold(RFC3454, pair.raw) + + if err != nil { + t.Error( + "For", pair.raw, + "expected", pair.folded, + "but we got an error:", err.Error(), + ) + } if val != pair.folded { t.Error( "For", pair.raw,