mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-18 22:23:07 -03:00
Add counting mode, and only programming languages flags. (#110)
Signed-off-by: Zachary Romero <zacromero3@gmail.com>
This commit is contained in:
committed by
Denys Smirnov
parent
83cc32253e
commit
35d103b4e4
36
cmd/enry/main_test.go
Normal file
36
cmd/enry/main_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetLines(t *testing.T) {
|
||||
tests := []struct {
|
||||
content string
|
||||
wantTotal int
|
||||
wantNonBlank int
|
||||
}{
|
||||
// 0
|
||||
{content: "This is one line", wantTotal: 1, wantNonBlank: 1},
|
||||
// 1 Test no content
|
||||
{content: "", wantTotal: 0, wantNonBlank: 0},
|
||||
// 2 A single blank line
|
||||
{content: "One blank line\n\nTwo nonblank lines", wantTotal: 3, wantNonBlank: 2},
|
||||
// 3 Testing multiple blank lines in a row
|
||||
{content: "\n\n", wantTotal: 3, wantNonBlank: 0},
|
||||
// 4 '
|
||||
{content: "\n\n\n\n", wantTotal: 5, wantNonBlank: 0},
|
||||
// 5 Multiple blank lines content on ends
|
||||
{content: "content\n\n\n\ncontent", wantTotal: 5, wantNonBlank: 2},
|
||||
// 6 Content with blank lines on ends
|
||||
{content: "\n\n\ncontent\n\n\n", wantTotal: 7, wantNonBlank: 1},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
gotTotal, gotNonBlank := getLines([]byte(test.content))
|
||||
if gotTotal != test.wantTotal || gotNonBlank != test.wantNonBlank {
|
||||
t.Errorf("wrong line counts obtained for test case #%d:\n %7s, %7s\nGOT: %7d, %7d\nWANT: %7d, %7d\n", i, "TOTAL", "NON_BLANK",
|
||||
gotTotal, gotNonBlank, test.wantTotal, test.wantNonBlank)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user