Skip to content

Commit 49cf6bd

Browse files
committed
xcollection and xfiles
1 parent 5039539 commit 49cf6bd

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

xcollection/xcollection_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"testing"
66
)
77

8-
func TestStringExtractions(t *testing.T) {
8+
func TestStringBoolMapKeys(t *testing.T) {
99

1010
keys := StringBoolMapKeys(map[string]bool{
1111
"qwe": true,
1212
"123": true,
1313
})
1414

1515
assert.Equal(t, 2, len(keys))
16-
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
1
2+
2
3+
3
4+
5+
6+
4
7+
4
8+
9+
10+
5
11+
12+
6

xfiles/xfiles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// ReadDistinctFileLines - Read text file lines as slice without empty and duplicates
1111
func ReadDistinctFileLines(path string)([]string, error) {
12-
var linesMap map[string]bool
12+
var linesMap = make(map[string]bool)
1313

1414
file, err := os.Open(path)
1515
if err != nil {

xfiles/xfiles_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package xfiles
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"testing"
6+
)
7+
8+
func TestFileLinesExtraction(t *testing.T) {
9+
lines, err := ReadDistinctFileLines("distinct_file_lines_test.txt")
10+
if err != nil {
11+
panic(err)
12+
}
13+
assert.Equal(t, 6, len(lines))
14+
}

0 commit comments

Comments
 (0)