feat: add even number problem
parent
0df7a369b7
commit
cb7b3d0ed6
|
@ -17,4 +17,4 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test
|
||||
run: go test -race -v -bench=. ./...
|
||||
run: go test -race -v ./...
|
||||
|
|
|
@ -3,4 +3,3 @@ package camelcase
|
|||
func Camelcase(s string) string {
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package even
|
||||
|
||||
func isEven(n int) bool {
|
||||
return n%2 == 0
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package even
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEven(t *testing.T) {
|
||||
suite := map[int]bool{
|
||||
2: true,
|
||||
1: false,
|
||||
824: true,
|
||||
200: true,
|
||||
52: true,
|
||||
1785616589187: false,
|
||||
0: true,
|
||||
100000000000000000: true,
|
||||
}
|
||||
|
||||
for k, v := range suite {
|
||||
if output := isEven(k); output != v {
|
||||
t.Errorf("input: %d - expected: %v, got: %v", k, v, output)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
Given a number N, return a boolean that tells whether N is a even number or not.
|
||||
|
||||
Example:
|
||||
|
||||
isEven(2) = true
|
||||
isEven(7) = false
|
Loading…
Reference in New Issue