(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestStringEncoding(t *testing.T) { |
| 41 | buf := bytes.NewBuffer(nil) |
| 42 | enc := NewEncoder(buf) |
| 43 | strList := []string{ |
| 44 | "", |
| 45 | "abc", |
| 46 | "12", |
| 47 | "32766", |
| 48 | "007", |
| 49 | "0", |
| 50 | "+0", |
| 51 | "-0", |
| 52 | "+1", |
| 53 | "-1", |
| 54 | "0x11", |
| 55 | "0o00", |
| 56 | strconv.Itoa(math.MaxInt8), |
| 57 | strconv.Itoa(math.MinInt8), |
| 58 | strconv.Itoa(math.MaxInt16), |
| 59 | strconv.Itoa(math.MinInt16), |
| 60 | strconv.Itoa(math.MaxInt32), |
| 61 | strconv.Itoa(math.MaxInt32) + "1", |
| 62 | strconv.Itoa(math.MinInt32), |
| 63 | strconv.Itoa(math.MinInt32) + "1", |
| 64 | strconv.Itoa(math.MaxInt64), |
| 65 | strconv.Itoa(math.MaxInt64) + "1", |
| 66 | strconv.Itoa(math.MinInt64), |
| 67 | strconv.Itoa(math.MinInt64) + "1", |
| 68 | RandString(20000), |
| 69 | } |
| 70 | for _, str := range strList { |
| 71 | err := enc.writeString(str) |
| 72 | if err != nil { |
| 73 | t.Error(err) |
| 74 | return |
| 75 | } |
| 76 | } |
| 77 | dec := NewDecoder(buf) |
| 78 | for _, expect := range strList { |
| 79 | actual, err := dec.readString() |
| 80 | if err != nil { |
| 81 | t.Error(err) |
| 82 | continue |
| 83 | } |
| 84 | if string(actual) != expect { |
| 85 | t.Errorf("expect %s, actual %s", expect, string(actual)) |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func TestRandomStringEncoding(t *testing.T) { |
| 91 | size := 1000 |
nothing calls this directly
no test coverage detected
searching dependent graphs…