-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharithmetic_progression_test.go
More file actions
40 lines (34 loc) · 1017 Bytes
/
arithmetic_progression_test.go
File metadata and controls
40 lines (34 loc) · 1017 Bytes
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
// Simple implementation tests
// :PROPERTIES:
// :header-args:go+: :tangle arithmetic_progression_test.go
// :END:
// Lets write some tests
// [[file:README.org::*Simple implementation tests][Simple implementation tests:1]]
package main
import (
"testing"
)
func TestIsArithmeticProgression(t *testing.T) {
testCases := []struct {
name string
input []int
expected bool
}{
{"Example 1 - Valid progression", []int{3, 5, 1}, true},
{"Example 2 - Invalid progression", []int{1, 2, 4}, false},
{"Empty array", []int{}, true},
{"Single element", []int{5}, true},
{"Two elements", []int{1, 2}, true},
{"Negative numbers", []int{-3, -1, 1}, true},
{"Same numbers", []int{2, 2, 2, 2}, true},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := isArithmeticProgression(tc.input)
if result != tc.expected {
t.Errorf("isArithmeticProgression(%v) = %v; want %v", tc.input, result, tc.expected)
}
})
}
}
// Simple implementation tests:1 ends here