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

Delta Between Two Patch Sets: src/pkg/big/rat_test.go

Issue 1250043: code review 1250043: big: Add Rat type (Closed)
Left Patch Set: code review 1250043: big: Add Rat type Created 14 years, 10 months ago
Right Patch Set: code review 1250043: big: Add Rat type Created 14 years, 10 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/big/rat.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 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 big 5 package big
6 6
7 import "testing" 7 import "testing"
8 8
9 9
10 type setStringTest struct { 10 type setStringTest struct {
11 in, out string 11 in, out string
12 } 12 }
13 13
14 var setStringTests = []setStringTest{ 14 var setStringTests = []setStringTest{
15 » setStringTest{"0", "0/1"}, 15 » setStringTest{"0", "0"},
16 » setStringTest{"1", "1/1"}, 16 » setStringTest{"1", "1"},
17 » setStringTest{"-1", "-1/1"}, 17 » setStringTest{"-1", "-1"},
18 setStringTest{"2/4", "1/2"}, 18 setStringTest{"2/4", "1/2"},
19 setStringTest{".25", "1/4"}, 19 setStringTest{".25", "1/4"},
20 setStringTest{"-1/5", "-1/5"}, 20 setStringTest{"-1/5", "-1/5"},
21 } 21 }
22 22
23 func TestRatSetString(t *testing.T) { 23 func TestRatSetString(t *testing.T) {
24 for i, test := range setStringTests { 24 for i, test := range setStringTests {
25 x, _ := new(Rat).SetString(test.in) 25 x, _ := new(Rat).SetString(test.in)
26 26
27 if x.String() != test.out { 27 if x.String() != test.out {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 rat1, rat2 string 64 rat1, rat2 string
65 out int 65 out int
66 } 66 }
67 67
68 var ratCmpTests = []ratCmpTest{ 68 var ratCmpTests = []ratCmpTest{
69 ratCmpTest{"0", "0/1", 0}, 69 ratCmpTest{"0", "0/1", 0},
70 ratCmpTest{"1/1", "1", 0}, 70 ratCmpTest{"1/1", "1", 0},
71 ratCmpTest{"-1", "-2/2", 0}, 71 ratCmpTest{"-1", "-2/2", 0},
72 ratCmpTest{"1", "0", 1}, 72 ratCmpTest{"1", "0", 1},
73 ratCmpTest{"0/1", "1/1", -1}, 73 ratCmpTest{"0/1", "1/1", -1},
74 » ratCmpTest{"-5/1434770811533343057144", "-5/1434770811533343057145", 1}, 74 » ratCmpTest{"-5/1434770811533343057144", "-5/1434770811533343057145", -1} ,
75 ratCmpTest{"49832350382626108453/8964749413", "49832350382626108454/8964 749413", -1}, 75 ratCmpTest{"49832350382626108453/8964749413", "49832350382626108454/8964 749413", -1},
76 ratCmpTest{"-37414950961700930/7204075375675961", "37414950961700930/720 4075375675961", -1}, 76 ratCmpTest{"-37414950961700930/7204075375675961", "37414950961700930/720 4075375675961", -1},
77 ratCmpTest{"37414950961700930/7204075375675961", "74829901923401860/1440 8150751351922", 0}, 77 ratCmpTest{"37414950961700930/7204075375675961", "74829901923401860/1440 8150751351922", 0},
78 } 78 }
79 79
80 func TestRatCmp(t *testing.T) { 80 func TestRatCmp(t *testing.T) {
81 for i, test := range ratCmpTests { 81 for i, test := range ratCmpTests {
82 x, _ := new(Rat).SetString(test.rat1) 82 x, _ := new(Rat).SetString(test.rat1)
83 y, _ := new(Rat).SetString(test.rat2) 83 y, _ := new(Rat).SetString(test.rat2)
84 84
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ratBinArg{"1/4", "1/3", "3/4"}, 176 ratBinArg{"1/4", "1/3", "3/4"},
177 ratBinArg{"2/5", "-14/3", "-3/35"}, 177 ratBinArg{"2/5", "-14/3", "-3/35"},
178 ratBinArg{"808/45524274987585732633", "29/712593081308", "57577520969686 4/1320203974639986246357"}, 178 ratBinArg{"808/45524274987585732633", "29/712593081308", "57577520969686 4/1320203974639986246357"},
179 ratBinArg{"8967230/3296219033", "6269770/1992362624741777", "17865973899 46320496771/2066653520653241"}, 179 ratBinArg{"8967230/3296219033", "6269770/1992362624741777", "17865973899 46320496771/2066653520653241"},
180 ratBinArg{"-3784609207827/3426986245", "9381566963714/9633539", "-364591 80403360509753/32150500941194292113930"}, 180 ratBinArg{"-3784609207827/3426986245", "9381566963714/9633539", "-364591 80403360509753/32150500941194292113930"},
181 } 181 }
182 182
183 func TestRatQuo(t *testing.T) { 183 func TestRatQuo(t *testing.T) {
184 testRatBin(t, (*Rat).Quo, ratQuoTests) 184 testRatBin(t, (*Rat).Quo, ratQuoTests)
185 } 185 }
LEFTRIGHT

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