22 lines
635 B
C
22 lines
635 B
C
#include <cmocka.h>
|
|
#include <math.h>
|
|
|
|
#include "../src/minecraft.h"
|
|
|
|
static void test_parse_player_entity(void **state) {
|
|
(void)state;
|
|
|
|
player_entity_t entity = {0};
|
|
const char *response =
|
|
"Steve has the following entity data: [-1234.1234567891234d, 71.0d, 113.0000000000001d]";
|
|
|
|
assert_int_equal(parse_player_entity(response, &entity), 0);
|
|
assert_non_null(entity.name);
|
|
assert_string_equal(entity.name, "Steve");
|
|
assert_true(fabs(entity.x - (-1234.1234567891234)) < 1e-12);
|
|
assert_true(fabs(entity.y - 71.0) < 1e-12);
|
|
assert_true(fabs(entity.z - 113.0000000000001) < 1e-12);
|
|
|
|
free_player_entity(&entity);
|
|
}
|