-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathph_test.go
More file actions
97 lines (75 loc) · 1.93 KB
/
ph_test.go
File metadata and controls
97 lines (75 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package PiHex
// PiHex
// Test
// Copyright © 2016-2026 Eduard Sesigin. All rights reserved. Contacts: <claygod@yandex.ru>
import (
"testing"
)
func TestLimitZero(t *testing.T) {
pi := New()
if len(pi.Get(0, 0)) != 0 {
t.Error("Error two zeros in the argument /pi.Get(0, 0)")
}
}
func TestLimitCount1(t *testing.T) {
pi := New()
if len(pi.Get(0, 5)) != 5 {
t.Error("It returned the wrong number of digits /pi.Get(0, 5)")
}
}
func TestLimitCount2(t *testing.T) {
pi := New()
if len(pi.Get(5, 5)) != 5 {
t.Error("It returned the wrong number of digits /pi.Get(5, 5)")
}
}
func TestLimitNegative1(t *testing.T) {
pi := New()
if len(pi.Get(-1, 5)) != 0 {
t.Error("Adopted by Negative arguments /pi.Get(-1, 5)")
}
}
func TestLimitNegative2(t *testing.T) {
pi := New()
if len(pi.Get(0, -5)) != 0 {
t.Error("Adopted by Negative arguments /pi.Get(0, -5)")
}
}
func TestLimitNegative3(t *testing.T) {
pi := New()
if len(pi.Get(-1, -5)) != 0 {
t.Error("Adopted by Negative arguments /pi.Get(-1, -5)")
}
}
func TestLimitMax1(t *testing.T) {
pi := New()
if len(pi.Get(0, 10000001)) != 0 {
t.Error("The value argument exceeds the limit /pi.Get(0, 10000001)")
}
}
func TestLimitMax2(t *testing.T) {
pi := New()
if len(pi.Get(9999999, 2)) != 0 {
t.Error("The value argument exceeds the limit /pi.Get(9999999, 2)")
}
}
func TestLimitResult1(t *testing.T) {
pi := New()
tru := []byte{2, 4, 3, 15, 6, 10, 8, 8, 8, 5, 10, 3, 0, 8, 13, 3, 1, 3, 1, 9}
result := pi.Get(0, len(tru))
for i := 0; i < len(tru); i++ {
if tru[i] != result[i] {
t.Error("Wrong Result ", result[i], " at position ", i, " /pi.Get(0, len(tru)")
}
}
}
func TestLimitResult2(t *testing.T) {
pi := New()
tru := []byte{6, 12, 6, 5, 14, 5, 2, 12, 11, 4}
result := pi.Get(1000000, len(tru))
for i := 0; i < len(tru); i++ {
if tru[i] != result[i] {
t.Error("Wrong Result ", result[i], " at position ", i, " /pi.Get(1000000, len(tru)")
}
}
}