-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs_test.go
68 lines (58 loc) · 1.25 KB
/
fs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"io/ioutil"
"os/exec"
"strings"
"testing"
)
func ReadTestFile(arg string) []string {
data, err := ioutil.ReadFile(arg)
if err != nil {
panic(err)
}
contentString := string(data)
contentSplit := strings.Split(contentString, "#")
return contentSplit
}
func TestAsciiArt(t *testing.T) {
testCases := []string{
"hello",
"HELLO",
"HeLlo HuMaN",
"1Hello 2There",
"Hello\\nThere",
"{Hello & There #}",
"hello There 1 to 2!",
"MaD3IrA&LiSboN",
"1a\"#FdwHywR&/()=",
"{|}~",
"[\\]^_ 'a",
"RGB",
":;<=>?@",
"\\!\" #$%&'()*+,-./",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"abcdefghijklmnopqrstuvwxyz",
"nice 2 meet you",
"It's Working",
}
banner := []string{
"standard",
"shadow",
"thinkertoy",
}
filename := []string{
"standardoutput.txt",
"shadowoutput.txt",
"thinkertoyoutput.txt",
}
for i := range banner {
expectedOutput := ReadTestFile(filename[i])
for index, testCase := range testCases {
cmd := exec.Command("go", "run", ".", testCase, banner[i])
output, _ := cmd.Output()
if string(output) != expectedOutput[index] {
t.Errorf("\nTest fails when given case:\n\t\"%s\","+"\nThe test should show:\n%s\nInstead it shows:\n%s", testCase, expectedOutput[index], output)
}
}
}
}