Strip old test runner back out of internal, issues and vendor

This commit is contained in:
Jeroen van Rijn
2024-06-02 21:15:25 +02:00
parent 9d8d864400
commit 60d0c03134
16 changed files with 282 additions and 582 deletions
+8 -9
View File
@@ -1,23 +1,22 @@
ODIN=../../odin ODIN=../../odin
COMMON=-file -vet -strict-style -o:minimal
all: all_bsd asan_test all: asan_test rtti_test map_test pow_test 128_test string_compare_test
all_bsd: rtti_test map_test pow_test 128_test string_compare_test
rtti_test: rtti_test:
$(ODIN) run test_rtti.odin -file -vet -strict-style -o:minimal $(ODIN) test test_rtti.odin $(COMMON)
map_test: map_test:
$(ODIN) run test_map.odin -file -vet -strict-style -o:minimal $(ODIN) test test_map.odin $(COMMON)
pow_test: pow_test:
$(ODIN) run test_pow.odin -file -vet -strict-style -o:minimal $(ODIN) test test_pow.odin $(COMMON)
128_test: 128_test:
$(ODIN) run test_128.odin -file -vet -strict-style -o:minimal $(ODIN) test test_128.odin $(COMMON)
asan_test: asan_test:
$(ODIN) run test_asan.odin -file -sanitize:address -debug $(ODIN) test test_asan.odin $(COMMON) -sanitize:address -debug
string_compare_test: string_compare_test:
$(ODIN) run test_string_compare.odin -file -vet -strict-style -o:minimal $(ODIN) test test_string_compare.odin $(COMMON)
+7 -8
View File
@@ -1,10 +1,9 @@
@echo off @echo off
set PATH_TO_ODIN==..\..\odin set PATH_TO_ODIN==..\..\odin
rem %PATH_TO_ODIN% run test_rtti.odin -file -vet -strict-style -o:minimal || exit /b set COMMON=-file -vet -strict-style -o:minimal
%PATH_TO_ODIN% run test_map.odin -file -vet -strict-style -o:minimal || exit /b %PATH_TO_ODIN% test test_rtti.odin %COMMON% || exit /b
rem -define:SEED=42 %PATH_TO_ODIN% test test_map.odin %COMMON% || exit /b
%PATH_TO_ODIN% run test_pow.odin -file -vet -strict-style -o:minimal || exit /b %PATH_TO_ODIN% test test_pow.odin %COMMON% || exit /b
%PATH_TO_ODIN% test test_asan.odin %COMMON% || exit /b
%PATH_TO_ODIN% run test_128.odin -file -vet -strict-style -o:minimal || exit /b %PATH_TO_ODIN% test test_128.odin %COMMON% || exit /b
%PATH_TO_ODIN% test test_string_compare.odin %COMMON% || exit /b
%PATH_TO_ODIN% run test_string_compare.odin -file -vet -strict-style -o:minimal || exit /b
+8 -42
View File
@@ -1,41 +1,7 @@
package test_128 package test_128
import "core:fmt"
import "core:os"
import "core:testing" import "core:testing"
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.printf("[%v] %v\n", loc, message)
return
}
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
main :: proc() {
t := testing.T{}
test_128_align(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
@test @test
test_128_align :: proc(t: ^testing.T) { test_128_align :: proc(t: ^testing.T) {
Danger_Struct :: struct { Danger_Struct :: struct {
@@ -45,15 +11,15 @@ test_128_align :: proc(t: ^testing.T) {
list := [?]Danger_Struct{{0, 0}, {1, 0}, {2, 0}, {3, 0}} list := [?]Danger_Struct{{0, 0}, {1, 0}, {2, 0}, {3, 0}}
expect(t, list[0].x == 0, fmt.tprintf("[0].x (%v) != 0", list[0].x)) testing.expectf(t, list[0].x == 0, "[0].x (%v) != 0", list[0].x)
expect(t, list[0].y == 0, fmt.tprintf("[0].y (%v) != 0", list[0].y)) testing.expectf(t, list[0].y == 0, "[0].y (%v) != 0", list[0].y)
expect(t, list[1].x == 1, fmt.tprintf("[1].x (%v) != 1", list[1].x)) testing.expectf(t, list[1].x == 1, "[1].x (%v) != 1", list[1].x)
expect(t, list[1].y == 0, fmt.tprintf("[1].y (%v) != 0", list[1].y)) testing.expectf(t, list[1].y == 0, "[1].y (%v) != 0", list[1].y)
expect(t, list[2].x == 2, fmt.tprintf("[2].x (%v) != 2", list[2].x)) testing.expectf(t, list[2].x == 2, "[2].x (%v) != 2", list[2].x)
expect(t, list[2].y == 0, fmt.tprintf("[2].y (%v) != 0", list[2].y)) testing.expectf(t, list[2].y == 0, "[2].y (%v) != 0", list[2].y)
expect(t, list[3].x == 3, fmt.tprintf("[3].x (%v) != 3", list[3].x)) testing.expectf(t, list[3].x == 3, "[3].x (%v) != 3", list[3].x)
expect(t, list[3].y == 0, fmt.tprintf("[3].y (%v) != 0", list[3].y)) testing.expectf(t, list[3].y == 0, "[3].y (%v) != 0", list[3].y)
} }
+5 -40
View File
@@ -1,42 +1,7 @@
// Intended to contain code that would trigger asan easily if the abi was set up badly. // Intended to contain code that would trigger asan easily if the abi was set up badly.
package test_asan package test_asan
import "core:fmt"
import "core:testing" import "core:testing"
import "core:os"
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.printf("[%v] %v\n", loc, message)
return
}
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
main :: proc() {
t := testing.T{}
test_12_bytes(&t)
test_12_bytes_two(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
@(test) @(test)
test_12_bytes :: proc(t: ^testing.T) { test_12_bytes :: proc(t: ^testing.T) {
@@ -45,9 +10,9 @@ test_12_bytes :: proc(t: ^testing.T) {
} }
a, b, ok := internal() a, b, ok := internal()
expect(t, a == max(f32), fmt.tprintf("a (%v) != max(f32)", a)) testing.expectf(t, a == max(f32), "a (%v) != max(f32)", a)
expect(t, b == 0, fmt.tprintf("b (%v) != 0", b)) testing.expectf(t, b == 0, "b (%v) != 0", b)
expect(t, ok, fmt.tprintf("ok (%v) != true", ok)) testing.expectf(t, ok, "ok (%v) != true", ok)
} }
@(test) @(test)
@@ -57,6 +22,6 @@ test_12_bytes_two :: proc(t: ^testing.T) {
} }
a, b := internal() a, b := internal()
expect(t, a == 100., fmt.tprintf("a (%v) != 100.", a)) testing.expectf(t, a == 100., "a (%v) != 100.", a)
expect(t, b == max(int), fmt.tprintf("b (%v) != max(int)", b)) testing.expectf(t, b == max(int), "b (%v) != max(int)", b)
} }
+45 -115
View File
@@ -1,26 +1,22 @@
package test_internal_map package test_internal_map
import "core:fmt" import "core:log"
import "base:intrinsics" import "base:intrinsics"
import "core:math/rand" import "core:math/rand"
import "core:mem"
import "core:os"
import "core:testing" import "core:testing"
seed: u64
ENTRY_COUNTS := []int{11, 101, 1_001, 10_001, 100_001, 1_000_001} ENTRY_COUNTS := []int{11, 101, 1_001, 10_001, 100_001, 1_000_001}
@test @test
map_insert_random_key_value :: proc(t: ^testing.T) { map_insert_random_key_value :: proc(t: ^testing.T) {
seed_incr := u64(0) seed_incr := u64(0)
for entries in ENTRY_COUNTS { for entries in ENTRY_COUNTS {
fmt.printf("[map_insert_random_key_value] Testing %v entries.\n", entries) log.infof("Testing %v entries", entries)
m: map[i64]i64 m: map[i64]i64
defer delete(m) defer delete(m)
unique_keys := 0 unique_keys := 0
r := rand.create(seed + seed_incr) r := rand.create(t.seed + seed_incr)
for _ in 0..<entries { for _ in 0..<entries {
k := rand.int63(&r) k := rand.int63(&r)
v := rand.int63(&r) v := rand.int63(&r)
@@ -36,11 +32,11 @@ map_insert_random_key_value :: proc(t: ^testing.T) {
key_count += 1 key_count += 1
} }
expect(t, key_count == unique_keys, fmt.tprintf("Expected key_count to equal %v, got %v", unique_keys, key_count)) testing.expectf(t, key_count == unique_keys, "Expected key_count to equal %v, got %v", unique_keys, key_count)
expect(t, len(m) == unique_keys, fmt.tprintf("Expected len(map) to equal %v, got %v", unique_keys, len(m))) testing.expectf(t, len(m) == unique_keys, "Expected len(map) to equal %v, got %v", unique_keys, len(m))
// Reset randomizer and verify // Reset randomizer and verify
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
num_fails := 0 num_fails := 0
for _ in 0..<entries { for _ in 0..<entries {
@@ -51,10 +47,10 @@ map_insert_random_key_value :: proc(t: ^testing.T) {
if !cond { if !cond {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Unexpected value. Expected m[%v] = %v, got %v", k, v, m[k])) testing.expectf(t, false, "Unexpected value. Expected m[%v] = %v, got %v", k, v, m[k])
} }
} }
seed_incr += 1 seed_incr += 1
@@ -65,12 +61,12 @@ map_insert_random_key_value :: proc(t: ^testing.T) {
map_update_random_key_value :: proc(t: ^testing.T) { map_update_random_key_value :: proc(t: ^testing.T) {
seed_incr := u64(0) seed_incr := u64(0)
for entries in ENTRY_COUNTS { for entries in ENTRY_COUNTS {
fmt.printf("[map_update_random_key_value] Testing %v entries.\n", entries) log.infof("Testing %v entries", entries)
m: map[i64]i64 m: map[i64]i64
defer delete(m) defer delete(m)
unique_keys := 0 unique_keys := 0
r := rand.create(seed + seed_incr) r := rand.create(t.seed + seed_incr)
for _ in 0..<entries { for _ in 0..<entries {
k := rand.int63(&r) k := rand.int63(&r)
v := rand.int63(&r) v := rand.int63(&r)
@@ -86,13 +82,13 @@ map_update_random_key_value :: proc(t: ^testing.T) {
key_count += 1 key_count += 1
} }
expect(t, key_count == unique_keys, fmt.tprintf("Expected key_count to equal %v, got %v", unique_keys, key_count)) testing.expectf(t, key_count == unique_keys, "Expected key_count to equal %v, got %v", unique_keys, key_count)
expect(t, len(m) == unique_keys, fmt.tprintf("Expected len(map) to equal %v, got %v", unique_keys, len(m))) testing.expectf(t, len(m) == unique_keys, "Expected len(map) to equal %v, got %v", unique_keys, len(m))
half_entries := entries / 2 half_entries := entries / 2
// Reset randomizer and update half the entries // Reset randomizer and update half the entries
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
for _ in 0..<half_entries { for _ in 0..<half_entries {
k := rand.int63(&r) k := rand.int63(&r)
v := rand.int63(&r) v := rand.int63(&r)
@@ -101,7 +97,7 @@ map_update_random_key_value :: proc(t: ^testing.T) {
} }
// Reset randomizer and verify // Reset randomizer and verify
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
num_fails := 0 num_fails := 0
for i in 0..<entries { for i in 0..<entries {
@@ -113,10 +109,10 @@ map_update_random_key_value :: proc(t: ^testing.T) {
if !cond { if !cond {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Unexpected value. Expected m[%v] = %v, got %v", k, v, m[k])) testing.expectf(t, false, "Unexpected value. Expected m[%v] = %v, got %v", k, v, m[k])
} }
} }
seed_incr += 1 seed_incr += 1
@@ -127,12 +123,12 @@ map_update_random_key_value :: proc(t: ^testing.T) {
map_delete_random_key_value :: proc(t: ^testing.T) { map_delete_random_key_value :: proc(t: ^testing.T) {
seed_incr := u64(0) seed_incr := u64(0)
for entries in ENTRY_COUNTS { for entries in ENTRY_COUNTS {
fmt.printf("[map_delete_random_key_value] Testing %v entries.\n", entries) log.infof("Testing %v entries", entries)
m: map[i64]i64 m: map[i64]i64
defer delete(m) defer delete(m)
unique_keys := 0 unique_keys := 0
r := rand.create(seed + seed_incr) r := rand.create(t.seed + seed_incr)
for _ in 0..<entries { for _ in 0..<entries {
k := rand.int63(&r) k := rand.int63(&r)
v := rand.int63(&r) v := rand.int63(&r)
@@ -148,13 +144,13 @@ map_delete_random_key_value :: proc(t: ^testing.T) {
key_count += 1 key_count += 1
} }
expect(t, key_count == unique_keys, fmt.tprintf("Expected key_count to equal %v, got %v", unique_keys, key_count)) testing.expectf(t, key_count == unique_keys, "Expected key_count to equal %v, got %v", unique_keys, key_count)
expect(t, len(m) == unique_keys, fmt.tprintf("Expected len(map) to equal %v, got %v", unique_keys, len(m))) testing.expectf(t, len(m) == unique_keys, "Expected len(map) to equal %v, got %v", unique_keys, len(m))
half_entries := entries / 2 half_entries := entries / 2
// Reset randomizer and delete half the entries // Reset randomizer and delete half the entries
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
for _ in 0..<half_entries { for _ in 0..<half_entries {
k := rand.int63(&r) k := rand.int63(&r)
_ = rand.int63(&r) _ = rand.int63(&r)
@@ -163,7 +159,7 @@ map_delete_random_key_value :: proc(t: ^testing.T) {
} }
// Reset randomizer and verify // Reset randomizer and verify
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
num_fails := 0 num_fails := 0
for i in 0..<entries { for i in 0..<entries {
@@ -174,26 +170,26 @@ map_delete_random_key_value :: proc(t: ^testing.T) {
if k in m { if k in m {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Unexpected key present. Expected m[%v] to have been deleted, got %v", k, m[k])) testing.expectf(t, false, "Unexpected key present. Expected m[%v] to have been deleted, got %v", k, m[k])
} }
} else { } else {
if k not_in m { if k not_in m {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Expected key not present. Expected m[%v] = %v", k, v)) testing.expectf(t, false, "Expected key not present. Expected m[%v] = %v", k, v)
} else if m[k] != v { } else if m[k] != v {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Unexpected value. Expected m[%v] = %v, got %v", k, v, m[k])) testing.expectf(t, false, "Unexpected value. Expected m[%v] = %v, got %v", k, v, m[k])
} }
} }
} }
@@ -205,12 +201,12 @@ map_delete_random_key_value :: proc(t: ^testing.T) {
set_insert_random_key_value :: proc(t: ^testing.T) { set_insert_random_key_value :: proc(t: ^testing.T) {
seed_incr := u64(0) seed_incr := u64(0)
for entries in ENTRY_COUNTS { for entries in ENTRY_COUNTS {
fmt.printf("[set_insert_random_key_value] Testing %v entries.\n", entries) log.infof("Testing %v entries", entries)
m: map[i64]struct{} m: map[i64]struct{}
defer delete(m) defer delete(m)
unique_keys := 0 unique_keys := 0
r := rand.create(seed + seed_incr) r := rand.create(t.seed + seed_incr)
for _ in 0..<entries { for _ in 0..<entries {
k := rand.int63(&r) k := rand.int63(&r)
if k not_in m { if k not_in m {
@@ -224,11 +220,11 @@ set_insert_random_key_value :: proc(t: ^testing.T) {
key_count += 1 key_count += 1
} }
expect(t, key_count == unique_keys, fmt.tprintf("Expected key_count to equal %v, got %v", unique_keys, key_count)) testing.expectf(t, key_count == unique_keys, "Expected key_count to equal %v, got %v", unique_keys, key_count)
expect(t, len(m) == unique_keys, fmt.tprintf("Expected len(map) to equal %v, got %v", unique_keys, len(m))) testing.expectf(t, len(m) == unique_keys, "Expected len(map) to equal %v, got %v", unique_keys, len(m))
// Reset randomizer and verify // Reset randomizer and verify
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
num_fails := 0 num_fails := 0
for _ in 0..<entries { for _ in 0..<entries {
@@ -238,10 +234,10 @@ set_insert_random_key_value :: proc(t: ^testing.T) {
if !cond { if !cond {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Unexpected value. Expected m[%v] to exist", k)) testing.expectf(t, false, "Unexpected value. Expected m[%v] to exist", k)
} }
} }
seed_incr += 1 seed_incr += 1
@@ -252,12 +248,12 @@ set_insert_random_key_value :: proc(t: ^testing.T) {
set_delete_random_key_value :: proc(t: ^testing.T) { set_delete_random_key_value :: proc(t: ^testing.T) {
seed_incr := u64(0) seed_incr := u64(0)
for entries in ENTRY_COUNTS { for entries in ENTRY_COUNTS {
fmt.printf("[set_delete_random_key_value] Testing %v entries.\n", entries) log.infof("Testing %v entries", entries)
m: map[i64]struct{} m: map[i64]struct{}
defer delete(m) defer delete(m)
unique_keys := 0 unique_keys := 0
r := rand.create(seed + seed_incr) r := rand.create(t.seed + seed_incr)
for _ in 0..<entries { for _ in 0..<entries {
k := rand.int63(&r) k := rand.int63(&r)
@@ -272,20 +268,20 @@ set_delete_random_key_value :: proc(t: ^testing.T) {
key_count += 1 key_count += 1
} }
expect(t, key_count == unique_keys, fmt.tprintf("Expected key_count to equal %v, got %v", unique_keys, key_count)) testing.expectf(t, key_count == unique_keys, "Expected key_count to equal %v, got %v", unique_keys, key_count)
expect(t, len(m) == unique_keys, fmt.tprintf("Expected len(map) to equal %v, got %v", unique_keys, len(m))) testing.expectf(t, len(m) == unique_keys, "Expected len(map) to equal %v, got %v", unique_keys, len(m))
half_entries := entries / 2 half_entries := entries / 2
// Reset randomizer and delete half the entries // Reset randomizer and delete half the entries
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
for _ in 0..<half_entries { for _ in 0..<half_entries {
k := rand.int63(&r) k := rand.int63(&r)
delete_key(&m, k) delete_key(&m, k)
} }
// Reset randomizer and verify // Reset randomizer and verify
r = rand.create(seed + seed_incr) r = rand.create(t.seed + seed_incr)
num_fails := 0 num_fails := 0
for i in 0..<entries { for i in 0..<entries {
@@ -295,88 +291,22 @@ set_delete_random_key_value :: proc(t: ^testing.T) {
if k in m { if k in m {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Unexpected key present. Expected m[%v] to have been deleted", k)) testing.expectf(t, false, "Unexpected key present. Expected m[%v] to have been deleted", k)
} }
} else { } else {
if k not_in m { if k not_in m {
num_fails += 1 num_fails += 1
if num_fails > 5 { if num_fails > 5 {
fmt.println("... and more") log.info("... and more")
break break
} }
expect(t, false, fmt.tprintf("Expected key not present. Expected m[%v] to exist", k)) testing.expectf(t, false, "Expected key not present. Expected m[%v] to exist", k)
} }
} }
} }
seed_incr += 1 seed_incr += 1
} }
} }
// -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
main :: proc() {
t := testing.T{}
// Allow tests to be repeatable
SEED :: #config(SEED, -1)
when SEED > 0 {
seed = u64(SEED)
} else {
seed = u64(intrinsics.read_cycle_counter())
}
fmt.println("Initialized seed to", seed)
mem_track_test(&t, map_insert_random_key_value)
mem_track_test(&t, map_update_random_key_value)
mem_track_test(&t, map_delete_random_key_value)
mem_track_test(&t, set_insert_random_key_value)
mem_track_test(&t, set_delete_random_key_value)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
mem_track_test :: proc(t: ^testing.T, test: proc(t: ^testing.T)) {
track: mem.Tracking_Allocator
mem.tracking_allocator_init(&track, context.allocator)
context.allocator = mem.tracking_allocator(&track)
test(t)
expect(t, len(track.allocation_map) == 0, "Expected no leaks.")
expect(t, len(track.bad_free_array) == 0, "Expected no leaks.")
for _, leak in track.allocation_map {
fmt.printf("%v leaked %v bytes\n", leak.location, leak.size)
}
for bad_free in track.bad_free_array {
fmt.printf("%v allocation %p was freed badly\n", bad_free.location, bad_free.memory)
}
}
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.printf("[%v] %v\n", loc, message)
return
}
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
+5 -41
View File
@@ -1,8 +1,7 @@
package test_internal_math_pow package test_internal_math_pow
import "core:fmt" @(require) import "core:log"
import "core:math" import "core:math"
import "core:os"
import "core:testing" import "core:testing"
@test @test
@@ -19,14 +18,14 @@ pow_test :: proc(t: ^testing.T) {
// pow2_f64 returns the same float on all platforms because it isn't this stupid // pow2_f64 returns the same float on all platforms because it isn't this stupid
_v1 = 0h00000000_00000000 _v1 = 0h00000000_00000000
} }
expect(t, _v1 == _v2, fmt.tprintf("Expected math.pow2_f64(%d) == math.pow(2, %d) (= %16x), got %16x", exp, exp, _v1, _v2)) testing.expectf(t, _v1 == _v2, "Expected math.pow2_f64(%d) == math.pow(2, %d) (= %16x), got %16x", exp, exp, _v1, _v2)
} }
{ {
v1 := math.pow(2, f32(exp)) v1 := math.pow(2, f32(exp))
v2 := math.pow2_f32(exp) v2 := math.pow2_f32(exp)
_v1 := transmute(u32)v1 _v1 := transmute(u32)v1
_v2 := transmute(u32)v2 _v2 := transmute(u32)v2
expect(t, _v1 == _v2, fmt.tprintf("Expected math.pow2_f32(%d) == math.pow(2, %d) (= %08x), got %08x", exp, exp, _v1, _v2)) testing.expectf(t, _v1 == _v2, "Expected math.pow2_f32(%d) == math.pow(2, %d) (= %08x), got %08x", exp, exp, _v1, _v2)
} }
{ {
v1 := math.pow(2, f16(exp)) v1 := math.pow(2, f16(exp))
@@ -36,46 +35,11 @@ pow_test :: proc(t: ^testing.T) {
when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 { when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 {
if exp == -25 { if exp == -25 {
testing.logf(t, "skipping known test failure on darwin+arm64, Expected math.pow2_f16(-25) == math.pow(2, -25) (= 0000), got 0001") log.info("skipping known test failure on darwin+arm64, Expected math.pow2_f16(-25) == math.pow(2, -25) (= 0000), got 0001")
_v2 = 0 _v2 = 0
} }
} }
testing.expectf(t, _v1 == _v2, "Expected math.pow2_f16(%d) == math.pow(2, %d) (= %04x), got %04x", exp, exp, _v1, _v2)
expect(t, _v1 == _v2, fmt.tprintf("Expected math.pow2_f16(%d) == math.pow(2, %d) (= %04x), got %04x", exp, exp, _v1, _v2))
} }
} }
} }
// -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
main :: proc() {
t := testing.T{}
pow_test(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.printf("[%v] %v\n", loc, message)
return
}
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
+7 -62
View File
@@ -1,11 +1,8 @@
package test_internal_rtti package test_internal_rtti
import "core:fmt" import "core:fmt"
import "core:mem"
import "core:os"
import "core:testing" import "core:testing"
Buggy_Struct :: struct { Buggy_Struct :: struct {
a: int, a: int,
b: bool, b: bool,
@@ -28,74 +25,22 @@ rtti_test :: proc(t: ^testing.T) {
for v, i in g_b { for v, i in g_b {
checksum += (i+1) * int(v) checksum += (i+1) * int(v)
} }
expect(t, checksum == 0, fmt.tprintf("Expected g_b to be zero-initialized, got %v", g_b)) testing.expectf(t, checksum == 0, "Expected g_b to be zero-initialized, got %v", g_b)
} }
{ {
checksum := 0 checksum := 0
for v, i in l_b { for v, i in l_b {
checksum += (i+1) * int(v) checksum += (i+1) * int(v)
} }
expect(t, checksum == 0, fmt.tprintf("Expected l_b to be zero-initialized, got %v", l_b)) testing.expectf(t, checksum == 0, "Expected l_b to be zero-initialized, got %v", l_b)
} }
expect(t, size_of(Buggy_Struct) == 40, fmt.tprintf("Expected size_of(Buggy_Struct) == 40, got %v", size_of(Buggy_Struct))) testing.expectf(t, size_of(Buggy_Struct) == 40, "Expected size_of(Buggy_Struct) == 40, got %v", size_of(Buggy_Struct))
expect(t, size_of(g_buggy) == 40, fmt.tprintf("Expected size_of(g_buggy) == 40, got %v", size_of(g_buggy))) testing.expectf(t, size_of(g_buggy) == 40, "Expected size_of(g_buggy) == 40, got %v", size_of(g_buggy))
expect(t, size_of(l_buggy) == 40, fmt.tprintf("Expected size_of(l_buggy) == 40, got %v", size_of(l_buggy))) testing.expectf(t, size_of(l_buggy) == 40, "Expected size_of(l_buggy) == 40, got %v", size_of(l_buggy))
g_s := fmt.tprintf("%s", g_buggy) g_s := fmt.tprintf("%s", g_buggy)
l_s := fmt.tprintf("%s", l_buggy) l_s := fmt.tprintf("%s", l_buggy)
expect(t, g_s == EXPECTED_REPR, fmt.tprintf("Expected fmt.tprintf(\"%%s\", g_s)) to return \"%v\", got \"%v\"", EXPECTED_REPR, g_s)) testing.expectf(t, g_s == EXPECTED_REPR, "Expected fmt.tprintf(\"%%s\", g_s)) to return \"%v\", got \"%v\"", EXPECTED_REPR, g_s)
expect(t, l_s == EXPECTED_REPR, fmt.tprintf("Expected fmt.tprintf(\"%%s\", l_s)) to return \"%v\", got \"%v\"", EXPECTED_REPR, l_s)) testing.expectf(t, l_s == EXPECTED_REPR, "Expected fmt.tprintf(\"%%s\", l_s)) to return \"%v\", got \"%v\"", EXPECTED_REPR, l_s)
}
// -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
main :: proc() {
t := testing.T{}
mem_track_test(&t, rtti_test)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
mem_track_test :: proc(t: ^testing.T, test: proc(t: ^testing.T)) {
track: mem.Tracking_Allocator
mem.tracking_allocator_init(&track, context.allocator)
context.allocator = mem.tracking_allocator(&track)
test(t)
expect(t, len(track.allocation_map) == 0, "Expected no leaks.")
expect(t, len(track.bad_free_array) == 0, "Expected no leaks.")
for _, leak in track.allocation_map {
fmt.printf("%v leaked %v bytes\n", leak.location, leak.size)
}
for bad_free in track.bad_free_array {
fmt.printf("%v allocation %p was freed badly\n", bad_free.location, bad_free.memory)
}
}
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.printf("[%v] %v\n", loc, message)
return
}
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
} }
+12 -48
View File
@@ -1,7 +1,5 @@
package test_internal_string_compare package test_internal_string_compare
import "core:fmt"
import "core:os"
import "core:testing" import "core:testing"
Op :: enum { Eq, Lt, Gt } Op :: enum { Eq, Lt, Gt }
@@ -29,65 +27,31 @@ string_compare :: proc(t: ^testing.T) {
for res, op in v.res { for res, op in v.res {
switch op { switch op {
case .Eq: case .Eq:
expect(t, (v.a == v.b) == res, fmt.tprintf("Expected cstring(\"%v\") == cstring(\"%v\") to be %v", v.a, v.b, res)) testing.expectf(t, (v.a == v.b) == res, "Expected cstring(\"%v\") == cstring(\"%v\") to be %v", v.a, v.b, res)
expect(t, (s_a == s_b) == res, fmt.tprintf("Expected string(\"%v\") == string(\"%v\") to be %v", v.a, v.b, res)) testing.expectf(t, (s_a == s_b) == res, "Expected string(\"%v\") == string(\"%v\") to be %v", v.a, v.b, res)
// If a == b then a != b // If a == b then a != b
expect(t, (v.a != v.b) == !res, fmt.tprintf("Expected cstring(\"%v\") != cstring(\"%v\") to be %v", v.a, v.b, !res)) testing.expectf(t, (v.a != v.b) == !res, "Expected cstring(\"%v\") != cstring(\"%v\") to be %v", v.a, v.b, !res)
expect(t, (s_a != s_b) == !res, fmt.tprintf("Expected string(\"%v\") != string(\"%v\") to be %v", v.a, v.b, !res)) testing.expectf(t, (s_a != s_b) == !res, "Expected string(\"%v\") != string(\"%v\") to be %v", v.a, v.b, !res)
case .Lt: case .Lt:
expect(t, (v.a < v.b) == res, fmt.tprintf("Expected cstring(\"%v\") < cstring(\"%v\") to be %v", v.a, v.b, res)) testing.expectf(t, (v.a < v.b) == res, "Expected cstring(\"%v\") < cstring(\"%v\") to be %v", v.a, v.b, res)
expect(t, (s_a < s_b) == res, fmt.tprintf("Expected string(\"%v\") < string(\"%v\") to be %v", v.a, v.b, res)) testing.expectf(t, (s_a < s_b) == res, "Expected string(\"%v\") < string(\"%v\") to be %v", v.a, v.b, res)
// .Lt | .Eq == .LtEq // .Lt | .Eq == .LtEq
lteq := v.res[.Eq] | res lteq := v.res[.Eq] | res
expect(t, (v.a <= v.b) == lteq, fmt.tprintf("Expected cstring(\"%v\") <= cstring(\"%v\") to be %v", v.a, v.b, lteq)) testing.expectf(t, (v.a <= v.b) == lteq, "Expected cstring(\"%v\") <= cstring(\"%v\") to be %v", v.a, v.b, lteq)
expect(t, (s_a <= s_b) == lteq, fmt.tprintf("Expected string(\"%v\") <= string(\"%v\") to be %v", v.a, v.b, lteq)) testing.expectf(t, (s_a <= s_b) == lteq, "Expected string(\"%v\") <= string(\"%v\") to be %v", v.a, v.b, lteq)
case .Gt: case .Gt:
expect(t, (v.a > v.b) == res, fmt.tprintf("Expected cstring(\"%v\") > cstring(\"%v\") to be %v", v.a, v.b, res)) testing.expectf(t, (v.a > v.b) == res, "Expected cstring(\"%v\") > cstring(\"%v\") to be %v", v.a, v.b, res)
expect(t, (s_a > s_b) == res, fmt.tprintf("Expected string(\"%v\") > string(\"%v\") to be %v", v.a, v.b, res)) testing.expectf(t, (s_a > s_b) == res, "Expected string(\"%v\") > string(\"%v\") to be %v", v.a, v.b, res)
// .Gt | .Eq == .GtEq // .Gt | .Eq == .GtEq
gteq := v.res[.Eq] | res gteq := v.res[.Eq] | res
expect(t, (v.a >= v.b) == gteq, fmt.tprintf("Expected cstring(\"%v\") >= cstring(\"%v\") to be %v", v.a, v.b, gteq)) testing.expectf(t, (v.a >= v.b) == gteq, "Expected cstring(\"%v\") >= cstring(\"%v\") to be %v", v.a, v.b, gteq)
expect(t, (s_a >= s_b) == gteq, fmt.tprintf("Expected string(\"%v\") >= string(\"%v\") to be %v", v.a, v.b, gteq)) testing.expectf(t, (s_a >= s_b) == gteq, "Expected string(\"%v\") >= string(\"%v\") to be %v", v.a, v.b, gteq)
} }
} }
} }
} }
// -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
main :: proc() {
t := testing.T{}
string_compare(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.printf("[%v] %v\n", loc, message)
return
}
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
+10 -10
View File
@@ -3,19 +3,19 @@
if not exist "build\" mkdir build if not exist "build\" mkdir build
pushd build pushd build
set COMMON=-collection:tests=..\.. -define:ODIN_TEST_FANCY=false set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style
@echo on @echo on
..\..\..\odin test ..\test_issue_829.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_829.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_1592.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_2056.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_2056.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_2087.odin %COMMON% || exit /b
..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug || exit /b ..\..\..\odin build ..\test_issue_2113.odin %COMMON% -debug || exit /b
..\..\..\odin test ..\test_issue_2466.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_2466.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_2615.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_2615.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_2637.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_2637.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_2666.odin %COMMON% -file || exit /b ..\..\..\odin test ..\test_issue_2666.odin %COMMON% || exit /b
@echo off @echo off
+11 -11
View File
@@ -4,22 +4,22 @@ set -eu
mkdir -p build mkdir -p build
pushd build pushd build
ODIN=../../../odin ODIN=../../../odin
COMMON="-collection:tests=../.. -define:ODIN_TEST_FANCY=false" COMMON="-define:ODIN_TEST_FANCY=false -file -vet -strict-style"
NO_NIL_ERR="Error: " NO_NIL_ERR="Error: "
set -x set -x
$ODIN test ../test_issue_829.odin $COMMON -file $ODIN test ../test_issue_829.odin $COMMON
$ODIN test ../test_issue_1592.odin $COMMON -file $ODIN test ../test_issue_1592.odin $COMMON
$ODIN test ../test_issue_2056.odin $COMMON -file $ODIN test ../test_issue_2056.odin $COMMON
$ODIN test ../test_issue_2087.odin $COMMON -file $ODIN test ../test_issue_2087.odin $COMMON
$ODIN build ../test_issue_2113.odin $COMMON -file -debug $ODIN build ../test_issue_2113.odin $COMMON -debug
$ODIN test ../test_issue_2466.odin $COMMON -file $ODIN test ../test_issue_2466.odin $COMMON
$ODIN test ../test_issue_2615.odin $COMMON -file $ODIN test ../test_issue_2615.odin $COMMON
$ODIN test ../test_issue_2637.odin $COMMON -file $ODIN test ../test_issue_2637.odin $COMMON
$ODIN test ../test_issue_2666.odin $COMMON -file $ODIN test ../test_issue_2666.odin $COMMON
if [[ $($ODIN build ../test_issue_2395.odin $COMMON -file 2>&1 >/dev/null | grep -c "$NO_NIL_ERR") -eq 2 ]] ; then if [[ $($ODIN build ../test_issue_2395.odin $COMMON 2>&1 >/dev/null | grep -c "$NO_NIL_ERR") -eq 2 ]] ; then
echo "SUCCESSFUL 1/1" echo "SUCCESSFUL 1/1"
else else
echo "SUCCESSFUL 0/1" echo "SUCCESSFUL 0/1"
+146 -147
View File
@@ -1,7 +1,6 @@
// Tests issue #1592 https://github.com/odin-lang/Odin/issues/1592 // Tests issue #1592 https://github.com/odin-lang/Odin/issues/1592
package test_issues package test_issues
import "core:fmt"
import "core:testing" import "core:testing"
/* Original issue #1592 example */ /* Original issue #1592 example */
@@ -31,428 +30,428 @@ true_result :: proc() -> bool {
@test @test
test_simple_const_false :: proc(t: ^testing.T) { test_simple_const_false :: proc(t: ^testing.T) {
if CONSTANT_FALSE { if CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if (CONSTANT_FALSE) { if (CONSTANT_FALSE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !CONSTANT_FALSE { if !CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if (!CONSTANT_FALSE) { if (!CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(CONSTANT_FALSE) { if !(CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !!CONSTANT_FALSE { if !!CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_FALSE == true { if CONSTANT_FALSE == true {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_FALSE == false { if CONSTANT_FALSE == false {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(CONSTANT_FALSE == true) { if !(CONSTANT_FALSE == true) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(CONSTANT_FALSE == false) { if !(CONSTANT_FALSE == false) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
} }
@test @test
test_simple_const_true :: proc(t: ^testing.T) { test_simple_const_true :: proc(t: ^testing.T) {
if CONSTANT_TRUE { if CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if (CONSTANT_TRUE) { if (CONSTANT_TRUE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !CONSTANT_TRUE { if !CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if (!CONSTANT_TRUE) { if (!CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if (!CONSTANT_TRUE) { if (!CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_TRUE) { if !(CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !!CONSTANT_TRUE { if !!CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_TRUE == true { if CONSTANT_TRUE == true {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_TRUE == false { if CONSTANT_TRUE == false {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_TRUE == true) { if !(CONSTANT_TRUE == true) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_TRUE == false) { if !(CONSTANT_TRUE == false) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_simple_proc_false :: proc(t: ^testing.T) { test_simple_proc_false :: proc(t: ^testing.T) {
if false_result() { if false_result() {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !false_result() { if !false_result() {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_simple_proc_true :: proc(t: ^testing.T) { test_simple_proc_true :: proc(t: ^testing.T) {
if true_result() { if true_result() {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !true_result() { if !true_result() {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
} }
@test @test
test_const_false_const_false :: proc(t: ^testing.T) { test_const_false_const_false :: proc(t: ^testing.T) {
if CONSTANT_FALSE || CONSTANT_FALSE { if CONSTANT_FALSE || CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_FALSE && CONSTANT_FALSE { if CONSTANT_FALSE && CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !CONSTANT_FALSE || CONSTANT_FALSE { if !CONSTANT_FALSE || CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !CONSTANT_FALSE && CONSTANT_FALSE { if !CONSTANT_FALSE && CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_FALSE || !CONSTANT_FALSE { if CONSTANT_FALSE || !CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_FALSE && !CONSTANT_FALSE { if CONSTANT_FALSE && !CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_FALSE || CONSTANT_FALSE) { if !(CONSTANT_FALSE || CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(CONSTANT_FALSE && CONSTANT_FALSE) { if !(CONSTANT_FALSE && CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_const_false_const_true :: proc(t: ^testing.T) { test_const_false_const_true :: proc(t: ^testing.T) {
if CONSTANT_FALSE || CONSTANT_TRUE { if CONSTANT_FALSE || CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_FALSE && CONSTANT_TRUE { if CONSTANT_FALSE && CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !CONSTANT_FALSE || CONSTANT_TRUE { if !CONSTANT_FALSE || CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !CONSTANT_FALSE && CONSTANT_TRUE { if !CONSTANT_FALSE && CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_FALSE || !CONSTANT_TRUE { if CONSTANT_FALSE || !CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_FALSE && !CONSTANT_TRUE { if CONSTANT_FALSE && !CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_FALSE || CONSTANT_TRUE) { if !(CONSTANT_FALSE || CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_FALSE && CONSTANT_TRUE) { if !(CONSTANT_FALSE && CONSTANT_TRUE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_const_true_const_false :: proc(t: ^testing.T) { test_const_true_const_false :: proc(t: ^testing.T) {
if CONSTANT_TRUE || CONSTANT_FALSE { if CONSTANT_TRUE || CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_TRUE && CONSTANT_FALSE { if CONSTANT_TRUE && CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !CONSTANT_TRUE || CONSTANT_FALSE { if !CONSTANT_TRUE || CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !CONSTANT_TRUE && CONSTANT_FALSE { if !CONSTANT_TRUE && CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_TRUE || !CONSTANT_FALSE { if CONSTANT_TRUE || !CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_TRUE && !CONSTANT_FALSE { if CONSTANT_TRUE && !CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(CONSTANT_TRUE || CONSTANT_FALSE) { if !(CONSTANT_TRUE || CONSTANT_FALSE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_TRUE && CONSTANT_FALSE) { if !(CONSTANT_TRUE && CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_const_true_const_true :: proc(t: ^testing.T) { test_const_true_const_true :: proc(t: ^testing.T) {
if CONSTANT_TRUE || CONSTANT_TRUE { if CONSTANT_TRUE || CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_TRUE && CONSTANT_TRUE { if CONSTANT_TRUE && CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !CONSTANT_TRUE || CONSTANT_TRUE { if !CONSTANT_TRUE || CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !CONSTANT_TRUE && CONSTANT_TRUE { if !CONSTANT_TRUE && CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if CONSTANT_TRUE || !CONSTANT_TRUE { if CONSTANT_TRUE || !CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if CONSTANT_TRUE && !CONSTANT_TRUE { if CONSTANT_TRUE && !CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_TRUE || CONSTANT_TRUE) { if !(CONSTANT_TRUE || CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(CONSTANT_TRUE && CONSTANT_TRUE) { if !(CONSTANT_TRUE && CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
} }
@test @test
test_proc_false_const_false :: proc(t: ^testing.T) { test_proc_false_const_false :: proc(t: ^testing.T) {
if false_result() || CONSTANT_FALSE { if false_result() || CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if false_result() && CONSTANT_FALSE { if false_result() && CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(false_result() || CONSTANT_FALSE) { if !(false_result() || CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(false_result() && CONSTANT_FALSE) { if !(false_result() && CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_proc_false_const_true :: proc(t: ^testing.T) { test_proc_false_const_true :: proc(t: ^testing.T) {
if false_result() || CONSTANT_TRUE { if false_result() || CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if false_result() && CONSTANT_TRUE { if false_result() && CONSTANT_TRUE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(false_result() || CONSTANT_TRUE) { if !(false_result() || CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(false_result() && CONSTANT_TRUE) { if !(false_result() && CONSTANT_TRUE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_proc_true_const_false :: proc(t: ^testing.T) { test_proc_true_const_false :: proc(t: ^testing.T) {
if true_result() || CONSTANT_FALSE { if true_result() || CONSTANT_FALSE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if true_result() && CONSTANT_FALSE { if true_result() && CONSTANT_FALSE {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(true_result() || CONSTANT_FALSE) { if !(true_result() || CONSTANT_FALSE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(true_result() && CONSTANT_FALSE) { if !(true_result() && CONSTANT_FALSE) {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
} }
@test @test
test_proc_true_const_true :: proc(t: ^testing.T) { test_proc_true_const_true :: proc(t: ^testing.T) {
if true_result() || CONSTANT_TRUE { if true_result() || CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if true_result() && CONSTANT_TRUE { if true_result() && CONSTANT_TRUE {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} else { } else {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} }
if !(true_result() || CONSTANT_TRUE) { if !(true_result() || CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
if !(true_result() && CONSTANT_TRUE) { if !(true_result() && CONSTANT_TRUE) {
testing.expect(t, false, fmt.tprintf("%s: !false\n", #procedure)) testing.expect(t, false, "!false")
} else { } else {
testing.expect(t, true, fmt.tprintf("%s: !true\n", #procedure)) testing.expect(t, true, "!true")
} }
} }
+2 -3
View File
@@ -1,7 +1,6 @@
// Tests issue #2056 https://github.com/odin-lang/Odin/issues/2056 // Tests issue #2056 https://github.com/odin-lang/Odin/issues/2056
package test_issues package test_issues
import "core:fmt"
import "core:testing" import "core:testing"
@test @test
@@ -12,9 +11,9 @@ test_scalar_matrix_conversion :: proc(t: ^testing.T) {
for i in 0..<4 { for i in 0..<4 {
for j in 0..<4 { for j in 0..<4 {
if i == j { if i == j {
testing.expect(t, m[i,j] == 1, fmt.tprintf("expected 1 at m[%d,%d], found %f\n", i, j, m[i,j])) testing.expectf(t, m[i,j] == 1, "expected 1 at m[%d,%d], found %f\n", i, j, m[i,j])
} else { } else {
testing.expect(t, m[i,j] == 0, fmt.tprintf("expected 0 at m[%d,%d], found %f\n", i, j, m[i,j])) testing.expectf(t, m[i,j] == 0, "expected 0 at m[%d,%d], found %f\n", i, j, m[i,j])
} }
} }
} }
+2 -3
View File
@@ -1,7 +1,6 @@
// Tests issue #2466 https://github.com/odin-lang/Odin/issues/2466 // Tests issue #2466 https://github.com/odin-lang/Odin/issues/2466
package test_issues package test_issues
import "core:fmt"
import "core:testing" import "core:testing"
Bug :: struct { Bug :: struct {
@@ -16,7 +15,7 @@ test_compound_literal_local_reuse :: proc(t: ^testing.T) {
val = v, val = v,
arr = {42}, arr = {42},
} }
testing.expect(t, bug.val == 123, fmt.tprintf("expected 123, found %d", bug.val)) testing.expectf(t, bug.val == 123, "expected 123, found %d", bug.val)
testing.expect(t, bug.arr[0] == 42, fmt.tprintf("expected 42, found %d", bug.arr[0])) testing.expectf(t, bug.arr[0] == 42, "expected 42, found %d", bug.arr[0])
} }
+2 -3
View File
@@ -1,7 +1,6 @@
// Tests issue #829 https://github.com/odin-lang/Odin/issues/829 // Tests issue #829 https://github.com/odin-lang/Odin/issues/829
package test_issues package test_issues
import "core:fmt"
import "core:testing" import "core:testing"
/* Original issue #829 example */ /* Original issue #829 example */
@@ -13,6 +12,6 @@ env : map[string]proc(a, b : int) -> int = {
@(test) @(test)
test_orig_ret :: proc(t: ^testing.T) { test_orig_ret :: proc(t: ^testing.T) {
r := fmt.tprint(env["+"](1, 2)) r := env["+"](1, 2)
testing.expect(t, r == "3", fmt.tprintf("%s: \"%s\" != \"3\"\n", #procedure, r)) testing.expectf(t, r == 3, "%q != 3", r)
} }
+1 -1
View File
@@ -5,4 +5,4 @@ set PATH_TO_ODIN==..\..\odin
echo --- echo ---
echo Running vendor:glfw tests echo Running vendor:glfw tests
echo --- echo ---
%PATH_TO_ODIN% run glfw %COMMON% -out:vendor_glfw.exe || exit /b %PATH_TO_ODIN% test glfw %COMMON% -out:vendor_glfw.exe || exit /b
+8 -36
View File
@@ -1,49 +1,21 @@
package test_vendor_glfw package test_vendor_glfw
import "core:testing" import "core:testing"
import "core:fmt"
import "vendor:glfw" import "vendor:glfw"
import "core:os"
GLFW_MAJOR :: 3 GLFW_MAJOR :: 3
GLFW_MINOR :: 4 GLFW_MINOR :: 4
GLFW_PATCH :: 0 GLFW_PATCH :: 0
TEST_count := 0
TEST_fail := 0
when ODIN_TEST {
expect :: testing.expect
log :: testing.log
} else {
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
fmt.printf("[%v] ", loc)
TEST_count += 1
if !condition {
TEST_fail += 1
fmt.println(message)
return
}
fmt.println(" PASS")
}
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
fmt.printf("[%v] ", loc)
fmt.printf("log: %v\n", v)
}
}
main :: proc() {
t := testing.T{}
test_glfw(&t)
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
if TEST_fail > 0 {
os.exit(1)
}
}
@(test) @(test)
test_glfw :: proc(t: ^testing.T) { test_glfw :: proc(t: ^testing.T) {
major, minor, patch := glfw.GetVersion() major, minor, patch := glfw.GetVersion()
expect(t, major == GLFW_MAJOR && minor == GLFW_MINOR, fmt.tprintf("Expected GLFW.GetVersion: %v.%v.%v, got %v.%v.%v instead", GLFW_MAJOR, GLFW_MINOR, GLFW_PATCH, major, minor, patch)) testing.expectf(
t,
major == GLFW_MAJOR && \
minor == GLFW_MINOR,
"Expected GLFW.GetVersion: %v.%v.%v, got %v.%v.%v instead",
GLFW_MAJOR, GLFW_MINOR, GLFW_PATCH,
major, minor, patch,
)
} }