aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-09-10 20:22:10 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2022-09-10 20:22:10 +0200
commit99f4cc30063c76588e666f564ed9a17e35730e45 (patch)
treeae43cc60781735cfb4ee505968bbf77692f0e8a3 /tests
parent913e8b2e02ea278235cade2c02c2ddae40e8470d (diff)
[core:image/tga] Add tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/core/image/test_core_image.odin23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/core/image/test_core_image.odin b/tests/core/image/test_core_image.odin
index 171e4674d..bce5c910b 100644
--- a/tests/core/image/test_core_image.odin
+++ b/tests/core/image/test_core_image.odin
@@ -16,6 +16,7 @@ import "core:image"
import pbm "core:image/netpbm"
import "core:image/png"
import "core:image/qoi"
+import "core:image/tga"
import "core:bytes"
import "core:hash"
@@ -1530,6 +1531,28 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
}
}
+ // Roundtrip through TGA to test the TGA encoder and decoder.
+ if img.depth == 8 && (img.channels == 3 || img.channels == 4) {
+ tga_buffer: bytes.Buffer
+ defer bytes.buffer_destroy(&tga_buffer)
+ tga_save_err := tga.save(&tga_buffer, img)
+
+ error = fmt.tprintf("%v test %v TGA save failed with %v.", file.file, count, tga_save_err)
+ expect(t, tga_save_err == nil, error)
+
+ if tga_save_err == nil {
+ tga_img, tga_load_err := tga.load(tga_buffer.buf[:])
+ defer tga.destroy(tga_img)
+
+ error = fmt.tprintf("%v test %v TGA load failed with %v.", file.file, count, tga_load_err)
+ expect(t, tga_load_err == nil, error)
+
+ tga_hash := hash.crc32(tga_img.pixels.buf[:])
+ error = fmt.tprintf("%v test %v TGA load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, tga_hash, png_hash, test.options)
+ expect(t, tga_hash == png_hash, error)
+ }
+ }
+
{
// Roundtrip through PBM to test the PBM encoders and decoders - prefer binary
pbm_buf, pbm_save_err := pbm.save_to_buffer(img)