Skip to content

Commit 0dcd865

Browse files
committed
test(printif): add tests and solutions
1 parent 7d07ef2 commit 0dcd865

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

solutions/printif.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package solutions
2+
3+
func PrintIf(arg string) string {
4+
if len(arg) == 0 || len(arg) < 3 {
5+
return "Invalid Output\n"
6+
} else {
7+
return "G\n"
8+
}
9+
}

tests/printif_test/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
student "student"
5+
6+
"github.com/01-edu/go-tests/lib/challenge"
7+
"github.com/01-edu/go-tests/solutions"
8+
)
9+
10+
func main() {
11+
table := []string{"First78last", " ", " 280jsl", "he", "", "honey!", "Z", "email123@live.fr", "w45m$", "-552", "474abc", "<=>"}
12+
for _, s := range table {
13+
challenge.Function("PrintIf", student.PrintIf, solutions.PrintIf, s)
14+
}
15+
}

0 commit comments

Comments
 (0)