Initial commit
This commit is contained in:
5
internal/internal.go
Normal file
5
internal/internal.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package internal
|
||||
|
||||
func Add(a, b int) int {
|
||||
return a + b
|
||||
}
|
30
internal/internal_test.go
Normal file
30
internal/internal_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package internal_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.t-juice.club/torjus/peckertest/internal"
|
||||
)
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
var tc = []struct {
|
||||
A int
|
||||
B int
|
||||
Expected int
|
||||
}{
|
||||
{A: 1, B: 0, Expected: 1},
|
||||
{A: 1, B: 1, Expected: 2},
|
||||
{A: 1, B: -1, Expected: 0},
|
||||
}
|
||||
|
||||
for _, test := range tc {
|
||||
name := fmt.Sprintf("%d+%d", test.A, test.B)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
result := internal.Add(test.A, test.B)
|
||||
if result != test.Expected {
|
||||
t.Errorf("Got %d, expected %d", result, test.Expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user