-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgematriya_test.go
More file actions
72 lines (66 loc) · 1.55 KB
/
Copy pathgematriya_test.go
File metadata and controls
72 lines (66 loc) · 1.55 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
package gematriya
import (
"fmt"
"strconv"
"testing"
)
func TestGematriya(t *testing.T) {
tests := []struct {
number int
want string
}{
{3, "ג׳"},
{14, "י״ד"},
{15, "ט״ו"}, // 9+6 rather than 10+5
{16, "ט״ז"}, // 9+7 rather than 10+6
{17, "י״ז"},
{20, "כ׳"},
{25, "כ״ה"},
{60, "ס׳"},
{115, "קט״ו"}, // the 15 rule still applies below a hundreds letter
{116, "קט״ז"},
{123, "קכ״ג"},
{400, "ת׳"},
{500, "ת״ק"}, // 400+100, there being no letter above tav
{613, "תרי״ג"},
{900, "תת״ק"},
{999, "תתקצ״ט"},
{5749, "תשמ״ט"}, // present millennium: the leading 5 is omitted
{5774, "תשע״ד"},
{5780, "תש״פ"},
{1123, "א׳קכ״ג"},
{3761, "ג׳תשס״א"},
{6749, "ו׳תשמ״ט"},
{8765, "ח׳תשס״ה"},
{16123, "טז׳קכ״ג"},
{22700, "כב׳ת״ש"},
{6000, "ו׳"}, // no letters below the thousands
{7007, "ז׳ז׳"},
{5000, ""}, // the elided 5 leaves nothing to write
{0, ""},
{-1, ""},
}
for _, tt := range tests {
t.Run(strconv.Itoa(tt.number), func(t *testing.T) {
if got := Gematriya(tt.number); got != tt.want {
t.Errorf("Gematriya(%d) = %q, want %q", tt.number, got, tt.want)
}
})
}
}
func ExampleGematriya() {
gematriya := Gematriya(5749)
fmt.Println(gematriya)
// Output: תשמ״ט
}
var sink string
func BenchmarkGematriya(b *testing.B) {
for i := 0; i < b.N; i++ {
sink = Gematriya(5749)
}
}
func BenchmarkGematriyaThousands(b *testing.B) {
for i := 0; i < b.N; i++ {
sink = Gematriya(16123)
}
}