From e4fe93a12666e44f7d55dad20472c93d72f86944 Mon Sep 17 00:00:00 2001 From: Anders Pearson Date: Sun, 23 Jul 2017 22:38:49 +0100 Subject: [PATCH] tests for ToImageMagickSpec() --- resize_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resize_test.go b/resize_test.go index 5d1ea78..358883e 100644 --- a/resize_test.go +++ b/resize_test.go @@ -11,6 +11,7 @@ type SizeSpecTestCase struct { Square bool ExpectedWidth int ExpectedHeight int + ExpectedIM string } func Test_MakeSizeSpec(t *testing.T) { @@ -21,6 +22,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: true, ExpectedWidth: 100, ExpectedHeight: 100, + ExpectedIM: "100x100^", }, { SizeSpecString: "100w", @@ -28,6 +30,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: 100, ExpectedHeight: -1, + ExpectedIM: "100", }, { SizeSpecString: "100h", @@ -35,6 +38,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: -1, ExpectedHeight: 100, + ExpectedIM: "x100", }, { SizeSpecString: "100h200w", @@ -42,6 +46,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: 200, ExpectedHeight: 100, + ExpectedIM: "200x100", }, { SizeSpecString: "200w100h", @@ -49,6 +54,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: 200, ExpectedHeight: 100, + ExpectedIM: "200x100", }, { SizeSpecString: "100w200h", @@ -56,6 +62,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: 100, ExpectedHeight: 200, + ExpectedIM: "100x200", }, { SizeSpecString: "200h100w", @@ -63,6 +70,7 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: 100, ExpectedHeight: 200, + ExpectedIM: "100x200", }, { SizeSpecString: "full", @@ -70,6 +78,10 @@ func Test_MakeSizeSpec(t *testing.T) { Square: false, ExpectedWidth: -1, ExpectedHeight: -1, + // this is not actually right + // current clients just don't call this + // on 'full' + ExpectedIM: "x-1", }, } @@ -112,6 +124,9 @@ func Test_MakeSizeSpec(t *testing.T) { if ss.String() != c.SizeSpecString && c.SizeSpecString != "100h200w" && c.SizeSpecString != "200h100w" { t.Error(c.SizeSpecString, "-- bad round trip on String()", ss.String()) } + if ss.ToImageMagickSpec() != c.ExpectedIM { + t.Error(c.SizeSpecString, "-- Bad ImageMagick Spec", ss.ToImageMagickSpec()) + } } }