From b769be0f605a57faf8a466c4c732fdbf11a9cb30 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 11 Apr 2014 09:46:03 -0700 Subject: [PATCH] invalid tests for some architectures (char is not guaranteed to be signed or unsigned) fix tests on ARM --- src/kernel/reports_test.c | 6 +++--- src/util/bsdstring_test.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/kernel/reports_test.c b/src/kernel/reports_test.c index 218f2d429..2340f32c3 100644 --- a/src/kernel/reports_test.c +++ b/src/kernel/reports_test.c @@ -64,16 +64,16 @@ static void test_regionid(CuTest * tc) { plain = test_create_terrain("plain", 0); r = test_create_region(0, 0, plain); - memset(buffer, -2, sizeof(buffer)); + memset(buffer, 0x7d, sizeof(buffer)); len = f_regionid(r, 0, buffer, sizeof(buffer)); CuAssertIntEquals(tc, 11, len); CuAssertStrEquals(tc, "plain (0,0)", buffer); - memset(buffer, -2, sizeof(buffer)); + memset(buffer, 0x7d, sizeof(buffer)); len = f_regionid(r, 0, buffer, 11); CuAssertIntEquals(tc, 10, len); CuAssertStrEquals(tc, "plain (0,0", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[11]); + CuAssertIntEquals(tc, 0x7d, buffer[11]); } CuSuite *get_reports_suite(void) diff --git a/src/util/bsdstring_test.c b/src/util/bsdstring_test.c index 0f9cdaeac..c4cd9db98 100644 --- a/src/util/bsdstring_test.c +++ b/src/util/bsdstring_test.c @@ -6,7 +6,7 @@ static void test_strlcat(CuTest * tc) { char buffer[32]; - memset(buffer, -2, sizeof(buffer)); + memset(buffer, 0xfe, sizeof(buffer)); buffer[0] = '\0'; CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 4)); @@ -15,47 +15,47 @@ static void test_strlcat(CuTest * tc) buffer[0] = '\0'; CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 8)); CuAssertStrEquals(tc, "herp", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[5]); + CuAssertIntEquals(tc, 0xfe, buffer[5]); CuAssertIntEquals(tc, 8, strlcat(buffer, "derp", 8)); CuAssertStrEquals(tc, "herpder", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[8]); + CuAssertIntEquals(tc, 0xfe, buffer[8]); } static void test_strlcpy(CuTest * tc) { char buffer[32]; - memset(buffer, -2, sizeof(buffer)); + memset(buffer, 0xed, sizeof(buffer)); CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 4)); CuAssertStrEquals(tc, "her", buffer); CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 8)); CuAssertStrEquals(tc, "herp", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[5]); + CuAssertIntEquals(tc, 0xed, buffer[5]); CuAssertIntEquals(tc, 8, strlcpy(buffer, "herpderp", 8)); CuAssertStrEquals(tc, "herpder", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[8]); + CuAssertIntEquals(tc, 0xed, buffer[8]); } static void test_slprintf(CuTest * tc) { char buffer[32]; - memset(buffer, -2, sizeof(buffer)); + memset(buffer, 0x7f, sizeof(buffer)); CuAssertTrue(tc, slprintf(buffer, 4, "%s", "herpderp")>3); CuAssertStrEquals(tc, "her", buffer); CuAssertIntEquals(tc, 4, slprintf(buffer, 8, "%s", "herp")); CuAssertStrEquals(tc, "herp", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[5]); + CuAssertIntEquals(tc, 0x7f, buffer[5]); CuAssertIntEquals(tc, 8, slprintf(buffer, 8, "%s", "herpderp")); CuAssertStrEquals(tc, "herpder", buffer); - CuAssertIntEquals(tc, (char)-2, buffer[8]); + CuAssertIntEquals(tc, 0x7f, buffer[8]); } CuSuite *get_bsdstring_suite(void)