aboutsummaryrefslogtreecommitdiff
path: root/tests/internal/test_128.odin
blob: 11ef068edfde6f4f6915fde65a300d867bd52cb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package test_128

import "core:fmt"
import "core:os"
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_128_align :: proc(t: ^testing.T) {
	Danger_Struct :: struct {
		x: u128,
		y: u64,
	}

	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))
	expect(t, list[0].y == 0, fmt.tprintf("[0].y (%v) != 0", list[0].y))

	expect(t, list[1].x == 1, fmt.tprintf("[1].x (%v) != 1", list[1].x))
	expect(t, list[1].y == 0, fmt.tprintf("[1].y (%v) != 0", list[1].y))

	expect(t, list[2].x == 2, fmt.tprintf("[2].x (%v) != 2", list[2].x))
	expect(t, list[2].y == 0, fmt.tprintf("[2].y (%v) != 0", list[2].y))

	expect(t, list[3].x == 3, fmt.tprintf("[3].x (%v) != 3", list[3].x))
	expect(t, list[3].y == 0, fmt.tprintf("[3].y (%v) != 0", list[3].y))
}