internal/dnsstring/reader_test.go
raw| 1 | package dnsstring |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestReader(t *testing.T) { |
| 6 | in := "aaa. 3600 IN NS a.nic.aaa." |
| 7 | r := NewReader(in) |
| 8 | p := make([]byte, 30) |
| 9 | _, err := r.Read(p) |
| 10 | if err != nil { |
| 11 | t.Fatal("expected no error, but got one") |
| 12 | } |
| 13 | // second read, should inlude a newline |
| 14 | p = make([]byte, 30) |
| 15 | _, err = r.Read(p) |
| 16 | if err == nil { |
| 17 | t.Fatal("expected error (io.EOF), but got none") |
| 18 | } |
| 19 | if p[0] != '\n' { |
| 20 | t.Fatalf("expected '\n', got %c", p[0]) |
| 21 | } |
| 22 | } |