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

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

Issue 1004042: code review 1004042: big: implemented Karatsuba multiplication (Closed)
Left Patch Set: code review 1004042: big: implemented Karatsuba multiplication Created 13 years, 11 months ago
Right Patch Set: code review 1004042: big: implemented Karatsuba multiplication Created 13 years, 11 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/int.go ('k') | src/pkg/big/nat.go » ('j') | src/pkg/big/nat.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 big 5 package big
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/hex" 9 "encoding/hex"
10 "testing" 10 "testing"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 var z2 Int 135 var z2 Int
136 z2.SetBytes(mulBytes(a, b)) 136 z2.SetBytes(mulBytes(a, b))
137 137
138 return z1.Cmp(&z2) == 0 138 return z1.Cmp(&z2) == 0
139 } 139 }
140 140
141 141
142 func TestMul(t *testing.T) { 142 func TestMul(t *testing.T) {
143 if err := quick.Check(checkMul, nil); err != nil { 143 if err := quick.Check(checkMul, nil); err != nil {
144 t.Error(err) 144 t.Error(err)
145 }
146 }
147
148
149 var facts = map[int]string{
150 0: "1",
151 1: "1",
152 2: "2",
153 10: "3628800",
154 20: "2432902008176640000",
155 100: "933262154439441526816992388562667004907159682643816214685929" +
156 "638952175999932299156089414639761565182862536979208272237582" +
157 "51185210916864000000000000000000000000",
158 }
159
160
161 func TestFact(t *testing.T) {
162 for n, s := range facts {
163 var z Int
164 f := z.Fact(uint(n)).String()
165 if f != s {
166 t.Errorf("%d! = %s; want %s", n, f, s)
167 }
168 }
169 }
170
171
172 func BenchmarkFact(b *testing.B) {
173 var z Int
174 for i := 0; i < b.N; i++ {
175 z.Fact(1e5)
176 } 145 }
177 } 146 }
178 147
179 148
180 type fromStringTest struct { 149 type fromStringTest struct {
181 in string 150 in string
182 base int 151 base int
183 out int64 152 out int64
184 ok bool 153 ok bool
185 } 154 }
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 func TestInt64(t *testing.T) { 696 func TestInt64(t *testing.T) {
728 for i, testVal := range int64Tests { 697 for i, testVal := range int64Tests {
729 in := NewInt(testVal) 698 in := NewInt(testVal)
730 out := in.Int64() 699 out := in.Int64()
731 700
732 if out != testVal { 701 if out != testVal {
733 t.Errorf("#%d got %d want %d", i, out, testVal) 702 t.Errorf("#%d got %d want %d", i, out, testVal)
734 } 703 }
735 } 704 }
736 } 705 }
LEFTRIGHT

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