(t *testing.T)
| 39 | } |
| 40 | |
| 41 | func TestMemoryReader_Body_Range(t *testing.T) { |
| 42 | item := &MemoryItem{ |
| 43 | ExpiresAt: 0, |
| 44 | HeaderValue: nil, |
| 45 | BodyValue: []byte("0123456789"), |
| 46 | Status: 2000, |
| 47 | } |
| 48 | reader := NewMemoryReader(item) |
| 49 | buf := make([]byte, 6) |
| 50 | var err error |
| 51 | { |
| 52 | err = reader.ReadBodyRange(buf, 0, 0, func(n int) (goNext bool, err error) { |
| 53 | t.Log("[0, 0]", "body:", string(buf[:n])) |
| 54 | return true, nil |
| 55 | }) |
| 56 | if err != nil { |
| 57 | t.Fatal(err) |
| 58 | } |
| 59 | } |
| 60 | { |
| 61 | err = reader.ReadBodyRange(buf, 7, 7, func(n int) (goNext bool, err error) { |
| 62 | t.Log("[7, 7]", "body:", string(buf[:n])) |
| 63 | return true, nil |
| 64 | }) |
| 65 | if err != nil { |
| 66 | t.Fatal(err) |
| 67 | } |
| 68 | } |
| 69 | { |
| 70 | err = reader.ReadBodyRange(buf, 0, 10, func(n int) (goNext bool, err error) { |
| 71 | t.Log("[0, 10]", "body:", string(buf[:n])) |
| 72 | return true, nil |
| 73 | }) |
| 74 | if err != nil { |
| 75 | t.Fatal(err) |
| 76 | } |
| 77 | } |
| 78 | { |
| 79 | err = reader.ReadBodyRange(buf, 3, 5, func(n int) (goNext bool, err error) { |
| 80 | t.Log("[3, 5]", "body:", string(buf[:n])) |
| 81 | return true, nil |
| 82 | }) |
| 83 | if err != nil { |
| 84 | t.Fatal(err) |
| 85 | } |
| 86 | } |
| 87 | { |
| 88 | err = reader.ReadBodyRange(buf, -1, -3, func(n int) (goNext bool, err error) { |
| 89 | t.Log("[, -3]", "body:", string(buf[:n])) |
| 90 | return true, nil |
| 91 | }) |
| 92 | if err != nil { |
| 93 | t.Fatal(err) |
| 94 | } |
| 95 | } |
| 96 | { |
| 97 | err = reader.ReadBodyRange(buf, 3, -1, func(n int) (goNext bool, err error) { |
| 98 | t.Log("[3, ]", "body:", string(buf[:n])) |
nothing calls this directly
no test coverage detected