-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoublons8_test.go
49 lines (42 loc) · 1.16 KB
/
doublons8_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
package doublons8
import "testing"
func Test1(t *testing.T) {
if doublons([]int{2, 1, 3, 5, 6}) {
t.Fail()
}
}
func Test2(t *testing.T) {
if !doublons([]int{6, 4, 4, 6, 5, 5}) {
t.Fail()
}
}
// Ajoutés après le test
type test struct {
tab []int
ok bool
}
var testSet []test = []test{
{tab: []int{1, 2, 3, 5, 6}, ok: false},
{tab: []int{2, 3, 4, 5, 6}, ok: true},
{tab: []int{6, 3, 4, 5, 2}, ok: true},
{tab: []int{3}, ok: true},
{tab: []int{-2, -3, -4}, ok: true},
{tab: []int{-4, -3, -2}, ok: true},
{tab: []int{-4, -3, -2, -1, 0, 1, 2}, ok: true},
{tab: []int{-4, -3, -1, -1, 0, 1, 2}, ok: false},
{tab: []int{1, 2, 3, 4, 5, 5, 6}, ok: false},
{tab: []int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6}, ok: false},
{tab: []int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6}, ok: true},
{tab: []int{6, 6, 6, 6}, ok: true},
{tab: []int{1, 2, 3, 1, 2, 3}, ok: true},
{tab: []int{1, 2, 3, 2, 1, 2, 1, 3, 3}, ok: true},
{tab: []int{1, 2, 3, 2, 1, 2, 1, 2, 3, 3, 2, 1, 1, 3}, ok: false},
}
func TestGeneral(t *testing.T) {
for numTest, aTester := range testSet {
ok := doublons(aTester.tab)
if aTester.ok != ok {
t.Error("Erreur sur l'entrée", numTest, "de testSet")
}
}
}