-
Notifications
You must be signed in to change notification settings - Fork 4
/
number_test.go
47 lines (37 loc) · 1.04 KB
/
number_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
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT
package assert
import "testing"
func TestAssertion_Length_NotLength(t *testing.T) {
a := New(t, false)
a.Length(nil, 0)
a.Length([]int{1, 2}, 2)
a.Length([3]int{1, 2, 3}, 3)
a.NotLength([3]int{1, 2, 3}, 2)
a.Length(map[string]string{"1": "1", "2": "2"}, 2)
a.NotLength(map[string]string{"1": "1", "2": "2"}, 3)
slices := []rune{'a', 'b', 'c'}
ps := &slices
pps := &ps
a.Length(pps, 3)
a.NotLength(pps, 2)
a.Length("string", 6)
a.NotLength("string", 4)
}
func TestAssertion_Greater_Less(t *testing.T) {
a := New(t, false)
a.Greater(uint16(5), 3).Less(uint8(5), 6).GreaterEqual(uint64(5), 5).LessEqual(uint(5), 5)
}
func TestAssertion_Positive_Negative(t *testing.T) {
a := New(t, false)
a.Positive(float32(5)).Negative(float64(-5))
}
func TestAssertion_Between(t *testing.T) {
a := New(t, false)
a.Between(int8(5), 1, 6).
BetweenEqual(int16(5), 5, 6).
BetweenEqual(int32(6), 5, 6).
BetweenEqualMin(int64(5), 5, 6).
BetweenEqualMax(uint32(5), 4, 5)
}