aboutsummaryrefslogtreecommitdiff
path: root/Unicorn_test.go
diff options
context:
space:
mode:
authorMartin Ashby <martin@martin-laptop.lan>2018-05-21 10:16:32 +0100
committerMartin Ashby <martin@martin-laptop.lan>2018-05-21 10:16:32 +0100
commitb1c8a696e4e40ea1ae72f886e0cfb4468eb737e8 (patch)
tree6342f364a3f611ea2d642dccc862f23108e90e44 /Unicorn_test.go
parent34f1a11454fc38a77338569f466df879fd1792f7 (diff)
downloadunicornpaint-b1c8a696e4e40ea1ae72f886e0cfb4468eb737e8.tar.gz
unicornpaint-b1c8a696e4e40ea1ae72f886e0cfb4468eb737e8.tar.bz2
unicornpaint-b1c8a696e4e40ea1ae72f886e0cfb4468eb737e8.tar.xz
unicornpaint-b1c8a696e4e40ea1ae72f886e0cfb4468eb737e8.zip
Moved unicorn to it's own package
Diffstat (limited to 'Unicorn_test.go')
-rw-r--r--Unicorn_test.go80
1 files changed, 0 insertions, 80 deletions
diff --git a/Unicorn_test.go b/Unicorn_test.go
deleted file mode 100644
index 4b06a73..0000000
--- a/Unicorn_test.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package main
-
-import (
- "reflect"
- "testing"
- "time"
-)
-
-func TestGetUnicorn(t *testing.T) {
-
-}
-
-func TestFakeUnicorn(t *testing.T) {
- unicorn, err := NewFake(uint8(16), uint8(16))
- if err != nil {
- t.Errorf("Got an error making a fake unicorn, shouldn't happen")
- }
- defer unicorn.Close()
-
- // Check simple functions
- if unicorn.GetHeight() != 16 {
- t.Errorf("Height was wrong, expecting 16")
- }
- if unicorn.GetWidth() != 16 {
- t.Errorf("Width was wrong, expecting 16")
- }
- // Pixels should be black to start with
- pixels := unicorn.GetPixels()
- for x := uint8(0); x < 16; x++ {
- for y := uint8(0); y < 16; y++ {
- if !reflect.DeepEqual(pixels[x][y], []uint8{0, 0, 0}) {
- t.Errorf("Expecting black pixels to start with")
- }
- }
- }
-
- // Should be able to set a pixel, no others should change
- unicorn.SetPixel(0, 0, uint8(255), uint8(255), uint8(255))
- pixels = unicorn.GetPixels()
- if !reflect.DeepEqual(pixels[0][0], []uint8{255, 255, 255}) {
- t.Errorf("Pixel wasn't set when it should be")
- }
- for x := uint8(0); x < 16; x++ {
- for y := uint8(0); y < 16; y++ {
- if x == 0 && y == 0 {
- continue
- }
- if !reflect.DeepEqual(pixels[x][y], []uint8{0, 0, 0}) {
- t.Errorf("Expecting black pixels to start with")
- }
- }
- }
-
- // Should be able to set a second pixel
- unicorn.SetPixel(3, 4, uint8(4), uint8(5), uint8(6))
- pixels = unicorn.GetPixels()
- for x := uint8(0); x < 16; x++ {
- for y := uint8(0); y < 16; y++ {
- checkcolor := []uint8{0, 0, 0}
- if x == 0 && y == 0 {
- checkcolor = []uint8{255, 255, 255}
- } else if x == 3 && y == 4 {
- checkcolor = []uint8{4, 5, 6}
- }
- if !reflect.DeepEqual(pixels[x][y], checkcolor) {
- t.Errorf("Got incorrect pixel color at %d %d", x, y)
- }
- }
- }
-
- unicorn.Show()
- time.Sleep(time.Duration(500) * time.Millisecond)
- unicorn.SetPixel(10, 10, uint8(255), uint8(255), uint8(0))
- unicorn.Show()
- time.Sleep(time.Duration(500) * time.Millisecond)
-
- unicorn.SetPixel(0, 15, uint8(255), uint8(0), uint8(0))
- unicorn.Show()
- time.Sleep(time.Duration(500) * time.Millisecond)
-}