invalid tests for some architectures (char is not guaranteed to be signed or unsigned)

fix tests on ARM
This commit is contained in:
Enno Rehling 2014-04-11 09:46:03 -07:00
parent 0d8a196491
commit b769be0f60
2 changed files with 12 additions and 12 deletions

View File

@ -64,16 +64,16 @@ static void test_regionid(CuTest * tc) {
plain = test_create_terrain("plain", 0); plain = test_create_terrain("plain", 0);
r = test_create_region(0, 0, plain); 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)); len = f_regionid(r, 0, buffer, sizeof(buffer));
CuAssertIntEquals(tc, 11, len); CuAssertIntEquals(tc, 11, len);
CuAssertStrEquals(tc, "plain (0,0)", buffer); CuAssertStrEquals(tc, "plain (0,0)", buffer);
memset(buffer, -2, sizeof(buffer)); memset(buffer, 0x7d, sizeof(buffer));
len = f_regionid(r, 0, buffer, 11); len = f_regionid(r, 0, buffer, 11);
CuAssertIntEquals(tc, 10, len); CuAssertIntEquals(tc, 10, len);
CuAssertStrEquals(tc, "plain (0,0", buffer); CuAssertStrEquals(tc, "plain (0,0", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[11]); CuAssertIntEquals(tc, 0x7d, buffer[11]);
} }
CuSuite *get_reports_suite(void) CuSuite *get_reports_suite(void)

View File

@ -6,7 +6,7 @@ static void test_strlcat(CuTest * tc)
{ {
char buffer[32]; char buffer[32];
memset(buffer, -2, sizeof(buffer)); memset(buffer, 0xfe, sizeof(buffer));
buffer[0] = '\0'; buffer[0] = '\0';
CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 4)); CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 4));
@ -15,47 +15,47 @@ static void test_strlcat(CuTest * tc)
buffer[0] = '\0'; buffer[0] = '\0';
CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 8)); CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 8));
CuAssertStrEquals(tc, "herp", buffer); CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[5]); CuAssertIntEquals(tc, 0xfe, buffer[5]);
CuAssertIntEquals(tc, 8, strlcat(buffer, "derp", 8)); CuAssertIntEquals(tc, 8, strlcat(buffer, "derp", 8));
CuAssertStrEquals(tc, "herpder", buffer); CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[8]); CuAssertIntEquals(tc, 0xfe, buffer[8]);
} }
static void test_strlcpy(CuTest * tc) static void test_strlcpy(CuTest * tc)
{ {
char buffer[32]; char buffer[32];
memset(buffer, -2, sizeof(buffer)); memset(buffer, 0xed, sizeof(buffer));
CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 4)); CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer); CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 8)); CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 8));
CuAssertStrEquals(tc, "herp", buffer); CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[5]); CuAssertIntEquals(tc, 0xed, buffer[5]);
CuAssertIntEquals(tc, 8, strlcpy(buffer, "herpderp", 8)); CuAssertIntEquals(tc, 8, strlcpy(buffer, "herpderp", 8));
CuAssertStrEquals(tc, "herpder", buffer); CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[8]); CuAssertIntEquals(tc, 0xed, buffer[8]);
} }
static void test_slprintf(CuTest * tc) static void test_slprintf(CuTest * tc)
{ {
char buffer[32]; char buffer[32];
memset(buffer, -2, sizeof(buffer)); memset(buffer, 0x7f, sizeof(buffer));
CuAssertTrue(tc, slprintf(buffer, 4, "%s", "herpderp")>3); CuAssertTrue(tc, slprintf(buffer, 4, "%s", "herpderp")>3);
CuAssertStrEquals(tc, "her", buffer); CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, slprintf(buffer, 8, "%s", "herp")); CuAssertIntEquals(tc, 4, slprintf(buffer, 8, "%s", "herp"));
CuAssertStrEquals(tc, "herp", buffer); CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[5]); CuAssertIntEquals(tc, 0x7f, buffer[5]);
CuAssertIntEquals(tc, 8, slprintf(buffer, 8, "%s", "herpderp")); CuAssertIntEquals(tc, 8, slprintf(buffer, 8, "%s", "herpderp"));
CuAssertStrEquals(tc, "herpder", buffer); CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, (char)-2, buffer[8]); CuAssertIntEquals(tc, 0x7f, buffer[8]);
} }
CuSuite *get_bsdstring_suite(void) CuSuite *get_bsdstring_suite(void)