Fix compiler warnings in unit tests (#1373)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss 2016-09-22 15:48:14 +02:00 committed by GitHub
parent e4f27199d7
commit 40bed0f963
2 changed files with 22 additions and 7 deletions

View File

@ -71,7 +71,8 @@ handler (const jerry_value_t func_obj_val, /**< function object */
char buffer[32];
jerry_size_t sz;
printf ("ok %d %d %p %d\n", func_obj_val, this_val, args_p, args_cnt);
printf ("ok %u %u %p %u\n",
(unsigned int) func_obj_val, (unsigned int) this_val, (void *) args_p, (unsigned int) args_cnt);
TEST_ASSERT (args_cnt == 2);
@ -95,7 +96,8 @@ handler_throw_test (const jerry_value_t func_obj_val, /**< function object */
const jerry_value_t args_p[], /**< arguments list */
const jerry_length_t args_cnt) /**< arguments length */
{
printf ("ok %d %d %p %d\n", func_obj_val, this_val, args_p, args_cnt);
printf ("ok %u %u %p %u\n",
(unsigned int) func_obj_val, (unsigned int) this_val, (void *) args_p, (unsigned int) args_cnt);
return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "error");
} /* handler_throw_test */
@ -115,7 +117,8 @@ handler_construct (const jerry_value_t func_obj_val, /**< function object */
const jerry_value_t args_p[], /**< arguments list */
const jerry_length_t args_cnt) /**< arguments length */
{
printf ("ok construct %d %d %p %d\n", func_obj_val, this_val, args_p, args_cnt);
printf ("ok construct %u %u %p %u\n",
(unsigned int) func_obj_val, (unsigned int) this_val, (void *) args_p, (unsigned int) args_cnt);
TEST_ASSERT (jerry_value_is_object (this_val));

View File

@ -33,13 +33,25 @@ check_int (const char *expr, int computed, int expected)
passed &= result;
} /* check_int */
typedef union
{
double value;
uint64_t bits64;
uint32_t bits32[2];
} double_bits_t;
static void
check_double (const char *expr, double computed, double expected)
{
uint64_t *computed_bits_p = (uint64_t *) &computed;
uint64_t *expected_bits_p = (uint64_t *) &expected;
double_bits_t computed_bits;
double_bits_t expected_bits;
printf ("%s = 0x%lx [expected=0x%lx] ", expr, *computed_bits_p, *expected_bits_p);
computed_bits.value = computed;
expected_bits.value = expected;
printf ("%s = 0x%08x%08x [expected=0x%08x%08x] ", expr,
(unsigned int) computed_bits.bits32[1], (unsigned int) computed_bits.bits32[0],
(unsigned int) expected_bits.bits32[1], (unsigned int) expected_bits.bits32[0]);
bool result;
if (isnan (computed) && isnan (expected))
@ -48,7 +60,7 @@ check_double (const char *expr, double computed, double expected)
}
else
{
int64_t diff = (int64_t) (*computed_bits_p - *expected_bits_p);
int64_t diff = (int64_t) (computed_bits.bits64 - expected_bits.bits64);
if (diff < 0)
{
diff = -diff;