aboutsummaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-03-20 17:20:26 +0000
committerGitHub <noreply@github.com>2025-03-20 17:20:26 +0000
commit539e9bd2e3409300a80109ea6b4c015a9dabdb0a (patch)
tree4c57efdaf2735b543a1068afdf051788fe0e64fe /tests/core
parentbadd2c90f9d168851bb3ee8b098392ef7a3f04ca (diff)
parentcae3f13d9f61fa4ec82dbdcfe3c9bcb6f9f8d344 (diff)
Merge pull request #4836 from laytan/fix-wrong-out-of-memory
fix wrong out of memory in edge cases, just try allocate from block for one source of truth
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/mem/test_core_mem.odin17
-rw-r--r--tests/core/runtime/test_core_runtime.odin15
2 files changed, 31 insertions, 1 deletions
diff --git a/tests/core/mem/test_core_mem.odin b/tests/core/mem/test_core_mem.odin
index d282ae1fd..4f2095fca 100644
--- a/tests/core/mem/test_core_mem.odin
+++ b/tests/core/mem/test_core_mem.odin
@@ -1,6 +1,7 @@
package test_core_mem
import "core:mem/tlsf"
+import "core:mem/virtual"
import "core:testing"
@test
@@ -38,4 +39,18 @@ test_tlsf_bitscan :: proc(t: ^testing.T) {
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
+}
+
+@(test)
+test_align_bumping_block_limit :: proc(t: ^testing.T) {
+ a: virtual.Arena
+ defer virtual.arena_destroy(&a)
+
+ data, err := virtual.arena_alloc(&a, 4193371, 1)
+ testing.expect_value(t, err, nil)
+ testing.expect(t, len(data) == 4193371)
+
+ data, err = virtual.arena_alloc(&a, 896, 64)
+ testing.expect_value(t, err, nil)
+ testing.expect(t, len(data) == 896)
+}
diff --git a/tests/core/runtime/test_core_runtime.odin b/tests/core/runtime/test_core_runtime.odin
index be6c24c72..472a5527d 100644
--- a/tests/core/runtime/test_core_runtime.odin
+++ b/tests/core/runtime/test_core_runtime.odin
@@ -32,6 +32,21 @@ test_temp_allocator_big_alloc_and_alignment :: proc(t: ^testing.T) {
}
@(test)
+test_align_bumping_block_limit :: proc(t: ^testing.T) {
+ a: runtime.Arena
+ a.minimum_block_size = 8*mem.Megabyte
+ defer runtime.arena_destroy(&a)
+
+ data, err := runtime.arena_alloc(&a, 4193371, 1)
+ testing.expect_value(t, err, nil)
+ testing.expect(t, len(data) == 4193371)
+
+ data, err = runtime.arena_alloc(&a, 896, 64)
+ testing.expect_value(t, err, nil)
+ testing.expect(t, len(data) == 896)
+}
+
+@(test)
test_temp_allocator_returns_correct_size :: proc(t: ^testing.T) {
arena: runtime.Arena
context.allocator = runtime.arena_allocator(&arena)