Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Side by Side Diff: src/pkg/fmt/scan_test.go

Issue 2144043: code review 2144043: fmt.Scan: fix integer overflow on 32-bit machines (Closed)
Patch Set: code review 2144043: fmt.Scan: fix integer overflow on 32-bit machines Created 14 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/fmt/scan.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 . "fmt" 8 . "fmt"
9 "io" 9 "io"
10 "os" 10 "os"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ScanTest{"109\n", &renamedUint8Val, renamedUint8(109)}, 176 ScanTest{"109\n", &renamedUint8Val, renamedUint8(109)},
177 ScanTest{"110\n", &renamedUint16Val, renamedUint16(110)}, 177 ScanTest{"110\n", &renamedUint16Val, renamedUint16(110)},
178 ScanTest{"111\n", &renamedUint32Val, renamedUint32(111)}, 178 ScanTest{"111\n", &renamedUint32Val, renamedUint32(111)},
179 ScanTest{"112\n", &renamedUint64Val, renamedUint64(112)}, 179 ScanTest{"112\n", &renamedUint64Val, renamedUint64(112)},
180 ScanTest{"113\n", &renamedUintptrVal, renamedUintptr(113)}, 180 ScanTest{"113\n", &renamedUintptrVal, renamedUintptr(113)},
181 ScanTest{"114\n", &renamedStringVal, renamedString("114")}, 181 ScanTest{"114\n", &renamedStringVal, renamedString("114")},
182 ScanTest{"115\n", &renamedBytesVal, renamedBytes([]byte("115"))}, 182 ScanTest{"115\n", &renamedBytesVal, renamedBytes([]byte("115"))},
183 183
184 // Custom scanner. 184 // Custom scanner.
185 ScanTest{" vvv ", &xVal, Xs("vvv")}, 185 ScanTest{" vvv ", &xVal, Xs("vvv")},
186
187 // Fixed bugs
188 ScanTest{"2147483648\n", &int64Val, int64(2147483648)}, // was: integer overflow
186 } 189 }
187 190
188 var scanfTests = []ScanfTest{ 191 var scanfTests = []ScanfTest{
189 ScanfTest{"%v", "TRUE\n", &boolVal, true}, 192 ScanfTest{"%v", "TRUE\n", &boolVal, true},
190 ScanfTest{"%t", "false\n", &boolVal, false}, 193 ScanfTest{"%t", "false\n", &boolVal, false},
191 ScanfTest{"%v", "-71\n", &intVal, -71}, 194 ScanfTest{"%v", "-71\n", &intVal, -71},
192 ScanfTest{"%d", "72\n", &intVal, 72}, 195 ScanfTest{"%d", "72\n", &intVal, 72},
193 ScanfTest{"%c", "a\n", &intVal, 'a'}, 196 ScanfTest{"%c", "a\n", &intVal, 'a'},
194 ScanfTest{"%c", "\u5072\n", &intVal, 0x5072}, 197 ScanfTest{"%c", "\u5072\n", &intVal, 0x5072},
195 ScanfTest{"%c", "\u1234\n", &intVal, '\u1234'}, 198 ScanfTest{"%c", "\u1234\n", &intVal, '\u1234'},
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 if err == nil { 575 if err == nil {
573 t.Error("expected error scanning empty string") 576 t.Error("expected error scanning empty string")
574 } 577 }
575 if n != 0 { 578 if n != 0 {
576 t.Error("expected to scan zero items, got", n) 579 t.Error("expected to scan zero items, got", n)
577 } 580 }
578 if ec.eofCount != 1 { 581 if ec.eofCount != 1 {
579 t.Error("expected one EOF, got", ec.eofCount) 582 t.Error("expected one EOF, got", ec.eofCount)
580 } 583 }
581 } 584 }
OLDNEW
« no previous file with comments | « src/pkg/fmt/scan.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b