mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
test/core/container: Refactor for multiple container types
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
@@ -1,29 +1,19 @@
|
|||||||
package test_core_compress
|
package test_core_container
|
||||||
|
|
||||||
import "core:fmt"
|
|
||||||
import "core:testing"
|
import "core:testing"
|
||||||
import "core:container/small_array"
|
import "core:container/small_array"
|
||||||
|
|
||||||
import tc "tests:common"
|
import tc "tests:common"
|
||||||
|
|
||||||
main :: proc() {
|
@(test)
|
||||||
t := testing.T{}
|
test_small_array :: proc(t: ^testing.T) {
|
||||||
test_small_array_removes(&t)
|
tc.log(t, "Testing small_array")
|
||||||
test_small_array_inject_at(&t)
|
|
||||||
tc.report(&t)
|
test_small_array_removes(t)
|
||||||
|
test_small_array_inject_at(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
expect_equal :: proc(t: ^testing.T, the_slice, expected: []int, loc := #caller_location) {
|
@(test)
|
||||||
_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
|
|
||||||
test_small_array_removes :: proc(t: ^testing.T) {
|
test_small_array_removes :: proc(t: ^testing.T) {
|
||||||
array: small_array.Small_Array(10, int)
|
array: small_array.Small_Array(10, int)
|
||||||
small_array.append(&array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
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 })
|
expect_equal(t, small_array.slice(&array), []int { 9, 2, 7, 4 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@(test)
|
||||||
test_small_array_inject_at :: proc(t: ^testing.T) {
|
test_small_array_inject_at :: proc(t: ^testing.T) {
|
||||||
array: small_array.Small_Array(13, int)
|
array: small_array.Small_Array(13, int)
|
||||||
small_array.append(&array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
small_array.append(&array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||||
|
|||||||
Reference in New Issue
Block a user