aboutsummaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-06-09 17:13:43 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2024-06-09 17:13:43 +0200
commitfc2ba81be0f7b53bedb6b8a57cee430d3ddff094 (patch)
tree1216c8a9a70d4f1cba655fdd86c77b87519f258b /tests/core
parent6b88d0a8206e78f2bf84bba39dc2261f906d0a58 (diff)
parentedcbca51c30c95356c46e9ab89caa168722f8a79 (diff)
Merge branch 'master' into png_cleanup
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/mem/test_core_mem.odin41
-rw-r--r--tests/core/normal.odin1
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/core/mem/test_core_mem.odin b/tests/core/mem/test_core_mem.odin
new file mode 100644
index 000000000..d282ae1fd
--- /dev/null
+++ b/tests/core/mem/test_core_mem.odin
@@ -0,0 +1,41 @@
+package test_core_mem
+
+import "core:mem/tlsf"
+import "core:testing"
+
+@test
+test_tlsf_bitscan :: proc(t: ^testing.T) {
+ Vector :: struct {
+ op: enum{ffs, fls, fls_uint},
+ v: union{u32, uint},
+ exp: i32,
+ }
+ Tests := []Vector{
+ {.ffs, u32 (0x0000_0000_0000_0000), -1},
+ {.ffs, u32 (0x0000_0000_0000_0000), -1},
+ {.fls, u32 (0x0000_0000_0000_0000), -1},
+ {.ffs, u32 (0x0000_0000_0000_0001), 0},
+ {.fls, u32 (0x0000_0000_0000_0001), 0},
+ {.ffs, u32 (0x0000_0000_8000_0000), 31},
+ {.ffs, u32 (0x0000_0000_8000_8000), 15},
+ {.fls, u32 (0x0000_0000_8000_0008), 31},
+ {.fls, u32 (0x0000_0000_7FFF_FFFF), 30},
+ {.fls_uint, uint(0x0000_0000_8000_0000), 31},
+ {.fls_uint, uint(0x0000_0001_0000_0000), 32},
+ {.fls_uint, uint(0xffff_ffff_ffff_ffff), 63},
+ }
+
+ for test in Tests {
+ switch test.op {
+ case .ffs:
+ res := tlsf.ffs(test.v.?)
+ testing.expectf(t, res == test.exp, "Expected tlsf.ffs(0x%08x) == %v, got %v", test.v, test.exp, res)
+ case .fls:
+ res := tlsf.fls(test.v.?)
+ testing.expectf(t, res == test.exp, "Expected tlsf.fls(0x%08x) == %v, got %v", test.v, test.exp, res)
+ case .fls_uint:
+ res := tlsf.fls_uint(test.v.?)
+ testing.expectf(t, res == test.exp, "Expected tlsf.fls_uint(0x%16x) == %v, got %v", test.v, test.exp, res)
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/core/normal.odin b/tests/core/normal.odin
index 29f4e9b80..7620d7d6e 100644
--- a/tests/core/normal.odin
+++ b/tests/core/normal.odin
@@ -24,6 +24,7 @@ download_assets :: proc() {
@(require) import "math/big"
@(require) import "math/linalg/glsl"
@(require) import "math/noise"
+@(require) import "mem"
@(require) import "net"
@(require) import "odin"
@(require) import "path/filepath"