aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2024-02-16 18:58:02 +0900
committerYawning Angel <yawning@schwanenlied.me>2024-02-24 14:05:15 +0900
commitdb3279e7da4d422005fa9224a9fb8c2301d88837 (patch)
tree71368bf8610a631ea685c8998eacc2a0a00c8844 /tests
parent9251e06143af437d919c5b9f639b746905708303 (diff)
test/core/container: Refactor for multiple container types
Diffstat (limited to 'tests')
-rw-r--r--tests/core/container/test_core_container.odin25
-rw-r--r--tests/core/container/test_core_small_array.odin28
2 files changed, 34 insertions, 19 deletions
diff --git a/tests/core/container/test_core_container.odin b/tests/core/container/test_core_container.odin
new file mode 100644
index 000000000..9065bed2c
--- /dev/null
+++ b/tests/core/container/test_core_container.odin
@@ -0,0 +1,25 @@
+package test_core_container
+
+import "core:fmt"
+import "core:testing"
+
+import tc "tests:common"
+
+expect_equal :: proc(t: ^testing.T, the_slice, expected: []int, loc := #caller_location) {
+ _eq :: proc(a, b: []int) -> bool {
+ if len(a) != len(b) do return false
+ for a, i in a {
+ if b[i] != a do return false
+ }
+ return true
+ }
+ tc.expect(t, _eq(the_slice, expected), fmt.tprintf("Expected %v, got %v\n", the_slice, expected), loc)
+}
+
+main :: proc() {
+ t := testing.T{}
+
+ test_small_array(&t)
+
+ tc.report(&t)
+}
diff --git a/tests/core/container/test_core_small_array.odin b/tests/core/container/test_core_small_array.odin
index 88bc8e532..78998de16 100644
--- a/tests/core/container/test_core_small_array.odin
+++ b/tests/core/container/test_core_small_array.odin
@@ -1,29 +1,19 @@
-package test_core_compress
+package test_core_container
-import "core:fmt"
import "core:testing"
import "core:container/small_array"
+
import tc "tests:common"
-main :: proc() {
- t := testing.T{}
- test_small_array_removes(&t)
- test_small_array_inject_at(&t)
- tc.report(&t)
-}
+@(test)
+test_small_array :: proc(t: ^testing.T) {
+ tc.log(t, "Testing small_array")
-expect_equal :: proc(t: ^testing.T, the_slice, expected: []int, loc := #caller_location) {
- _eq :: proc(a, b: []int) -> bool {
- if len(a) != len(b) do return false
- for a, i in a {
- if b[i] != a do return false
- }
- return true
- }
- tc.expect(t, _eq(the_slice, expected), fmt.tprintf("Expected %v, got %v\n", the_slice, expected), loc)
+ test_small_array_removes(t)
+ test_small_array_inject_at(t)
}
-@test
+@(test)
test_small_array_removes :: proc(t: ^testing.T) {
array: small_array.Small_Array(10, int)
small_array.append(&array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
@@ -42,7 +32,7 @@ test_small_array_removes :: proc(t: ^testing.T) {
expect_equal(t, small_array.slice(&array), []int { 9, 2, 7, 4 })
}
-@test
+@(test)
test_small_array_inject_at :: proc(t: ^testing.T) {
array: small_array.Small_Array(13, int)
small_array.append(&array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)