mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-07 21:43:15 +00:00
Add test for #4210
This commit is contained in:
@@ -15,6 +15,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style
|
||||
..\..\..\odin test ..\test_issue_2615.odin %COMMON% || exit /b
|
||||
..\..\..\odin test ..\test_issue_2637.odin %COMMON% || exit /b
|
||||
..\..\..\odin test ..\test_issue_2666.odin %COMMON% || exit /b
|
||||
..\..\..\odin test ..\test_issue_4210.odin %COMMON% || exit /b
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ $ODIN test ../test_issue_2466.odin $COMMON
|
||||
$ODIN test ../test_issue_2615.odin $COMMON
|
||||
$ODIN test ../test_issue_2637.odin $COMMON
|
||||
$ODIN test ../test_issue_2666.odin $COMMON
|
||||
$ODIN test ../test_issue_4210.odin $COMMON
|
||||
if [[ $($ODIN build ../test_issue_2395.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
|
||||
echo "SUCCESSFUL 1/1"
|
||||
else
|
||||
|
||||
85
tests/issues/test_issue_4210.odin
Normal file
85
tests/issues/test_issue_4210.odin
Normal file
@@ -0,0 +1,85 @@
|
||||
// Tests issue #4210 https://github.com/odin-lang/Odin/issues/4210
|
||||
package test_issues
|
||||
|
||||
import "core:testing"
|
||||
import "base:intrinsics"
|
||||
|
||||
@test
|
||||
test_row_major_matrix :: proc(t: ^testing.T) {
|
||||
row_major34: #row_major matrix[3,4]int = {
|
||||
11,12,13,14,
|
||||
21,22,23,24,
|
||||
31,32,33,34,
|
||||
}
|
||||
row_major34_expected := [?]int{11,12,13,14, 21,22,23,24, 31,32,33,34}
|
||||
|
||||
row_major43: #row_major matrix[4,3]int = {
|
||||
11,12,13,
|
||||
21,22,23,
|
||||
31,32,33,
|
||||
41,42,43,
|
||||
}
|
||||
row_major43_expected := [?]int{11,12,13, 21,22,23, 31,32,33, 41,42,43}
|
||||
|
||||
major34_flattened := intrinsics.matrix_flatten(row_major34)
|
||||
major34_casted := (^[3 * 4]int)(&row_major34)^
|
||||
|
||||
for row in 0..<3 {
|
||||
for column in 0..<4 {
|
||||
idx := row * 4 + column
|
||||
testing.expect_value(t, major34_flattened[idx], row_major34_expected[idx])
|
||||
testing.expect_value(t, major34_casted [idx], row_major34_expected[idx])
|
||||
}
|
||||
}
|
||||
|
||||
major43_flattened := intrinsics.matrix_flatten(row_major43)
|
||||
major43_casted := (^[4 * 3]int)(&row_major43)^
|
||||
|
||||
for row in 0..<4 {
|
||||
for column in 0..<3 {
|
||||
idx := row * 3 + column
|
||||
testing.expect_value(t, major43_flattened[idx], row_major43_expected[idx])
|
||||
testing.expect_value(t, major43_casted [idx], row_major43_expected[idx])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_row_minor_matrix :: proc(t: ^testing.T) {
|
||||
row_minor34: matrix[3,4]int = {
|
||||
11,12,13,14,
|
||||
21,22,23,24,
|
||||
31,32,33,34,
|
||||
}
|
||||
row_minor34_expected := [?]int{11,21,31, 12,22,32, 13,23,33, 14,24,34}
|
||||
|
||||
row_minor43: matrix[4,3]int = {
|
||||
11,12,13,
|
||||
21,22,23,
|
||||
31,32,33,
|
||||
41,42,43,
|
||||
}
|
||||
row_minor43_expected := [?]int{11,21,31,41, 12,22,32,42, 13,23,33,43}
|
||||
|
||||
minor34_flattened := intrinsics.matrix_flatten(row_minor34)
|
||||
minor34_casted := (^[3 * 4]int)(&row_minor34)^
|
||||
|
||||
for row in 0..<3 {
|
||||
for column in 0..<4 {
|
||||
idx := row * 4 + column
|
||||
testing.expect_value(t, minor34_flattened[idx], row_minor34_expected[idx])
|
||||
testing.expect_value(t, minor34_casted [idx], row_minor34_expected[idx])
|
||||
}
|
||||
}
|
||||
|
||||
minor43_flattened := intrinsics.matrix_flatten(row_minor43)
|
||||
minor43_casted := (^[4 * 3]int)(&row_minor43)^
|
||||
|
||||
for row in 0..<4 {
|
||||
for column in 0..<3 {
|
||||
idx := row * 3 + column
|
||||
testing.expect_value(t, minor43_flattened[idx], row_minor43_expected[idx])
|
||||
testing.expect_value(t, minor43_casted [idx], row_minor43_expected[idx])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user