Skip to content

Commit

Permalink
feat(unit-test): test that tabs and spaces are removed from lines cor…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
logan-bobo committed Feb 13, 2024
1 parent 648180b commit 026247f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func stripTabAndSpaceFromLine(text string) []string {
flatWords = append(flatWords, word)
}
}

return flatWords
}

Expand Down
15 changes: 15 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,18 @@ func TestCharCount(t *testing.T) {
t.Logf("countChars(%s), PASSED.\n", testFile)
}
}

func TestStripTabandSpaceFromLine(t *testing.T) {
line := "hello world. today."
outputSlice := []string{"hello", "world.", "today."}

stripLine := stripTabAndSpaceFromLine(line)

isEqual := reflect.DeepEqual(outputSlice, stripLine)

if isEqual != true {
t.Errorf("stripTabAndSpaceFromLine(%s), FAILED. Expected %v got %v \n", line, outputSlice, stripLine)
} else {
t.Logf("stripTabAndSpaceFromLine(%s), PASSED.\n", line)
}
}

0 comments on commit 026247f

Please sign in to comment.