Harbor

branch main
showing the latest snapshot on main
backend_handle_test.odin 859 B · Plain text
tests/backend_handle_test.odin 0644 Raw
package gpu_tests

import bk "../backend"
import gl_backend "../backend/opengl"
import "core:testing"

Test_Pool_Entry :: struct {
	active: bool,
	value:  int,
}

@(test)
test_opengl_active_pool_entry_validates_bounds_and_active_state :: proc(t: ^testing.T) {
	pool: [4]Test_Pool_Entry
	pool[1] = {
		active = true,
		value  = 42,
	}
	pool[2] = {
		active = false,
		value  = 99,
	}

	entry, valid_ok := gl_backend.active_pool_entry(&pool, bk.Buffer_Handle(1))
	testing.expect(t, valid_ok)
	testing.expect_value(t, entry.value, 42)

	_, null_ok := gl_backend.active_pool_entry(&pool, bk.NULL_BUFFER)
	testing.expect(t, !null_ok)

	_, inactive_ok := gl_backend.active_pool_entry(&pool, bk.Buffer_Handle(2))
	testing.expect(t, !inactive_ok)

	_, out_of_range_ok := gl_backend.active_pool_entry(&pool, bk.Buffer_Handle(4))
	testing.expect(t, !out_of_range_ok)
}