1package interactors 2 3import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7) 8 9func TestDistinctValues(t *testing.T) { 10 s1 := []string{ 11 "v1", 12 "v2", 13 "v3", 14 "v4", 15 // "v5", 16 } 17 s2 := []string{ 18 // "v1", 19 "v2", 20 // "v3", 21 "v4", 22 "v5", 23 } 24 expectedDiff := []string{ 25 "v1", 26 "v3", 27 "v5", 28 } 29 diff := DistinctValues(s1, s2) 30 assert.Equal(t, expectedDiff, diff, "Output differential of s1 and s2") 31} 32 33func TestDistinctValuesEmpty(t *testing.T) { 34 var s1 []string 35 var s2 []string 36 37 diff := DistinctValues(s1, s2) 38 assert.Equal(t, 0, len(diff), "Output differential of s1 and s2") 39} 40 41func TestDistinctValuesDuplicates(t *testing.T) { 42 s1 := []string{} 43 s2 := []string{ 44 "v1", 45 "v1", 46 "v1", 47 } 48 expectedDiff := []string{ 49 "v1", 50 } 51 diff := DistinctValues(s1, s2) 52 assert.Equal(t, expectedDiff, diff, "Output differential of s1 and s2") 53} 54 55func TestSetSubtract(t *testing.T) { 56 s1 := []string{ 57 "v1", 58 "v2", 59 "v3", 60 } 61 s2 := []string{ 62 "v2", 63 "v3", 64 "v4", 65 } 66 expected := []string{ 67 "v1", 68 } 69 diff := SetSubtract(s1, s2) 70 assert.Equal(t, expected, diff, "Discard of s2 from s1") 71} 72 73func TestSetUnion(t *testing.T) { 74 s1 := []string{ 75 "v1", 76 "v2", 77 "v3", 78 } 79 s2 := []string{ 80 "v2", 81 "v3", 82 "v4", 83 } 84 expected := []string{ 85 "v1", 86 "v2", 87 "v3", 88 "v4", 89 } 90 union := SetUnion(s1, s2) 91 assert.Equal(t, expected, union, "Union of s2 and s1") 92} 93 94func TestFilterNoUnicodeWithUnicode(t *testing.T) { 95 regressionStr := "Move to AGP 3.0.0 stable " 96 assert.Equal( 97 t, 98 "Move to AGP 3.0.0 stable ", 99 FilterNoUnicode(regressionStr), 100 "Function should filter out unicode characters", 101 ) 102} 103 104func TestFilterNoUnicodeWithNoUnicode(t *testing.T) { 105 validStr := "I'm a regular string with no whacky unicode chars" 106 assert.Equal( 107 t, 108 validStr, 109 FilterNoUnicode(validStr), 110 "No change should occur", 111 ) 112} 113