Skip to content

Commit

Permalink
Add reshapeImage first test
Browse files Browse the repository at this point in the history
  • Loading branch information
dacr committed Jul 21, 2024
1 parent 0135e9e commit 4292fc6
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ object BasicImagingSpec extends ZIOSpecDefault {
loadedImage.getRGB(imageSampleWidth - 1, imageSampleHeight - 1) == Color.BLACK.getRGB
)
}
)
),
test("should be able to reshape an image file") {
import java.nio.file.*
import java.nio.*
for {
original <- ZIO.attempt(imageSample())
tmpPath = Path.of(scala.util.Properties.tmpDir)
inputPath <- ZIO.attempt(Files.createTempFile(tmpPath, "tempoImageInput", ".png"))
outputPath <- ZIO.attempt(Files.createTempFile(tmpPath, "tempoImageOutput", ".png"))
_ <- ZIO.attempt(BasicImaging.save(inputPath, original))
_ <- ZIO.attempt(BasicImaging.reshapeImage(inputPath, outputPath, imageSampleWidth / 2))
loadedImage <- ZIO.attempt(BasicImaging.load(outputPath))
} yield assertTrue(
loadedImage.getWidth == imageSampleWidth / 2,
loadedImage.getHeight == imageSampleHeight / 2,
loadedImage.getRGB(10, 10) == Color.GREEN.getRGB,
)
}
)
}

0 comments on commit 4292fc6

Please sign in to comment.