Skip to content

Commit

Permalink
test(challenge1): Enhance test coverage for stats
Browse files Browse the repository at this point in the history
  • Loading branch information
salma2vec committed Mar 4, 2024
1 parent 719fe49 commit de24f6e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions challenge1/stats_test.go
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)
}
})
}
}

0 comments on commit de24f6e

Please sign in to comment.