Skip to content

Commit 90ed378

Browse files
committed
Coverage
1 parent 273c5c7 commit 90ed378

4 files changed

Lines changed: 31 additions & 15 deletions

File tree

tests/Encryption/Base64Decode/Base64Decode_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import (
66
"github.com/serkanalgur/phpfuncs"
77
)
88

9+
func CoverCheck(t *testing.T, s, exp string) {
10+
if s != exp {
11+
t.Errorf("%q (expected: %q)", s, exp)
12+
}
13+
}
14+
915
// TestBase64Decode - Test for Encryption
1016
func TestBase64Decode(t *testing.T) {
1117
want := "Hello World"
12-
if got, _ := phpfuncs.Base64Decode("SGVsbG8gV29ybGQ="); got != want {
13-
t.Errorf("Base64Decode() = %v, want %v", got, want)
14-
}
18+
g, _ := phpfuncs.Base64Decode("SGVsbG8gV29ybGQ=")
19+
CoverCheck(t, g, want)
1520
}

tests/Encryption/Base64Encode/Base64Encode_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ import (
66
"github.com/serkanalgur/phpfuncs"
77
)
88

9+
func CoverCheck(t *testing.T, s, exp string) {
10+
if s != exp {
11+
t.Errorf("%q (expected: %q)", s, exp)
12+
}
13+
}
14+
915
// TestBase64Encode - Test for Encryption
1016
func TestBase64Encode(t *testing.T) {
1117
want := "SGVsbG8gV29ybGQ="
12-
if got := phpfuncs.Base64Encode("Hello World"); got != want {
13-
t.Errorf("Base64Encode() = %v, want %v", got, want)
14-
}
18+
CoverCheck(t,phpfuncs.Base64Encode("Hello World"),want)
1519
}

tests/Encryption/MD5/MD5_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import (
66
"github.com/serkanalgur/phpfuncs"
77
)
88

9+
func CoverCheck(t *testing.T, s, exp string) {
10+
if s != exp {
11+
t.Errorf("%q (expected: %q)", s, exp)
12+
}
13+
}
14+
15+
916
// TestMD5 - Test for Encryption
1017
func TestMD5(t *testing.T) {
1118
want := "b10a8db164e0754105b7a99be72e3fe5"
12-
if got := phpfuncs.MD5("Hello World"); got != want {
13-
t.Errorf("MD5() = %v, want %v", got, want)
14-
}
19+
CoverCheck(t,phpfuncs.MD5("Hello World"),want)
1520
}

tests/arrays/InArray_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ const TestWords = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
1111

1212
const needle = "est"
1313

14+
func CoverCheck(t *testing.T, s, exp bool) {
15+
if s != exp {
16+
t.Errorf("%v (expected: %v)", s, exp)
17+
}
18+
}
19+
1420
func TestInArrayString(t *testing.T) {
1521
want := true
1622
stack := strings.Split(TestWords, " ")
17-
if got := phpfuncs.InArray(needle, stack); got != want {
18-
t.Errorf("inArray() = %v, want %v", got, want)
19-
}
23+
CoverCheck(t,phpfuncs.InArray(needle, stack),want)
2024
}
2125

2226
func TestInArrrayInt(t *testing.T) {
2327
want := true
2428
var needle = 2
2529
stack := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
26-
if got := phpfuncs.InArray(needle, stack); got != want {
27-
t.Errorf("inArray() = %v, want %v", got, want)
28-
}
30+
CoverCheck(t,phpfuncs.InArray(needle, stack),want)
2931
}

0 commit comments

Comments
 (0)