-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(challenge1): Enhance test coverage for stats
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
package main | ||
|
||
import "testing" | ||
|
||
func TestFormatStats(t *testing.T) { | ||
cases := []struct { | ||
Description string | ||
InputStats stats | ||
InputFilename string | ||
Want string | ||
}{ | ||
{"Empty", stats{bytes: 0, words: 0, lines: 0, chars: 0}, "", "0\t0\t0\t"}, | ||
{"Default", stats{bytes: 11, words: 2, lines: 1, chars: 0}, "filename", "1\t2\t11\tfilename"}, | ||
{"Chars", stats{bytes: 0, words: 0, lines: 0, chars: 100}, "filename", "100\tfilename"}, | ||
} | ||
|
||
for _, test := range cases { | ||
t.Run(test.Description, func(t *testing.T) { | ||
got := formatStats(true, true, true, true, test.InputStats, test.InputFilename) | ||
|
||
if got != test.Want { | ||
t.Errorf("got %v, want %v", got, test.Want) | ||
} | ||
}) | ||
} | ||
} |