Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Added tests for negative offsets or larger widths / heights than tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-ward committed Apr 12, 2018
1 parent 240f478 commit 8df384c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Binary file added test_data/output/test_expand.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test_data/output/test_negative_xOff.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions tilemerge_test.go
Expand Up @@ -189,6 +189,26 @@ func Test_Merge_xOff(t *testing.T) {
verifyJPG(t, img, "test_data/output/test_xOff.jpg")
}

func Test_Merge_negative_xOff(t *testing.T) {
tiles := jpgTiles()
xOff := -100
yOff := 0
width := 2 * TILE_SIZE
height := 2*TILE_SIZE - yOff

img, err := Merge(tiles, xOff, yOff, width, height, nil)
if err != nil {
panic(err)
}

if *update {
exportJPG(img, "test_data/output/test_negative_xOff.jpg")
}

verifyDimensions(t, img, width, height)
verifyJPG(t, img, "test_data/output/test_negative_xOff.jpg")
}

func Test_Merge_yOff(t *testing.T) {
tiles := jpgTiles()
xOff := 0
Expand Down Expand Up @@ -310,6 +330,27 @@ func Test_Merge_crop(t *testing.T) {
verifyJPG(t, img, "test_data/output/test_crop.jpg")
}

// Request a larger image than we have tiles to fill it
func Test_Merge_expand(t *testing.T) {
tiles := jpgTiles()
xOff := -100
yOff := -50
width := 2*TILE_SIZE + 175 // should extend 75 px to the right of tiles
height := 2*TILE_SIZE + 175 // should expand 125 px to the bottom of tiles

img, err := Merge(tiles, xOff, yOff, width, height, nil)
if err != nil {
panic(err)
}

if *update {
exportJPG(img, "test_data/output/test_expand.jpg")
}

verifyDimensions(t, img, width, height)
verifyJPG(t, img, "test_data/output/test_expand.jpg")
}

func Test_Merge_Missing_Tile(t *testing.T) {
tiles := jpgTiles()
// remove a tile's data
Expand Down

0 comments on commit 8df384c

Please sign in to comment.