| 12 | var emptyOptions = Options{} |
| 13 | |
| 14 | func TestOptions_String(t *testing.T) { |
| 15 | tests := []struct { |
| 16 | Options Options |
| 17 | String string |
| 18 | }{ |
| 19 | { |
| 20 | emptyOptions, |
| 21 | "0x0", |
| 22 | }, |
| 23 | { |
| 24 | Options{Width: 1, Height: 2, Fit: true, Rotate: 90, FlipVertical: true, FlipHorizontal: true, Quality: 80}, |
| 25 | "1x2,fh,fit,fv,q80,r90", |
| 26 | }, |
| 27 | { |
| 28 | Options{Width: 0.15, Height: 1.3, Rotate: 45, Quality: 95, Signature: "c0ffee", Format: "png"}, |
| 29 | "0.15x1.3,png,q95,r45,sc0ffee", |
| 30 | }, |
| 31 | { |
| 32 | Options{Width: 0.15, Height: 1.3, CropX: 100, CropY: 200}, |
| 33 | "0.15x1.3,cx100,cy200", |
| 34 | }, |
| 35 | { |
| 36 | Options{ScaleUp: true, CropX: 100, CropY: 200, CropWidth: 300, CropHeight: 400, SmartCrop: true}, |
| 37 | "0x0,ch400,cw300,cx100,cy200,sc,scaleUp", |
| 38 | }, |
| 39 | } |
| 40 | |
| 41 | for i, tt := range tests { |
| 42 | if got, want := tt.Options.String(), tt.String; got != want { |
| 43 | t.Errorf("%d. Options.String returned %v, want %v", i, got, want) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestParseOptions(t *testing.T) { |
| 49 | tests := []struct { |