Skip to content

Commit

Permalink
tests for ToImageMagickSpec()
Browse files Browse the repository at this point in the history
  • Loading branch information
thraxil committed Jul 23, 2017
1 parent 73f8c38 commit e4fe93a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions resize_test.go
Expand Up @@ -11,6 +11,7 @@ type SizeSpecTestCase struct {
Square bool
ExpectedWidth int
ExpectedHeight int
ExpectedIM string
}

func Test_MakeSizeSpec(t *testing.T) {
Expand All @@ -21,55 +22,66 @@ func Test_MakeSizeSpec(t *testing.T) {
Square: true,
ExpectedWidth: 100,
ExpectedHeight: 100,
ExpectedIM: "100x100^",
},
{
SizeSpecString: "100w",
Full: false,
Square: false,
ExpectedWidth: 100,
ExpectedHeight: -1,
ExpectedIM: "100",
},
{
SizeSpecString: "100h",
Full: false,
Square: false,
ExpectedWidth: -1,
ExpectedHeight: 100,
ExpectedIM: "x100",
},
{
SizeSpecString: "100h200w",
Full: false,
Square: false,
ExpectedWidth: 200,
ExpectedHeight: 100,
ExpectedIM: "200x100",
},
{
SizeSpecString: "200w100h",
Full: false,
Square: false,
ExpectedWidth: 200,
ExpectedHeight: 100,
ExpectedIM: "200x100",
},
{
SizeSpecString: "100w200h",
Full: false,
Square: false,
ExpectedWidth: 100,
ExpectedHeight: 200,
ExpectedIM: "100x200",
},
{
SizeSpecString: "200h100w",
Full: false,
Square: false,
ExpectedWidth: 100,
ExpectedHeight: 200,
ExpectedIM: "100x200",
},
{
SizeSpecString: "full",
Full: true,
Square: false,
ExpectedWidth: -1,
ExpectedHeight: -1,
// this is not actually right
// current clients just don't call this
// on 'full'
ExpectedIM: "x-1",
},
}

Expand Down Expand Up @@ -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())
}
}

}
Expand Down

0 comments on commit e4fe93a

Please sign in to comment.