MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestFactorize

Function TestFactorize

math/prime/primefactorization_test.go:8–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestFactorize(t *testing.T) {
9 var tests = []struct {
10 n int64
11 expected map[int64]int64
12 }{
13 {4, map[int64]int64{2: 2}},
14 {5, map[int64]int64{5: 1}},
15 {7, map[int64]int64{7: 1}},
16 {10, map[int64]int64{2: 1, 5: 1}},
17 {999, map[int64]int64{3: 3, 37: 1}},
18 {999999999999878, map[int64]int64{2: 1, 19: 1, 26315789473681: 1}},
19 }
20 for _, test := range tests {
21 result := Factorize(test.n)
22 t.Log(test.n, " ", result)
23 if !reflect.DeepEqual(result, test.expected) {
24 t.Errorf("Wrong result! Expected:%v, returned:%v ", test.expected, result)
25 }
26 }
27}
28
29func BenchmarkFactorize(b *testing.B) {
30 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 1

FactorizeFunction · 0.85

Tested by

no test coverage detected