Skip to content

Commit

Permalink
Boost coverage slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Oct 14, 2019
1 parent 5a05833 commit baf910b
Showing 1 changed file with 140 additions and 0 deletions.
140 changes: 140 additions & 0 deletions processor/formatters_test.go
Expand Up @@ -142,6 +142,146 @@ func TestSortSummaryFiles(t *testing.T) {
}
}

func TestSortLanguageSummaryName(t *testing.T) {
SortBy = "name"
ls := []LanguageSummary{
{
Name: "b",
Lines: 1,
},
{
Name: "a",
Lines: 1,
},
}

ls = sortLanguageSummary(ls)

if ls[0].Name != "a" {
t.Error("Expected a to be first")
}
}

func TestSortLanguageSummaryLine(t *testing.T) {
SortBy = "line"
ls := []LanguageSummary{
{
Name: "a",
Lines: 1,
},
{
Name: "b",
Lines: 1,
},
{
Name: "c",
Lines: 2,
},
}

ls = sortLanguageSummary(ls)

if ls[0].Name != "c" || ls[1].Name != "a" {
t.Error("Expected c to be first and a second")
}
}

func TestSortLanguageSummaryBlank(t *testing.T) {
SortBy = "blank"
ls := []LanguageSummary{
{
Name: "a",
Blank: 1,
},
{
Name: "b",
Blank: 1,
},
{
Name: "c",
Blank: 2,
},
}

ls = sortLanguageSummary(ls)

if ls[0].Name != "c" || ls[1].Name != "a" {
t.Error("Expected c to be first and a second")
}
}

func TestSortLanguageSummaryCode(t *testing.T) {
SortBy = "code"
ls := []LanguageSummary{
{
Name: "a",
Code: 1,
},
{
Name: "b",
Code: 1,
},
{
Name: "c",
Code: 2,
},
}

ls = sortLanguageSummary(ls)

if ls[0].Name != "c" || ls[1].Name != "a" {
t.Error("Expected c to be first and a second")
}
}

func TestSortLanguageSummaryComment(t *testing.T) {
SortBy = "comment"
ls := []LanguageSummary{
{
Name: "a",
Comment: 1,
},
{
Name: "b",
Comment: 1,
},
{
Name: "c",
Comment: 2,
},
}

ls = sortLanguageSummary(ls)

if ls[0].Name != "c" || ls[1].Name != "a" {
t.Error("Expected c to be first and a second")
}
}

func TestSortLanguageSummaryComplexity(t *testing.T) {
SortBy = "complexity"
ls := []LanguageSummary{
{
Name: "a",
Complexity: 1,
},
{
Name: "b",
Complexity: 1,
},
{
Name: "c",
Complexity: 2,
},
}

ls = sortLanguageSummary(ls)

if ls[0].Name != "c" || ls[1].Name != "a" {
t.Error("Expected c to be first and a second")
}
}

func TestToJSONEmpty(t *testing.T) {
inputChan := make(chan *FileJob, 1000)
close(inputChan)
Expand Down

0 comments on commit baf910b

Please sign in to comment.