simplify data.go and tests

remove unecessary string casting, and simplify duplicate tests.  Also
don't use struct literals for test values.
This commit is contained in:
Will Norris 2019-10-13 19:28:22 -07:00
parent 3b850734af
commit c0a97f6742
2 changed files with 16 additions and 26 deletions

14
data.go
View file

@ -99,7 +99,7 @@ func (o Options) String() string {
opts = append(opts, optFit)
}
if o.Rotate != 0 {
opts = append(opts, fmt.Sprintf("%s%d", string(optRotatePrefix), o.Rotate))
opts = append(opts, fmt.Sprintf("%s%d", optRotatePrefix, o.Rotate))
}
if o.FlipVertical {
opts = append(opts, optFlipVertical)
@ -108,10 +108,10 @@ func (o Options) String() string {
opts = append(opts, optFlipHorizontal)
}
if o.Quality != 0 {
opts = append(opts, fmt.Sprintf("%s%d", string(optQualityPrefix), o.Quality))
opts = append(opts, fmt.Sprintf("%s%d", optQualityPrefix, o.Quality))
}
if o.Signature != "" {
opts = append(opts, fmt.Sprintf("%s%s", string(optSignaturePrefix), o.Signature))
opts = append(opts, fmt.Sprintf("%s%s", optSignaturePrefix, o.Signature))
}
if o.ScaleUp {
opts = append(opts, optScaleUp)
@ -120,16 +120,16 @@ func (o Options) String() string {
opts = append(opts, o.Format)
}
if o.CropX != 0 {
opts = append(opts, fmt.Sprintf("%s%v", string(optCropX), o.CropX))
opts = append(opts, fmt.Sprintf("%s%v", optCropX, o.CropX))
}
if o.CropY != 0 {
opts = append(opts, fmt.Sprintf("%s%v", string(optCropY), o.CropY))
opts = append(opts, fmt.Sprintf("%s%v", optCropY, o.CropY))
}
if o.CropWidth != 0 {
opts = append(opts, fmt.Sprintf("%s%v", string(optCropWidth), o.CropWidth))
opts = append(opts, fmt.Sprintf("%s%v", optCropWidth, o.CropWidth))
}
if o.CropHeight != 0 {
opts = append(opts, fmt.Sprintf("%s%v", string(optCropHeight), o.CropHeight))
opts = append(opts, fmt.Sprintf("%s%v", optCropHeight, o.CropHeight))
}
if o.SmartCrop {
opts = append(opts, optSmartCrop)