smarter_test

This commit is contained in:
TheRadischen
2026-08-16 12:27:30 +02:00
parent df54692a9b
commit 3f851d2b02

View File

@@ -169,18 +169,22 @@ test_sort_stability :: proc(t: ^testing.T) {
// Verify sorted test values
rand.reset(t.seed)
sum := vals[0].index
for i in 1..<len(vals) {
if vals[i - 1].rand < vals[i].rand {
continue
}
if vals[i - 1].rand > vals[i].rand {
sum += vals[i].index
if vals[i-1].rand > vals[i].rand {
testing.expect(t, false, "Expected slice to be sorted")
}
if vals[i - 1].index > vals[i].index {
if vals[i-1].rand < vals[i].rand {
continue
}
if vals[i-1].index > vals[i].index {
testing.expect(t, false, "Expected slice to be stable")
}
}
testing.expect(t, sum == test_size * (test_size - 1) / 2, "Expected slice to have all indecies")
}
}