Fix MSVC Spectre warnings
This commit is contained in:
@@ -9,10 +9,15 @@ TestFuncResult test_i32_array(void) {
|
||||
result = array.count == 7 && array.capacity == 16;
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
item = wapp_i32_array_get(&array, i);
|
||||
result = result && item && (*item == (i32)(i + 1));
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)(index + 1));
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
@@ -33,10 +38,15 @@ TestFuncResult test_i32_array_get(void) {
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
item = wapp_i32_array_get(&array, i);
|
||||
result = result && item && (*item == (i32)i);
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)index);
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
@@ -48,11 +58,16 @@ TestFuncResult test_i32_array_set(void) {
|
||||
I32Array array = wapp_i32_array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
i32 *item;
|
||||
u64 count = array.count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
wapp_i32_array_set(&array, i, (i32)(i * 2));
|
||||
item = wapp_i32_array_get(&array, i);
|
||||
result = result && item && (*item == (i32)(i * 2));
|
||||
u64 count = array.count;
|
||||
u64 index = 0;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
wapp_i32_array_set(&array, index, (i32)(index * 2));
|
||||
item = wapp_i32_array_get(&array, index);
|
||||
result = result && item && (*item == (i32)(index * 2));
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
@@ -133,15 +148,27 @@ TestFuncResult test_i32_array_copy_capped(void) {
|
||||
u64 expected_count = 5;
|
||||
wapp_i32_array_copy_capped(&src, &dst1);
|
||||
result = dst1.count == expected_count;
|
||||
for (u64 i = 0; i < expected_count; ++i) {
|
||||
result = result && (*wapp_i32_array_get(&src, i) == *wapp_i32_array_get(&dst1, i));
|
||||
|
||||
u64 index = 0;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(&dst1, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
expected_count = 4;
|
||||
wapp_i32_array_copy_capped(&src, &dst2);
|
||||
result = result && dst2.count == expected_count;
|
||||
for (u64 i = 0; i < expected_count; ++i) {
|
||||
result = result && (*wapp_i32_array_get(&src, i) == *wapp_i32_array_get(&dst2, i));
|
||||
|
||||
index = 0;
|
||||
running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(&dst2, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
return wapp_tester_result(result);
|
||||
@@ -171,8 +198,14 @@ TestFuncResult test_i32_array_append_alloc(void) {
|
||||
I32Array *arr_ptr = wapp_i32_array_append_alloc(&allocator, &array1, 10);
|
||||
result = arr_ptr == &array1;
|
||||
|
||||
for (u64 i = 0; i < 4; ++i) {
|
||||
arr_ptr = wapp_i32_array_append_alloc(&allocator, &array2, (i32)i);
|
||||
u64 count = 4;
|
||||
u64 index = 0;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
arr_ptr = wapp_i32_array_append_alloc(&allocator, &array2, (i32)index);
|
||||
|
||||
++index;
|
||||
running = index < count;
|
||||
}
|
||||
result = result && arr_ptr != &array2;
|
||||
|
||||
@@ -212,15 +245,27 @@ TestFuncResult test_i32_array_copy_alloc(void) {
|
||||
u64 expected_count = 5;
|
||||
array_ptr = wapp_i32_array_copy_alloc(&allocator, &src, &dst1);
|
||||
result = array_ptr->count == expected_count && array_ptr == &dst1;
|
||||
for (u64 i = 0; i < expected_count; ++i) {
|
||||
result = result && (*wapp_i32_array_get(&src, i) == *wapp_i32_array_get(array_ptr, i));
|
||||
|
||||
u64 index = 0;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(array_ptr, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
expected_count = 5;
|
||||
array_ptr = wapp_i32_array_copy_alloc(&allocator, &src, &dst2);
|
||||
result = result && array_ptr->count == expected_count && array_ptr != &dst2;
|
||||
for (u64 i = 0; i < expected_count; ++i) {
|
||||
result = result && (*wapp_i32_array_get(&src, i) == *wapp_i32_array_get(array_ptr, i));
|
||||
|
||||
index = 0;
|
||||
running = true;
|
||||
while (running) {
|
||||
result = result && (*wapp_i32_array_get(&src, index) == *wapp_i32_array_get(array_ptr, index));
|
||||
|
||||
++index;
|
||||
running = index < expected_count;
|
||||
}
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&allocator);
|
||||
|
Reference in New Issue
Block a user