| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestReadLine(t *testing.T) { |
| filename := "/etc/services"; // a nice big file |
| fd, err := os.Open(filename, os.O_RDONLY, 0); |
| t.Fatalf("open %s: %v", filename, err) |
| br := bufio.NewReader(fd); |
| file, err = open(filename); |
| t.Fatalf("net.open(%s) = nil", filename) |
| bline, berr := br.ReadString('\n'); |
| if n := len(bline); n > 0 { |
| line, ok := file.readLine(); |
| if (berr != nil) != !ok || bline != line { |
| t.Fatalf("%s:%d (#%d)\nbufio => %q, %v\nnet => %q, %v", |
| filename, lineno, byteno, bline, berr, line, ok) |