Passed
Push — master ( 8b69c4...6c4303 )
by ertugrul
01:31 queued 36s
created

internal.getEveryTestData   A

Complexity

Conditions 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 21
dl 0
loc 27
rs 9.376
c 0
b 0
f 0
nop 0
1
package internal
2
3
import (
4
	"fmt"
5
	"reflect"
6
	"testing"
7
)
8
9
func TestEvery(t *testing.T) {
10
	testData := getEveryTestData()
11
	for _, test := range testData {
12
		a, erra := test.output, test.err
13
		b, errb := Every(test.inputValue1, test.inputValue2)
14
		if erra == nil {
15
			if !reflect.DeepEqual(a, b) || errb != nil {
16
				t.Errorf(errb.Error())
17
			}
18
		}
19
	}
20
}
21
22
func ExampleEvery() {
23
	data := []int64{-100, -5, 30, 100}
24
	// Input: [-100 -5 30 100]
25
	result, _ := Every(data, -100)
26
	fmt.Println(result)
27
	// Output: false
28
}
29
30
func getEveryTestData() map[string]struct {
31
	inputValue1 interface{}
32
	inputValue2 interface{}
33
	output      bool
34
	err         error
35
} {
36
37
	testData := map[string]struct {
38
		inputValue1 interface{}
39
		inputValue2 interface{}
40
		output      bool
41
		err         error
42
	}{
43
		"every_int": {
44
			inputValue1: []int64{-100, -5, 30, 100},
45
			inputValue2: -100,
46
			output:      false,
47
			err:         nil,
48
		},
49
		"every_int2": {
50
			inputValue1: []int64{-100, -100, -100},
51
			inputValue2: -100,
52
			output:      true,
53
			err:         nil,
54
		},
55
	}
56
	return testData
57
}
58