mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-18 03:12:10 +00:00
smarter_test
This commit is contained in:
@@ -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")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user