diff options
| author | Kei Son <hey.calmdown@gmail.com> | 2009-12-11 10:37:48 -0800 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-12-11 10:37:48 -0800 |
| commit | 128974adfd8384ef6d8ee90f711df6a771c9cb1f (patch) | |
| tree | a0901ead658b056634aec216b9bc8ff0f7895036 /src/pkg/bytes/bytes_test.go | |
| parent | 67aa1399d65a0d7c2d3b4d99447f07811cf79194 (diff) | |
| download | go-128974adfd8384ef6d8ee90f711df6a771c9cb1f.tar.xz | |
bytes, strings: allow -1 in Map to mean "drop this character".
xml: drop invalid characters in attribute names
when constructing struct field names.
R=rsc
CC=r
https://golang.org/cl/157104
Diffstat (limited to 'src/pkg/bytes/bytes_test.go')
| -rw-r--r-- | src/pkg/bytes/bytes_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/bytes/bytes_test.go b/src/pkg/bytes/bytes_test.go index 553ceb7c5a..3f77e6e9ff 100644 --- a/src/pkg/bytes/bytes_test.go +++ b/src/pkg/bytes/bytes_test.go @@ -365,6 +365,19 @@ func TestMap(t *testing.T) { if string(m) != expect { t.Errorf("rot13: expected %q got %q", expect, m) } + + // 5. Drop + dropNotLatin := func(rune int) int { + if unicode.Is(unicode.Latin, rune) { + return rune + } + return -1; + }; + m = Map(dropNotLatin, Bytes("Hello, 세계")); + expect = "Hello"; + if string(m) != expect { + t.Errorf("drop: expected %q got %q", expect, m) + } } func TestToUpper(t *testing.T) { runStringTests(t, ToUpper, "ToUpper", upperTests) } |
