Browse Source

Update `core:image` tests to use new runner.

Jeroen van Rijn 1 year ago
parent
commit
eb3d6d7d75
4 changed files with 118 additions and 193 deletions
  1. 2 2
      tests/core/Makefile
  2. 2 2
      tests/core/build.bat
  3. 2 4
      tests/core/image/build.bat
  4. 112 185
      tests/core/image/test_core_image.odin

+ 2 - 2
tests/core/Makefile

@@ -1,6 +1,6 @@
 ODIN=../../odin
 PYTHON=$(shell which python3)
-COMMON=-vet -strict-style
+COMMON=-no-bounds-check -vet -strict-style -define:test_track_memory=true
 COLLECTION=-collection:tests=..
 
 all: all_bsd \
@@ -34,7 +34,7 @@ download_test_assets:
 	$(PYTHON) download_assets.py
 
 image_test:
-	$(ODIN) run image $(COMMON) -out:test_core_image
+	$(ODIN) test image $(COMMON) -define:test_progress_width=12 -out:test_core_image
 
 compress_test:
 	$(ODIN) run compress $(COMMON) -out:test_core_compress

+ 2 - 2
tests/core/build.bat

@@ -1,5 +1,5 @@
 @echo off
-set COMMON=-no-bounds-check -vet -strict-style
+set COMMON=-no-bounds-check -vet -strict-style -define:test_track_memory=true
 set COLLECTION=-collection:tests=..
 set PATH_TO_ODIN==..\..\odin
 python3 download_assets.py
@@ -42,7 +42,7 @@ echo ---
 echo ---
 echo Running core:image tests
 echo ---
-%PATH_TO_ODIN% run image    %COMMON% -out:test_core_image.exe || exit /b
+%PATH_TO_ODIN% test image %COMMON% -define:test_progress_width=12 -out:test_core_image.exe || exit /b
 
 echo ---
 echo Running core:math tests

+ 2 - 4
tests/core/image/build.bat

@@ -1,4 +1,2 @@
-@echo off
-pushd ..
-odin run image
-popd
+@echo off
+odin test . -define:test_track_memory=true -define:test_progress_width=12 -vet -strict-style

+ 112 - 185
tests/core/image/test_core_image.odin

@@ -20,48 +20,14 @@ import "core:image/tga"
 
 import "core:bytes"
 import "core:hash"
-import "core:fmt"
 import "core:strings"
-
 import "core:mem"
-import "core:os"
 import "core:time"
-
 import "base:runtime"
 
-TEST_SUITE_PATH   :: "assets/PNG"
-
-TEST_count := 0
-TEST_fail  := 0
-
-when ODIN_TEST {
-	expect  :: testing.expect
-	log     :: testing.log
-} else {
-	expect  :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
-		TEST_count += 1
-		if !condition {
-			TEST_fail += 1
-			fmt.printf("[%v] %v\n", loc, message)
-			return
-		}
-	}
-	log     :: proc(t: ^testing.T, v: any, loc := #caller_location) {
-		fmt.printf("[%v] ", loc)
-		fmt.printf("log: %v\n", v)
-	}
-}
-I_Error :: image.Error
-
-main :: proc() {
-	t := testing.T{}
-	png_test(&t)
+TEST_SUITE_PATH :: "assets/PNG"
 
-	fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
-	if TEST_fail > 0 {
-		os.exit(1)
-	}
-}
+I_Error :: image.Error
 
 PNG_Test :: struct {
 	file:   string,
@@ -72,7 +38,6 @@ PNG_Test :: struct {
 		hash:           u32,
 	},
 }
-
 Default              :: image.Options{}
 Alpha_Add            :: image.Options{.alpha_add_if_missing}
 Premul_Drop          :: image.Options{.alpha_premultiply, .alpha_drop_if_present}
@@ -82,7 +47,7 @@ Blend_BG_Keep        :: image.Options{.blend_background, .alpha_add_if_missing}
 Return_Metadata      :: image.Options{.return_metadata}
 No_Channel_Expansion :: image.Options{.do_not_expand_channels, .return_metadata}
 
-PNG_Dims    :: struct {
+PNG_Dims :: struct {
 	width:     int,
 	height:    int,
 	channels:  int,
@@ -1430,38 +1395,66 @@ Expected_Text := map[string]map[string]png.Text {
 }
 
 @test
-png_test :: proc(t: ^testing.T) {
-
-	total_tests    := 0
-	total_expected := 235
-
-	PNG_Suites := [][]PNG_Test{
-		Basic_PNG_Tests,
-		Interlaced_PNG_Tests,
-		Odd_Sized_PNG_Tests,
-		PNG_bKGD_Tests,
-		PNG_tRNS_Tests,
-		PNG_Filter_Tests,
-		PNG_Varied_IDAT_Tests,
-		PNG_ZLIB_Levels_Tests,
-		PNG_sPAL_Tests,
-		PNG_Ancillary_Tests,
-		Corrupt_PNG_Tests,
-
-		No_Postprocesing_Tests,
+png_test_basic :: proc(t: ^testing.T) {
+	run_png_suite(t, Basic_PNG_Tests)
+}
 
-	}
+@test
+png_test_interlaced :: proc(t: ^testing.T) {
+	run_png_suite(t, Interlaced_PNG_Tests)
+}
 
-	for suite in PNG_Suites {
-		total_tests += run_png_suite(t, suite)
-	}
+@test
+png_test_odd_sized :: proc(t: ^testing.T) {
+	run_png_suite(t, Odd_Sized_PNG_Tests)
+}
+
+@test
+png_test_bKGD :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_bKGD_Tests)
+}
+
+@test
+png_test_tRNS :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_tRNS_Tests)
+}
+
+@test
+png_test_sPAL :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_sPAL_Tests)
+}
+
+@test
+png_test_filter :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_Filter_Tests)
+}
+
+@test
+png_test_varied_idat :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_Varied_IDAT_Tests)
+}
 
-	error  := fmt.tprintf("Expected %v PNG tests, %v ran.", total_expected, total_tests)
-	expect(t, total_tests == total_expected, error)
+@test
+png_test_zlib_levels :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_ZLIB_Levels_Tests)
 }
 
-run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
+@test
+png_test_ancillary :: proc(t: ^testing.T) {
+	run_png_suite(t, PNG_Ancillary_Tests)
+}
 
+@test
+png_test_corrupt :: proc(t: ^testing.T) {
+	run_png_suite(t, Corrupt_PNG_Tests)
+}
+
+@test
+png_test_no_postproc :: proc(t: ^testing.T) {
+	run_png_suite(t, No_Postprocesing_Tests)
+}
+
+run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) {
 	context = runtime.default_context()
 
 	for file in suite {
@@ -1472,9 +1465,7 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 
 		count := 0
 		for test in file.tests {
-			count        += 1
-			subtotal     += 1
-			passed       := false
+			count += 1
 
 			track: mem.Tracking_Allocator
 			mem.tracking_allocator_init(&track, context.allocator)
@@ -1482,29 +1473,21 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 
 			img, err = png.load(test_file, test.options)
 
-			error  := fmt.tprintf("%v failed with %v.", test_file, err)
-
-			passed = (test.expected_error == nil && err == nil) || (test.expected_error == err)
-
-			expect(t, passed, error)
+			passed := (test.expected_error == nil && err == nil) || (test.expected_error == err)
+			testing.expectf(t, passed, "%v failed with %v.", test_file, err)
 
 			if err == nil { // No point in running the other tests if it didn't load.
 				pixels := bytes.buffer_to_bytes(&img.pixels)
 
 				// This struct compare fails at -opt:2 if PNG_Dims is not #packed.
-
-				dims   := PNG_Dims{img.width, img.height, img.channels, img.depth}
-				error  = fmt.tprintf("%v has %v, expected: %v.", file.file, dims, test.dims)
-
+				dims := PNG_Dims{img.width, img.height, img.channels, img.depth}
 				dims_pass := test.dims == dims
 
-				expect(t, dims_pass, error)
-
+				testing.expectf(t, dims_pass, "%v has %v, expected: %v.", file.file, dims, test.dims)
 				passed &= dims_pass
 
-				png_hash   := hash.crc32(pixels)
-				error  = fmt.tprintf("%v test %v hash is %08x, expected %08x with %v.", file.file, count, png_hash, test.hash, test.options)
-				expect(t, test.hash == png_hash, error)
+				png_hash := hash.crc32(pixels)
+				testing.expectf(t, test.hash == png_hash, "%v test %v hash is %08x, expected %08x with %v.", file.file, count, png_hash, test.hash, test.options)
 
 				passed &= test.hash == png_hash
 
@@ -1515,19 +1498,16 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 						defer bytes.buffer_destroy(&qoi_buffer)
 						qoi_save_err := qoi.save(&qoi_buffer, img)
 
-						error  = fmt.tprintf("%v test %v QOI save failed with %v.", file.file, count, qoi_save_err)
-						expect(t, qoi_save_err == nil, error)
+						testing.expectf(t, qoi_save_err == nil, "%v test %v QOI save failed with %v.", file.file, count, qoi_save_err)
 
 						if qoi_save_err == nil {
 							qoi_img, qoi_load_err := qoi.load(qoi_buffer.buf[:])
 							defer qoi.destroy(qoi_img)
 
-							error  = fmt.tprintf("%v test %v QOI load failed with %v.", file.file, count, qoi_load_err)
-							expect(t, qoi_load_err == nil, error)
+							testing.expectf(t, qoi_load_err == nil, "%v test %v QOI load failed with %v.", file.file, count, qoi_load_err)
 
 							qoi_hash := hash.crc32(qoi_img.pixels.buf[:])
-							error  = fmt.tprintf("%v test %v QOI load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, qoi_hash, png_hash, test.options)
-							expect(t, qoi_hash == png_hash, error)
+							testing.expectf(t, qoi_hash == png_hash, "%v test %v QOI load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, qoi_hash, png_hash, test.options)
 						}
 					}
 
@@ -1537,19 +1517,15 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 						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)
-
+						testing.expectf(t, tga_save_err == nil, "%v test %v TGA save failed with %v.", file.file, count, tga_save_err)
 						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)
+							testing.expectf(t, tga_load_err == nil, "%v test %v TGA load failed with %v.", file.file, count, tga_load_err)
 
 							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)
+							testing.expectf(t, tga_hash == png_hash, "%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)
 						}
 					}
 
@@ -1558,22 +1534,18 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 						pbm_buf, pbm_save_err := pbm.save_to_buffer(img)
 						defer delete(pbm_buf)
 
-						error = fmt.tprintf("%v test %v PBM save failed with %v.", file.file, count, pbm_save_err)
-						expect(t, pbm_save_err == nil, error)
+						testing.expectf(t, pbm_save_err == nil, "%v test %v PBM save failed with %v.", file.file, count, pbm_save_err)
 
 						if pbm_save_err == nil {
 							// Try to load it again.
 							pbm_img, pbm_load_err := pbm.load(pbm_buf)
 							defer pbm.destroy(pbm_img)
 
-							error  = fmt.tprintf("%v test %v PBM load failed with %v.", file.file, count, pbm_load_err)
-							expect(t, pbm_load_err == nil, error)
+							testing.expectf(t, pbm_load_err == nil, "%v test %v PBM load failed with %v.", file.file, count, pbm_load_err)
 
 							if pbm_load_err == nil {
 								pbm_hash := hash.crc32(pbm_img.pixels.buf[:])
-
-								error  = fmt.tprintf("%v test %v PBM load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, pbm_hash, png_hash, test.options)
-								expect(t, pbm_hash == png_hash, error)
+								testing.expectf(t, pbm_hash == png_hash, "%v test %v PBM load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, pbm_hash, png_hash, test.options)
 							}
 						}
 					}
@@ -1587,22 +1559,18 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 							pbm_buf, pbm_save_err := pbm.save_to_buffer(img, pbm_info)
 							defer delete(pbm_buf)
 
-							error = fmt.tprintf("%v test %v PBM save failed with %v.", file.file, count, pbm_save_err)
-							expect(t, pbm_save_err == nil, error)
+							testing.expectf(t, pbm_save_err == nil, "%v test %v PBM save failed with %v.", file.file, count, pbm_save_err)
 
 							if pbm_save_err == nil {
 								// Try to load it again.
 								pbm_img, pbm_load_err := pbm.load(pbm_buf)
 								defer pbm.destroy(pbm_img)
 
-								error  = fmt.tprintf("%v test %v PBM load failed with %v.", file.file, count, pbm_load_err)
-								expect(t, pbm_load_err == nil, error)
+								testing.expectf(t, pbm_load_err == nil, "%v test %v PBM load failed with %v.", file.file, count, pbm_load_err)
 
 								if pbm_load_err == nil {
 									pbm_hash := hash.crc32(pbm_img.pixels.buf[:])
-
-									error  = fmt.tprintf("%v test %v PBM load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, pbm_hash, png_hash, test.options)
-									expect(t, pbm_hash == png_hash, error)
+									testing.expectf(t, pbm_hash == png_hash, "%v test %v PBM load hash is %08x, expected it match PNG's %08x with %v.", file.file, count, pbm_hash, png_hash, test.options)
 								}
 							}
 						}
@@ -1655,21 +1623,18 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 							float_pbm_buf, float_pbm_save_err := pbm.save_to_buffer(float_img, pbm_info)
 							defer delete(float_pbm_buf)
 
-							error = fmt.tprintf("%v test %v save as PFM failed with %v", file.file, count, float_pbm_save_err)
-							expect(t, float_pbm_save_err == nil, error)
+							testing.expectf(t, float_pbm_save_err == nil, "%v test %v save as PFM failed with %v", file.file, count, float_pbm_save_err)
 
 							if float_pbm_save_err == nil {
 								// Load float image and compare.
 								float_pbm_img, float_pbm_load_err := pbm.load(float_pbm_buf)
 								defer pbm.destroy(float_pbm_img)
 
-								error = fmt.tprintf("%v test %v PFM load failed with %v", file.file, count, float_pbm_load_err)
-								expect(t, float_pbm_load_err == nil, error)
+								testing.expectf(t, float_pbm_load_err == nil, "%v test %v PFM load failed with %v", file.file, count, float_pbm_load_err)
 
 								load_float := mem.slice_data_cast([]f32, float_pbm_img.pixels.buf[:])
 
-								error = fmt.tprintf("%v test %v PFM load returned %v floats, expected %v", file.file, count, len(load_float), len(orig_float))
-								expect(t, len(load_float) == len(orig_float), error)
+								testing.expectf(t, len(load_float) == len(orig_float), "%v test %v PFM load returned %v floats, expected %v", file.file, count, len(load_float), len(orig_float))
 
 								// Compare floats
 								equal := true
@@ -1679,15 +1644,13 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 										break
 									}
 								}
-								error = fmt.tprintf("%v test %v PFM loaded floats to match", file.file, count)
-								expect(t, equal, error)
+								testing.expectf(t, equal, "%v test %v PFM loaded floats to match", file.file, count)
 							}
 						}
 					}
 				}
 
 				if .return_metadata in test.options {
-
 					if v, ok := img.metadata.(^image.PNG_Info); ok {
 						for c in v.chunks {
 							#partial switch(c.header.type) {
@@ -1696,8 +1659,7 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 								case "pp0n2c16", "pp0n6a08":
 									gamma, gamma_ok := png.gamma(c)
 									expected_gamma := f32(1.0)
-									error  = fmt.tprintf("%v test %v gAMA is %v, expected %v.", file.file, count, gamma, expected_gamma)
-									expect(t, gamma == expected_gamma && gamma_ok, error)
+									testing.expectf(t, gamma == expected_gamma && gamma_ok, "%v test %v gAMA is %v, expected %v.", file.file, count, gamma, expected_gamma)
 								}
 							case .PLTE:
 								switch(file.file) {
@@ -1705,8 +1667,7 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 									plte, plte_ok := png.plte(c)
 
 									expected_plte_len := u16(216)
-									error  = fmt.tprintf("%v test %v PLTE length is %v, expected %v.", file.file, count, plte.used, expected_plte_len)
-									expect(t, expected_plte_len == plte.used && plte_ok, error)
+									testing.expectf(t, expected_plte_len == plte.used && plte_ok, "%v test %v PLTE length is %v, expected %v.", file.file, count, plte.used, expected_plte_len)
 								}
 							case .sPLT:
 								switch(file.file) {
@@ -1714,12 +1675,10 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 									splt, splt_ok := png.splt(c)
 
 									expected_splt_len  := u16(216)
-									error  = fmt.tprintf("%v test %v sPLT length is %v, expected %v.", file.file, count, splt.used, expected_splt_len)
-									expect(t, expected_splt_len == splt.used && splt_ok, error)
+									testing.expectf(t, expected_splt_len == splt.used && splt_ok, "%v test %v sPLT length is %v, expected %v.", file.file, count, splt.used, expected_splt_len)
 
 									expected_splt_name := "six-cube"
-									error  = fmt.tprintf("%v test %v sPLT name is %v, expected %v.", file.file, count, splt.name, expected_splt_name)
-									expect(t, expected_splt_name == splt.name && splt_ok, error)
+									testing.expectf(t, expected_splt_name == splt.name && splt_ok, "%v test %v sPLT name is %v, expected %v.", file.file, count, splt.name, expected_splt_name)
 
 									png.splt_destroy(splt)
 								}
@@ -1733,48 +1692,37 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 										g = png.CIE_1931{x = 0.3000, y = 0.6000},
 										b = png.CIE_1931{x = 0.1500, y = 0.0600},
 									}
-									error  = fmt.tprintf("%v test %v cHRM is %v, expected %v.", file.file, count, chrm, expected_chrm)
-									expect(t, expected_chrm == chrm && chrm_ok, error)
+									testing.expectf(t, expected_chrm == chrm && chrm_ok, "%v test %v cHRM is %v, expected %v.", file.file, count, chrm, expected_chrm)
 								}
 							case .pHYs:
 								phys, phys_ok := png.phys(c)
-								phys_err := "%v test %v cHRM is %v, expected %v."
 								switch (file.file) {
 								case "cdfn2c08":
 									expected_phys := png.pHYs{ppu_x =    1, ppu_y =    4, unit = .Unknown}
-									error  = fmt.tprintf(phys_err, file.file, count, phys, expected_phys)
-									expect(t, expected_phys == phys && phys_ok, error)
+									testing.expectf(t, expected_phys == phys && phys_ok, "%v test %v cHRM is %v, expected %v.", file.file, count, phys, expected_phys)
 								case "cdhn2c08":
 									expected_phys := png.pHYs{ppu_x =    4, ppu_y =    1, unit = .Unknown}
-									error  = fmt.tprintf(phys_err, file.file, count, phys, expected_phys)
-									expect(t, expected_phys == phys && phys_ok, error)
+									testing.expectf(t, expected_phys == phys && phys_ok, "%v test %v cHRM is %v, expected %v.", file.file, count, phys, expected_phys)
 								case "cdsn2c08":
 									expected_phys := png.pHYs{ppu_x =    1, ppu_y =    1, unit = .Unknown}
-									error  = fmt.tprintf(phys_err, file.file, count, phys, expected_phys)
-									expect(t, expected_phys == phys && phys_ok, error)
+									testing.expectf(t, expected_phys == phys && phys_ok, "%v test %v cHRM is %v, expected %v.", file.file, count, phys, expected_phys)
 								case "cdun2c08":
 									expected_phys := png.pHYs{ppu_x = 1000, ppu_y = 1000, unit = .Meter}
-									error  = fmt.tprintf(phys_err, file.file, count, phys, expected_phys)
-									expect(t, expected_phys == phys && phys_ok, error)
+									testing.expectf(t, expected_phys == phys && phys_ok, "%v test %v cHRM is %v, expected %v.", file.file, count, phys, expected_phys)
 								}
 							case .hIST:
 								hist, hist_ok := png.hist(c)
-								hist_err := "%v test %v hIST has %v entries, expected %v."
 								switch (file.file) {
 								case "ch1n3p04":
-									error  = fmt.tprintf(hist_err, file.file, count, hist.used, 15)
-									expect(t, hist.used == 15 && hist_ok, error)
+									testing.expectf(t, hist.used == 15 && hist_ok, "%v test %v hIST has %v entries, expected %v.", file.file, count, hist.used, 15)
 								case "ch2n3p08":
-									error  = fmt.tprintf(hist_err, file.file, count, hist.used, 256)
-									expect(t, hist.used == 256 && hist_ok, error)
+									testing.expectf(t, hist.used == 256 && hist_ok, "%v test %v hIST has %v entries, expected %v.", file.file, count, hist.used, 256)
 								}
 							case .tIME:
 								png_time, png_time_ok := png.time(c)
-								time_err := "%v test %v tIME was %v, expected %v."
 								expected_time: png.tIME
 
 								core_time, core_time_ok := png.core_time(c)
-								time_core_err := "%v test %v tIME->core:time is %v, expected %v."
 								expected_core: time.Time
 
 								switch(file.file) {
@@ -1789,14 +1737,10 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 									expected_core = time.Time{_nsec = 946684799000000000}
 
 								}
-								error  = fmt.tprintf(time_err, file.file, count, png_time, expected_time)
-								expect(t, png_time  == expected_time && png_time_ok,  error)
-
-								error  = fmt.tprintf(time_core_err, file.file, count, core_time, expected_core)
-								expect(t, core_time == expected_core && core_time_ok, error)
+								testing.expectf(t, png_time  == expected_time && png_time_ok,  "%v test %v tIME was %v, expected %v.", file.file, count, png_time, expected_time)
+								testing.expectf(t, core_time == expected_core && core_time_ok, "%v test %v tIME->core:time is %v, expected %v.", file.file, count, core_time, expected_core)
 							case .sBIT:
 								sbit, sbit_ok  := png.sbit(c)
-								sbit_err       := "%v test %v sBIT was %v, expected %v."
 								expected_sbit: [4]u8
 
 								switch (file.file) {
@@ -1815,8 +1759,7 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 								case "cdfn2c08", "cdhn2c08", "cdsn2c08", "cdun2c08", "ch1n3p04", "basn3p04":
 									expected_sbit = [4]u8{ 4,  4,  4,  0}
 								}
-								error  = fmt.tprintf(sbit_err, file.file, count, sbit, expected_sbit)
-								expect(t, sbit == expected_sbit && sbit_ok, error)
+								testing.expectf(t, sbit == expected_sbit && sbit_ok, "%v test %v sBIT was %v, expected %v.", file.file, count, sbit, expected_sbit)
 							case .tEXt, .zTXt:
 								text, text_ok := png.text(c)
 								defer png.text_destroy(text)
@@ -1828,8 +1771,7 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 									if file.file in Expected_Text {
 										if text.keyword in Expected_Text[file.file] {
 											test_text := Expected_Text[file.file][text.keyword].text
-											error  = fmt.tprintf("%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text.text, test_text)
-											expect(t, text.text == test_text && text_ok, error)
+											testing.expectf(t, text.text == test_text && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text.text, test_text)
 										}
 									}
 								}
@@ -1842,74 +1784,59 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) {
 									if file.file in Expected_Text {
 										if text.keyword in Expected_Text[file.file] {
 											test := Expected_Text[file.file][text.keyword]
-											error  = fmt.tprintf("%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
-											expect(t, text.language == test.language && text_ok, error)
-											expect(t, text.keyword_localized == test.keyword_localized && text_ok, error)
+											testing.expectf(t, text.language == test.language && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.keyword_localized == test.keyword_localized && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
 										}
 									}
 								case "ctfn0g04": // international UTF-8, finnish
 									if file.file in Expected_Text {
 										if text.keyword in Expected_Text[file.file] {
 											test := Expected_Text[file.file][text.keyword]
-											error  = fmt.tprintf("%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
-											expect(t, text.text == test.text && text_ok, error)
-											expect(t, text.language == test.language && text_ok, error)
-											expect(t, text.keyword_localized == test.keyword_localized && text_ok, error)
+											testing.expectf(t, text.text == test.text && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.language == test.language && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.keyword_localized == test.keyword_localized && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
 										}
 									}
 								case "ctgn0g04": // international UTF-8, greek
 									if file.file in Expected_Text {
 										if text.keyword in Expected_Text[file.file] {
 											test := Expected_Text[file.file][text.keyword]
-											error  = fmt.tprintf("%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
-											expect(t, text.text == test.text && text_ok, error)
-											expect(t, text.language == test.language && text_ok, error)
-											expect(t, text.keyword_localized == test.keyword_localized && text_ok, error)
+											testing.expectf(t, text.text == test.text && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.language == test.language && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.keyword_localized == test.keyword_localized && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
 										}
 									}
 								case "cthn0g04": // international UTF-8, hindi
 									if file.file in Expected_Text {
 										if text.keyword in Expected_Text[file.file] {
 											test := Expected_Text[file.file][text.keyword]
-											error  = fmt.tprintf("%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
-											expect(t, text.text == test.text && text_ok, error)
-											expect(t, text.language == test.language && text_ok, error)
-											expect(t, text.keyword_localized == test.keyword_localized && text_ok, error)
+											testing.expectf(t, text.text == test.text && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.language == test.language && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.keyword_localized == test.keyword_localized && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
 										}
 									}
 								case "ctjn0g04": // international UTF-8, japanese
 									if file.file in Expected_Text {
 										if text.keyword in Expected_Text[file.file] {
 											test := Expected_Text[file.file][text.keyword]
-											error  = fmt.tprintf("%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
-											expect(t, text.text == test.text && text_ok, error)
-											expect(t, text.language == test.language && text_ok, error)
-											expect(t, text.keyword_localized == test.keyword_localized && text_ok, error)
+											testing.expectf(t, text.text == test.text && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.language == test.language && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
+											testing.expectf(t, text.keyword_localized == test.keyword_localized && text_ok, "%v test %v text keyword {{%v}}:'%v', expected '%v'.", file.file, count, text.keyword, text, test)
 										}
 									}
 								}
 							case .eXIf:
 								if file.file == "exif2c08" { // chunk with jpeg exif data
 									exif, exif_ok := png.exif(c)
-									error      = fmt.tprintf("%v test %v eXIf byte order '%v', expected 'big_endian'.", file.file, count, exif.byte_order)
-									error_len := fmt.tprintf("%v test %v eXIf data length '%v', expected '%v'.", file.file, len(exif.data), 978)
-									expect(t, exif.byte_order == .big_endian && exif_ok, error)
-									expect(t, len(exif.data)  == 978         && exif_ok, error_len)
+									testing.expectf(t, exif.byte_order == .big_endian && exif_ok, "%v test %v eXIf byte order '%v', expected 'big_endian'.", file.file, count, exif.byte_order)
+									testing.expectf(t, len(exif.data)  == 978         && exif_ok, "%v test %v eXIf data length '%v', expected '%v'.", file.file, len(exif.data), 978)
 								}
 							}
 						}
 					}
 				}
 			}
-
 			png.destroy(img)
-
-			for _, v in track.allocation_map {
-				error = fmt.tprintf("%v test %v leaked %v bytes @ loc %v.", file.file, count, v.size, v.location)
-				expect(t, false, error)
-			}
 		}
 	}
-
-	return
-}
+}