diff options
author | Corey Hulen <corey@hulen.com> | 2017-04-04 11:42:07 -0700 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-04-04 14:42:07 -0400 |
commit | 6bf080393d88534aa658ecaff32ae089bd304772 (patch) | |
tree | be25ba4cea3d687d11fe49537b84fae4bf21a484 /vendor/golang.org/x/text/encoding/charmap/charmap_test.go | |
parent | 32460bf63bc07c69ee5da0bb5640b879facb5538 (diff) | |
download | chat-6bf080393d88534aa658ecaff32ae089bd304772.tar.gz chat-6bf080393d88534aa658ecaff32ae089bd304772.tar.bz2 chat-6bf080393d88534aa658ecaff32ae089bd304772.zip |
Fixing race conditions in the code base (#5966)
* Adding initial race detector
* Remove setting of config twice
* Fixing config file watch and config reload on license save
* Fixing config file watch and config reload on license save
* Fixing build error
* Fixing locking issue
* Fixing makefile
* Fixing race in config
* Fixing race in status unit test
* Adding EE race tests
* Fixing race in cluster info
* Removing code that's isn't needed
* Fixing some more races
* Fixing govet issue
Diffstat (limited to 'vendor/golang.org/x/text/encoding/charmap/charmap_test.go')
-rw-r--r-- | vendor/golang.org/x/text/encoding/charmap/charmap_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/golang.org/x/text/encoding/charmap/charmap_test.go b/vendor/golang.org/x/text/encoding/charmap/charmap_test.go index 186bf4c5b..03dd76ebd 100644 --- a/vendor/golang.org/x/text/encoding/charmap/charmap_test.go +++ b/vendor/golang.org/x/text/encoding/charmap/charmap_test.go @@ -16,9 +16,11 @@ import ( func dec(e encoding.Encoding) (dir string, t transform.Transformer, err error) { return "Decode", e.NewDecoder(), nil } + func encASCIISuperset(e encoding.Encoding) (dir string, t transform.Transformer, err error) { return "Encode", e.NewEncoder(), internal.ErrASCIIReplacement } + func encEBCDIC(e encoding.Encoding) (dir string, t transform.Transformer, err error) { return "Encode", e.NewEncoder(), internal.RepertoireError(0x3f) } @@ -200,6 +202,57 @@ func TestBasics(t *testing.T) { } } +var windows1255TestCases = []struct { + b byte + ok bool + r rune +}{ + {'\x00', true, '\u0000'}, + {'\x1a', true, '\u001a'}, + {'\x61', true, '\u0061'}, + {'\x7f', true, '\u007f'}, + {'\x80', true, '\u20ac'}, + {'\x95', true, '\u2022'}, + {'\xa0', true, '\u00a0'}, + {'\xc0', true, '\u05b0'}, + {'\xfc', true, '\ufffd'}, + {'\xfd', true, '\u200e'}, + {'\xfe', true, '\u200f'}, + {'\xff', true, '\ufffd'}, + {encoding.ASCIISub, false, '\u0400'}, + {encoding.ASCIISub, false, '\u2603'}, + {encoding.ASCIISub, false, '\U0001f4a9'}, +} + +func TestDecodeByte(t *testing.T) { + for _, tc := range windows1255TestCases { + if !tc.ok { + continue + } + + got := Windows1255.DecodeByte(tc.b) + want := tc.r + if got != want { + t.Errorf("DecodeByte(%#02x): got %#08x, want %#08x", tc.b, got, want) + } + } +} + +func TestEncodeRune(t *testing.T) { + for _, tc := range windows1255TestCases { + // There can be multiple tc.b values that map to tc.r = '\ufffd'. + if tc.r == '\ufffd' { + continue + } + + gotB, gotOK := Windows1255.EncodeRune(tc.r) + wantB, wantOK := tc.b, tc.ok + if gotB != wantB || gotOK != wantOK { + t.Errorf("EncodeRune(%#08x): got (%#02x, %t), want (%#02x, %t)", tc.r, gotB, gotOK, wantB, wantOK) + } + } +} + func TestFiles(t *testing.T) { enctest.TestFile(t, Windows1252) } func BenchmarkEncoding(b *testing.B) { enctest.Benchmark(b, Windows1252) } |