-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpiet_test.go
42 lines (36 loc) · 932 Bytes
/
piet_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
package piet
import (
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"bytes"
"image"
"os"
"testing"
)
// Runs the first Hello World example from http://www.dangermouse.net/esoteric/piet/samples.html
func TestHelloWorld(t *testing.T) {
reader, _ := os.Open("testdata/Piet_hello.png")
m, _, _ := image.Decode(reader)
outputBuffer := &bytes.Buffer{}
i := New(m)
i.Writer = outputBuffer
i.Run()
output := outputBuffer.String()
if output != "Hello world!" {
t.Error("Incorrect output", output)
}
}
// Runs the "artistic" Hello World example from http://www.dangermouse.net/esoteric/piet/samples.html
func TestArtisticHelloWorld(t *testing.T) {
reader, _ := os.Open("testdata/artistic_hw.gif")
m, _, _ := image.Decode(reader)
outputBuffer := &bytes.Buffer{}
i := New(m)
i.Writer = outputBuffer
i.Run()
output := outputBuffer.String()
if output != "Hello, world!\n" {
t.Error("Incorrect output", output)
}
}