tests: fix failure of test test_stlb_write()
Compiler: GCC v4.9.2 OS : linux-x64
This commit is contained in:
parent
fd19fa0726
commit
035e9c2ba6
@ -36,7 +36,7 @@ gmio_stl_triangle_array_t gmio_stl_triangle_array_malloc(size_t tri_count)
|
||||
gmio_stl_triangle_array_t array = {0};
|
||||
if (tri_count > 0) {
|
||||
array.ptr =
|
||||
(gmio_stl_triangle_t*)malloc(tri_count * sizeof(gmio_stl_triangle_t));
|
||||
(gmio_stl_triangle_t*)calloc(tri_count, sizeof(gmio_stl_triangle_t));
|
||||
}
|
||||
array.count = gmio_size_to_uint32(tri_count);
|
||||
array.capacity = array.count;
|
||||
@ -83,7 +83,7 @@ static void gmio_stl_data__add_triangle(
|
||||
realloc(data->tri_array.ptr, cap * sizeof(gmio_stl_triangle_t));
|
||||
data->tri_array.capacity = cap;
|
||||
}
|
||||
data->tri_array.ptr[tri_id] = *triangle;
|
||||
memcpy(&data->tri_array.ptr[tri_id], triangle, GMIO_STLB_TRIANGLE_RAWSIZE);
|
||||
data->tri_array.count = GMIO_MAX(data->tri_array.count, tri_id + 1);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,11 @@ struct gmio_stl_triangle_array
|
||||
};
|
||||
typedef struct gmio_stl_triangle_array gmio_stl_triangle_array_t;
|
||||
|
||||
/*! Returns an dynamically allocated array of gmio_stl_triangle_t */
|
||||
/*! Returns an dynamically allocated array of gmio_stl_triangle_t
|
||||
*
|
||||
* Contents of the memory block beginnning at gmio_stl_triangle_array::ptr
|
||||
* is initialized with zeroes
|
||||
*/
|
||||
gmio_stl_triangle_array_t gmio_stl_triangle_array_malloc(size_t tri_count);
|
||||
|
||||
/*! Holds complete STL data (usable for both binary and ascii formats) */
|
||||
|
@ -265,15 +265,16 @@ const char* test_stlb_write()
|
||||
|
||||
/* Check output LE/BE models are equal */
|
||||
{
|
||||
const uint32_t le_tri_count = data.tri_array.count;
|
||||
const gmio_stl_triangle_t* le_tri_ptr = data.tri_array.ptr;
|
||||
gmio_stl_data_t data_be = {0};
|
||||
gmio_stl_mesh_creator_t creator = gmio_stl_data_mesh_creator(&data_be);
|
||||
error = gmio_stl_read_file(model_filepath_out_be, &creator, NULL);
|
||||
UTEST_ASSERT(error == GMIO_ERROR_OK);
|
||||
UTEST_ASSERT(gmio_stlb_header_equal(&data.header, &data_be.header));
|
||||
UTEST_ASSERT(le_tri_count == data_be.tri_array.count);
|
||||
UTEST_ASSERT(memcmp(le_tri_ptr, data_be.tri_array.ptr, le_tri_count) == 0);
|
||||
UTEST_ASSERT(data.tri_array.count == data_be.tri_array.count);
|
||||
UTEST_ASSERT(memcmp(data.tri_array.ptr,
|
||||
data_be.tri_array.ptr,
|
||||
data.tri_array.count * sizeof(gmio_stl_triangle_t))
|
||||
== 0);
|
||||
free(data_be.tri_array.ptr);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user