diff options
| author | Kei Son <hey.calmdown@gmail.com> | 2009-12-11 10:37:48 -0800 |
|---|---|---|
| committer | Kei Son <hey.calmdown@gmail.com> | 2009-12-11 10:37:48 -0800 |
| commit | 4faa9da32a986b1c10ad8b02e6bde4e6f06552ff (patch) | |
| tree | 3016eecdbaea6a8f70831cb6a56929843bcceaa8 /src/pkg/bytes/bytes_test.go | |
| parent | e584e6d2da734864fab7bbc340aa83636a4e5739 (diff) | |
| download | golang-4faa9da32a986b1c10ad8b02e6bde4e6f06552ff.tar.gz | |
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
http://codereview.appspot.com/157104
Committer: Russ Cox <rsc@golang.org>
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 553ceb7c5..3f77e6e9f 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) } |
