Skip to content

Commit

Permalink
Add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Dec 19, 2021
1 parent b1d8708 commit f9f788a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions internal/local_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package internal

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
)

func TestHasSuffix(t *testing.T) {
tests := []struct {
filename string
suffix string
want bool
}{
{
filename: "a/b/core/Test.class",
suffix: "core/Test.class",
want: true,
},
{
filename: "a/b/core/test.class",
suffix: "core/Test.class",
want: true,
},
{
filename: "a/b/core/Test.class",
suffix: "core/test.class",
want: true,
},
{
filename: "a/b/corex/Test.class",
suffix: "core/test.class",
want: false,
},
{
filename: "a/b/core/Test.classx",
suffix: "core/test.class",
want: false,
},
}

for i, test := range tests {
t.Run(fmt.Sprintf("Test-%d", i), func(t *testing.T) {
assert.Equal(t, test.want, hasSuffix(test.filename, test.suffix))
})
}
}

0 comments on commit f9f788a

Please sign in to comment.