mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
apply gofmt to rand reflect regexp rpc runtime sort strconv strings sync syscall testing time unicode unsafe utf8
R=gri DELTA=1409 (79 added, 24 deleted, 1306 changed) OCL=35415 CL=35437
This commit is contained in:
parent
f77b255c38
commit
91549438d8
41 changed files with 1331 additions and 1276 deletions
|
|
@ -5,91 +5,91 @@
|
|||
package strconv_test
|
||||
|
||||
import (
|
||||
"os";
|
||||
"reflect";
|
||||
. "strconv";
|
||||
"testing";
|
||||
"os";
|
||||
"reflect";
|
||||
. "strconv";
|
||||
"testing";
|
||||
)
|
||||
|
||||
type atofTest struct {
|
||||
in string;
|
||||
out string;
|
||||
err os.Error;
|
||||
in string;
|
||||
out string;
|
||||
err os.Error;
|
||||
}
|
||||
|
||||
var atoftests = []atofTest {
|
||||
atofTest{ "", "0", os.EINVAL },
|
||||
atofTest{ "1", "1", nil },
|
||||
atofTest{ "+1", "1", nil },
|
||||
atofTest{ "1x", "0", os.EINVAL },
|
||||
atofTest{ "1.1.", "0", os.EINVAL },
|
||||
atofTest{ "1e23", "1e+23", nil },
|
||||
atofTest{ "100000000000000000000000", "1e+23", nil },
|
||||
atofTest{ "1e-100", "1e-100", nil },
|
||||
atofTest{ "123456700", "1.234567e+08", nil },
|
||||
atofTest{ "99999999999999974834176", "9.999999999999997e+22", nil },
|
||||
atofTest{ "100000000000000000000001", "1.0000000000000001e+23", nil },
|
||||
atofTest{ "100000000000000008388608", "1.0000000000000001e+23", nil },
|
||||
atofTest{ "100000000000000016777215", "1.0000000000000001e+23", nil },
|
||||
atofTest{ "100000000000000016777216", "1.0000000000000003e+23", nil },
|
||||
atofTest{ "-1", "-1", nil },
|
||||
atofTest{ "-0", "-0", nil },
|
||||
atofTest{ "1e-20", "1e-20", nil },
|
||||
atofTest{ "625e-3", "0.625", nil },
|
||||
var atoftests = []atofTest{
|
||||
atofTest{"", "0", os.EINVAL},
|
||||
atofTest{"1", "1", nil},
|
||||
atofTest{"+1", "1", nil},
|
||||
atofTest{"1x", "0", os.EINVAL},
|
||||
atofTest{"1.1.", "0", os.EINVAL},
|
||||
atofTest{"1e23", "1e+23", nil},
|
||||
atofTest{"100000000000000000000000", "1e+23", nil},
|
||||
atofTest{"1e-100", "1e-100", nil},
|
||||
atofTest{"123456700", "1.234567e+08", nil},
|
||||
atofTest{"99999999999999974834176", "9.999999999999997e+22", nil},
|
||||
atofTest{"100000000000000000000001", "1.0000000000000001e+23", nil},
|
||||
atofTest{"100000000000000008388608", "1.0000000000000001e+23", nil},
|
||||
atofTest{"100000000000000016777215", "1.0000000000000001e+23", nil},
|
||||
atofTest{"100000000000000016777216", "1.0000000000000003e+23", nil},
|
||||
atofTest{"-1", "-1", nil},
|
||||
atofTest{"-0", "-0", nil},
|
||||
atofTest{"1e-20", "1e-20", nil},
|
||||
atofTest{"625e-3", "0.625", nil},
|
||||
|
||||
// largest float64
|
||||
atofTest{ "1.7976931348623157e308", "1.7976931348623157e+308", nil },
|
||||
atofTest{ "-1.7976931348623157e308", "-1.7976931348623157e+308", nil },
|
||||
atofTest{"1.7976931348623157e308", "1.7976931348623157e+308", nil},
|
||||
atofTest{"-1.7976931348623157e308", "-1.7976931348623157e+308", nil},
|
||||
// next float64 - too large
|
||||
atofTest{ "1.7976931348623159e308", "+Inf", os.ERANGE },
|
||||
atofTest{ "-1.7976931348623159e308", "-Inf", os.ERANGE },
|
||||
atofTest{"1.7976931348623159e308", "+Inf", os.ERANGE},
|
||||
atofTest{"-1.7976931348623159e308", "-Inf", os.ERANGE},
|
||||
// the border is ...158079
|
||||
// borderline - okay
|
||||
atofTest{ "1.7976931348623158e308", "1.7976931348623157e+308", nil },
|
||||
atofTest{ "-1.7976931348623158e308", "-1.7976931348623157e+308", nil },
|
||||
atofTest{"1.7976931348623158e308", "1.7976931348623157e+308", nil},
|
||||
atofTest{"-1.7976931348623158e308", "-1.7976931348623157e+308", nil},
|
||||
// borderline - too large
|
||||
atofTest{ "1.797693134862315808e308", "+Inf", os.ERANGE },
|
||||
atofTest{ "-1.797693134862315808e308", "-Inf", os.ERANGE },
|
||||
atofTest{"1.797693134862315808e308", "+Inf", os.ERANGE},
|
||||
atofTest{"-1.797693134862315808e308", "-Inf", os.ERANGE},
|
||||
|
||||
// a little too large
|
||||
atofTest{ "1e308", "1e+308", nil },
|
||||
atofTest{ "2e308", "+Inf", os.ERANGE },
|
||||
atofTest{ "1e309", "+Inf", os.ERANGE },
|
||||
atofTest{"1e308", "1e+308", nil},
|
||||
atofTest{"2e308", "+Inf", os.ERANGE},
|
||||
atofTest{"1e309", "+Inf", os.ERANGE},
|
||||
|
||||
// way too large
|
||||
atofTest{ "1e310", "+Inf", os.ERANGE },
|
||||
atofTest{ "-1e310", "-Inf", os.ERANGE },
|
||||
atofTest{ "1e400", "+Inf", os.ERANGE },
|
||||
atofTest{ "-1e400", "-Inf", os.ERANGE },
|
||||
atofTest{ "1e400000", "+Inf", os.ERANGE },
|
||||
atofTest{ "-1e400000", "-Inf", os.ERANGE },
|
||||
atofTest{"1e310", "+Inf", os.ERANGE},
|
||||
atofTest{"-1e310", "-Inf", os.ERANGE},
|
||||
atofTest{"1e400", "+Inf", os.ERANGE},
|
||||
atofTest{"-1e400", "-Inf", os.ERANGE},
|
||||
atofTest{"1e400000", "+Inf", os.ERANGE},
|
||||
atofTest{"-1e400000", "-Inf", os.ERANGE},
|
||||
|
||||
// denormalized
|
||||
atofTest{ "1e-305", "1e-305", nil },
|
||||
atofTest{ "1e-306", "1e-306", nil },
|
||||
atofTest{ "1e-307", "1e-307", nil },
|
||||
atofTest{ "1e-308", "1e-308", nil },
|
||||
atofTest{ "1e-309", "1e-309", nil },
|
||||
atofTest{ "1e-310", "1e-310", nil },
|
||||
atofTest{ "1e-322", "1e-322", nil },
|
||||
atofTest{"1e-305", "1e-305", nil},
|
||||
atofTest{"1e-306", "1e-306", nil},
|
||||
atofTest{"1e-307", "1e-307", nil},
|
||||
atofTest{"1e-308", "1e-308", nil},
|
||||
atofTest{"1e-309", "1e-309", nil},
|
||||
atofTest{"1e-310", "1e-310", nil},
|
||||
atofTest{"1e-322", "1e-322", nil},
|
||||
// smallest denormal
|
||||
atofTest{ "5e-324", "5e-324", nil },
|
||||
atofTest{"5e-324", "5e-324", nil},
|
||||
// too small
|
||||
atofTest{ "4e-324", "0", nil },
|
||||
atofTest{"4e-324", "0", nil},
|
||||
// way too small
|
||||
atofTest{ "1e-350", "0", nil },
|
||||
atofTest{ "1e-400000", "0", nil },
|
||||
atofTest{"1e-350", "0", nil},
|
||||
atofTest{"1e-400000", "0", nil},
|
||||
|
||||
// try to overflow exponent
|
||||
atofTest{ "1e-4294967296", "0", nil },
|
||||
atofTest{ "1e+4294967296", "+Inf", os.ERANGE },
|
||||
atofTest{ "1e-18446744073709551616", "0", nil },
|
||||
atofTest{ "1e+18446744073709551616", "+Inf", os.ERANGE },
|
||||
atofTest{"1e-4294967296", "0", nil},
|
||||
atofTest{"1e+4294967296", "+Inf", os.ERANGE},
|
||||
atofTest{"1e-18446744073709551616", "0", nil},
|
||||
atofTest{"1e+18446744073709551616", "+Inf", os.ERANGE},
|
||||
|
||||
// Parse errors
|
||||
atofTest{ "1e", "0", os.EINVAL },
|
||||
atofTest{ "1e-", "0", os.EINVAL },
|
||||
atofTest{ ".e-1", "0", os.EINVAL },
|
||||
atofTest{"1e", "0", os.EINVAL},
|
||||
atofTest{"1e-", "0", os.EINVAL},
|
||||
atofTest{".e-1", "0", os.EINVAL},
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
@ -98,7 +98,7 @@ func init() {
|
|||
for i := range atoftests {
|
||||
test := &atoftests[i];
|
||||
if test.err != nil {
|
||||
test.err = &NumError{test.in, test.err}
|
||||
test.err = &NumError{test.in, test.err};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue