-
Notifications
You must be signed in to change notification settings - Fork 0
/
cases_test.go
75 lines (73 loc) · 1.51 KB
/
cases_test.go
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
package grains
// This is an auto-generated file. Do not change it manually. Run the generator to update the file.
// See https://github.com/exercism/go#synchronizing-tests-and-instructions
// Source: exercism/problem-specifications
// Commit: d137db1 Format using prettier (#1917)
// returns the number of grains on the square
var squareTests = []struct {
description string
input int
expectedVal uint64
expectError bool
}{
{
description: "grains on square 1",
input: 1,
expectedVal: 1,
expectError: false,
},
{
description: "grains on square 2",
input: 2,
expectedVal: 2,
expectError: false,
},
{
description: "grains on square 3",
input: 3,
expectedVal: 4,
expectError: false,
},
{
description: "grains on square 4",
input: 4,
expectedVal: 8,
expectError: false,
},
{
description: "grains on square 16",
input: 16,
expectedVal: 32768,
expectError: false,
},
{
description: "grains on square 32",
input: 32,
expectedVal: 2147483648,
expectError: false,
},
{
description: "grains on square 64",
input: 64,
expectedVal: 9223372036854775808,
expectError: false,
},
{
description: "square 0 raises an exception",
input: 0,
expectedVal: 0,
expectError: true,
},
{
description: "negative square raises an exception",
input: -1,
expectedVal: 0,
expectError: true,
},
{
description: "square greater than 64 raises an exception",
input: 65,
expectedVal: 0,
expectError: true,
},
}