LEFT | RIGHT |
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 fmt_test | 5 package fmt_test |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "bytes" | 9 "bytes" |
10 . "fmt" | 10 . "fmt" |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 803 } |
804 | 804 |
805 func TestScanInts(t *testing.T) { | 805 func TestScanInts(t *testing.T) { |
806 testScanInts(t, scanInts) | 806 testScanInts(t, scanInts) |
807 testScanInts(t, func(r *RecursiveInt, b *bytes.Buffer) (err os.Error) { | 807 testScanInts(t, func(r *RecursiveInt, b *bytes.Buffer) (err os.Error) { |
808 _, err = Fscan(b, r) | 808 _, err = Fscan(b, r) |
809 return | 809 return |
810 }) | 810 }) |
811 } | 811 } |
812 | 812 |
| 813 // 800 is small enough to not overflow the stack when using gccgo on a |
| 814 // platform that does not support split stack. |
813 const intCount = 800 | 815 const intCount = 800 |
814 | 816 |
815 func testScanInts(t *testing.T, scan func(*RecursiveInt, *bytes.Buffer) os.Error
) { | 817 func testScanInts(t *testing.T, scan func(*RecursiveInt, *bytes.Buffer) os.Error
) { |
816 r := new(RecursiveInt) | 818 r := new(RecursiveInt) |
817 ints := makeInts(intCount) | 819 ints := makeInts(intCount) |
818 buf := bytes.NewBuffer(ints) | 820 buf := bytes.NewBuffer(ints) |
819 err := scan(r, buf) | 821 err := scan(r, buf) |
820 if err != nil { | 822 if err != nil { |
821 t.Error("unexpected error", err) | 823 t.Error("unexpected error", err) |
822 } | 824 } |
(...skipping 25 matching lines...) Expand all Loading... |
848 b.ResetTimer() | 850 b.ResetTimer() |
849 ints := makeInts(intCount) | 851 ints := makeInts(intCount) |
850 var r RecursiveInt | 852 var r RecursiveInt |
851 for i := b.N - 1; i >= 0; i-- { | 853 for i := b.N - 1; i >= 0; i-- { |
852 buf := bytes.NewBuffer(ints) | 854 buf := bytes.NewBuffer(ints) |
853 b.StartTimer() | 855 b.StartTimer() |
854 Fscan(buf, &r) | 856 Fscan(buf, &r) |
855 b.StopTimer() | 857 b.StopTimer() |
856 } | 858 } |
857 } | 859 } |
LEFT | RIGHT |