File: strings_test.go

package info (click to toggle)
android-platform-tools 34.0.5-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 150,900 kB
  • sloc: cpp: 805,786; java: 293,500; ansic: 128,288; xml: 127,491; python: 41,481; sh: 14,245; javascript: 9,665; cs: 3,846; asm: 2,049; makefile: 1,917; yacc: 440; awk: 368; ruby: 183; sql: 140; perl: 88; lex: 67
file content (112 lines) | stat: -rw-r--r-- 1,826 bytes parent folder | download | duplicates (5)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package interactors

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDistinctValues(t *testing.T) {
	s1 := []string{
		"v1",
		"v2",
		"v3",
		"v4",
		// "v5",
	}
	s2 := []string{
		// "v1",
		"v2",
		// "v3",
		"v4",
		"v5",
	}
	expectedDiff := []string{
		"v1",
		"v3",
		"v5",
	}
	diff := DistinctValues(s1, s2)
	assert.Equal(t, expectedDiff, diff, "Output differential of s1 and s2")
}

func TestDistinctValuesEmpty(t *testing.T) {
	var s1 []string
	var s2 []string

	diff := DistinctValues(s1, s2)
	assert.Equal(t, 0, len(diff), "Output differential of s1 and s2")
}

func TestDistinctValuesDuplicates(t *testing.T) {
	s1 := []string{}
	s2 := []string{
		"v1",
		"v1",
		"v1",
	}
	expectedDiff := []string{
		"v1",
	}
	diff := DistinctValues(s1, s2)
	assert.Equal(t, expectedDiff, diff, "Output differential of s1 and s2")
}

func TestSetSubtract(t *testing.T) {
	s1 := []string{
		"v1",
		"v2",
		"v3",
	}
	s2 := []string{
		"v2",
		"v3",
		"v4",
	}
	expected := []string{
		"v1",
	}
	diff := SetSubtract(s1, s2)
	assert.Equal(t, expected, diff, "Discard of s2 from s1")
}

func TestSetUnion(t *testing.T) {
	s1 := []string{
		"v1",
		"v2",
		"v3",
	}
	s2 := []string{
		"v2",
		"v3",
		"v4",
	}
	expected := []string{
		"v1",
		"v2",
		"v3",
		"v4",
	}
	union := SetUnion(s1, s2)
	assert.Equal(t, expected, union, "Union of s2 and s1")
}

func TestFilterNoUnicodeWithUnicode(t *testing.T) {
	regressionStr := "Move to AGP 3.0.0 stable 😁"
	assert.Equal(
		t,
		"Move to AGP 3.0.0 stable ",
		FilterNoUnicode(regressionStr),
		"Function should filter out unicode characters",
	)
}

func TestFilterNoUnicodeWithNoUnicode(t *testing.T) {
	validStr := "I'm a regular string with no whacky unicode chars"
	assert.Equal(
		t,
		validStr,
		FilterNoUnicode(validStr),
		"No change should occur",
	)
}