This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv_non_unique_test.go
73 lines (70 loc) · 1.98 KB
/
csv_non_unique_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package slices
import (
"testing"
)
func TestCommaSeparatedValuesList_Add(t *testing.T) {
var csvl CommaSeparatedValuesList
if csvl = csvl.Add("v1"); csvl != "v1" {
t.Error("unexpected: " + csvl)
}
if csvl = csvl.Add("v3"); csvl != "v1,v3" {
t.Error("unexpected")
}
if csvl = csvl.Add("v2"); csvl != "v1,v3,v2" {
t.Error("unexpected")
}
}
func TestCommaSeparatedValuesList_Remove(t *testing.T) {
var csvl CommaSeparatedValuesList
csvl = CommaSeparatedValuesList("")
if csvl = csvl.Remove("v1"); csvl != "" {
t.Error("unexpected: " + csvl)
}
csvl = CommaSeparatedValuesList("v1")
if csvl = csvl.Remove("v1"); csvl != "" {
t.Error("unexpected: " + csvl)
}
csvl = CommaSeparatedValuesList("v2")
if csvl = csvl.Remove("v1"); csvl != "v2" {
t.Error("unexpected: " + csvl)
}
csvl = CommaSeparatedValuesList("v1,v3,v2,v4")
if csvl = csvl.Remove("v1"); csvl != "v3,v2,v4" {
t.Error("unexpected: " + csvl)
}
csvl = CommaSeparatedValuesList("v1,v3,v2,v4")
if csvl = csvl.Remove("v2"); csvl != "v1,v3,v4" {
t.Error("unexpected: " + csvl)
}
csvl = CommaSeparatedValuesList("v1,v3,v2,v4")
if csvl = csvl.Remove("v3"); csvl != "v1,v2,v4" {
t.Error("unexpected: " + csvl)
}
csvl = CommaSeparatedValuesList("v1,v3,v2,v4")
if csvl = csvl.Remove("v4"); csvl != "v1,v3,v2" {
t.Error("unexpected: " + csvl)
}
}
func TestCommaSeparatedValuesList_Contains(t *testing.T) {
if CommaSeparatedValuesList("").Contains("v1") {
t.Error("unexpected true")
}
if !CommaSeparatedValuesList("v1").Contains("v1") {
t.Error("unexpected false")
}
if !CommaSeparatedValuesList("v1,v2").Contains("v1") {
t.Error("unexpected false")
}
if !CommaSeparatedValuesList("v1,v2").Contains("v2") {
t.Error("unexpected false")
}
if !CommaSeparatedValuesList("v1,v2,v3").Contains("v1") {
t.Error("unexpected false")
}
if !CommaSeparatedValuesList("v1,v2,v3").Contains("v2") {
t.Error("unexpected false")
}
if !CommaSeparatedValuesList("v1,v2,v3").Contains("v3") {
t.Error("unexpected false")
}
}