| giolekva | 7be17df | 2020-03-21 13:57:02 +0400 | [diff] [blame^] | 1 | package chunk |
| 2 | |
| 3 | import "bytes" |
| 4 | import "testing" |
| 5 | |
| 6 | func TestConcurrentReads(t *testing.T) { |
| 7 | c := InMemoryChunkFactory{}.New() |
| 8 | if _, err := c.Writer().Write([]byte("abcd")); err != nil { |
| 9 | panic(err) |
| 10 | } |
| 11 | d1 := make([]byte, 2) |
| 12 | d2 := make([]byte, 3) |
| 13 | if _, err := c.ReadSeeker().Read(d1); err != nil { |
| 14 | t.Error(err) |
| 15 | } |
| 16 | if bytes.Compare(d1, []byte("ab")) != 0 { |
| 17 | t.Errorf("Expected: %s\nActual: %s", "ab", d1) |
| 18 | } |
| 19 | if _, err := c.ReadSeeker().Read(d2); err != nil { |
| 20 | t.Error(err) |
| 21 | } |
| 22 | if bytes.Compare(d2, []byte("abc")) != 0 { |
| 23 | t.Errorf("Expected: %s\nActual: %s", "abc", d2) |
| 24 | } |
| 25 | } |