Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Aug 23, 2024
1 parent 748ce2b commit c0eaf4b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions fxgl-core/src/test/kotlin/com/almasb/fxgl/texture/ImagesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,32 @@ class ImagesTest {
assertThat(result[11], `is`(img2))
assertThat(result[22], `is`(img3))
}

@Test
fun `Compare two images`() {
var img1 = ColoredTexture(100, 100, Color.WHITE)
.superTexture(ColoredTexture(100, 100, Color.BLACK), HorizontalDirection.RIGHT)
.image

var img2 = ColoredTexture(100, 100, Color.WHITE)
.superTexture(ColoredTexture(100, 100, Color.RED), HorizontalDirection.RIGHT)
.image

var result = img1.compareStrict(img2)

assertThat(result, `is`(0.5))

// compare identical
img1 = ColoredTexture(100, 100, Color.WHITE).image
img2 = ColoredTexture(100, 100, Color.WHITE).image
result = img1.compareStrict(img2)

assertThat(result, `is`(1.0))

// compare different sizes
img2 = ColoredTexture(100, 50, Color.WHITE).image
result = img1.compareStrict(img2)

assertThat(result, `is`(0.0))
}
}

0 comments on commit c0eaf4b

Please sign in to comment.