Browse Source

test/core/container: Refactor for multiple container types

Yawning Angel 1 year ago
parent
commit
db3279e7da

+ 25 - 0
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)
+}

+ 9 - 19
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)