-
Notifications
You must be signed in to change notification settings - Fork 1
/
hord_test.go
52 lines (47 loc) · 1.23 KB
/
hord_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
package hord
import (
"testing"
)
// TestValidations brought to you buy ChatGPT
func TestValidations(t *testing.T) {
t.Run("ValidKey", func(t *testing.T) {
// Valid keys
validKeys := []string{"key1", "KEY_2", "3_key", "KEY-4", "key_5"}
for _, key := range validKeys {
err := ValidKey(key)
if err != nil {
t.Errorf("ValidKey(%s) returned error: %s, expected nil", key, err)
}
}
})
t.Run("InvalidKey", func(t *testing.T) {
// Invalid keys
invalidKeys := []string{""}
for _, key := range invalidKeys {
err := ValidKey(key)
if err != ErrInvalidKey {
t.Errorf("ValidKey(%s) returned error: %s, expected ErrInvalidKey", key, err)
}
}
})
t.Run("ValidData", func(t *testing.T) {
// Valid data
validData := [][]byte{{0x01}, {0x01, 0x02, 0x03}, {0xFF}}
for _, data := range validData {
err := ValidData(data)
if err != nil {
t.Errorf("ValidData(%v) returned error: %s, expected nil", data, err)
}
}
})
t.Run("InvalidData", func(t *testing.T) {
// Invalid data
invalidData := [][]byte{nil, {}}
for _, data := range invalidData {
err := ValidData(data)
if err != ErrInvalidData {
t.Errorf("ValidData(%v) returned error: %s, expected ErrInvalidData", data, err)
}
}
})
}