LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package net | 5 package net |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "os" | 9 "os" |
10 "runtime" | 10 "runtime" |
11 "testing" | 11 "testing" |
12 ) | 12 ) |
13 | 13 |
14 func TestReadLine(t *testing.T) { | 14 func TestReadLine(t *testing.T) { |
15 // /etc/services file does not exist on windows and Plan 9. | 15 // /etc/services file does not exist on windows and Plan 9. |
16 switch runtime.GOOS { | 16 switch runtime.GOOS { |
17 case "plan9", "windows": | 17 case "plan9", "windows": |
18 » » t.Logf("skipping test on %q", runtime.GOOS) | 18 » » t.Skipf("skipping test on %q", runtime.GOOS) |
19 » » return | |
20 } | 19 } |
21 filename := "/etc/services" // a nice big file | 20 filename := "/etc/services" // a nice big file |
22 | 21 |
23 fd, err := os.Open(filename) | 22 fd, err := os.Open(filename) |
24 if err != nil { | 23 if err != nil { |
25 t.Fatalf("open %s: %v", filename, err) | 24 t.Fatalf("open %s: %v", filename, err) |
26 } | 25 } |
27 br := bufio.NewReader(fd) | 26 br := bufio.NewReader(fd) |
28 | 27 |
29 file, err := open(filename) | 28 file, err := open(filename) |
(...skipping 13 matching lines...) Expand all Loading... |
43 t.Fatalf("%s:%d (#%d)\nbufio => %q, %v\nnet => %q, %v", | 42 t.Fatalf("%s:%d (#%d)\nbufio => %q, %v\nnet => %q, %v", |
44 filename, lineno, byteno, bline, berr, line, ok) | 43 filename, lineno, byteno, bline, berr, line, ok) |
45 } | 44 } |
46 if !ok { | 45 if !ok { |
47 break | 46 break |
48 } | 47 } |
49 lineno++ | 48 lineno++ |
50 byteno += len(line) + 1 | 49 byteno += len(line) + 1 |
51 } | 50 } |
52 } | 51 } |
LEFT | RIGHT |