From ce58e76ba943644512057dc3ee1fc7f61d689fa4 Mon Sep 17 00:00:00 2001 From: Rafael Passos Date: Fri, 26 Apr 2019 13:06:44 -0300 Subject: [PATCH] tests for openImageFromPath helper --- examples/stego_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/stego_test.go diff --git a/examples/stego_test.go b/examples/stego_test.go new file mode 100644 index 0000000..0d0133f --- /dev/null +++ b/examples/stego_test.go @@ -0,0 +1,31 @@ +package main + +import ( + "image" + "log" + "testing" +) + +var rawInputFile = "./stegosaurus.png" +var encodedInputFile = "./encoded_stegosaurus.png" + +func TestOpenImageFromPath(t *testing.T) { + img, err := OpenImageFromPath(rawInputFile) + if err != nil { + log.Printf("Error opening or Decoding file %s: %v", rawInputFile, err) + t.FailNow() + } + if (img.Bounds().Bounds() != image.Rectangle{image.Point{0, 0}, image.Point{1195, 642}}) { + log.Printf("Image has wrong size") + t.FailNow() + + } +} + +func TestEmptyPathHelperFunction(t *testing.T) { + _, err := OpenImageFromPath(" ") + if err == nil { + log.Print("Empty path given, err could not be nil.") + t.FailNow() + } +}