Пример #1
0
static char * test_parsenames_ok(void)
{
    char test_path[] = TEST_PATH TEST_FILENAME;
    int retval;

    retval = parsenames(test_path, &path, &filename);

    ku_assert_equal("Return value is 0", retval, 0);
    ku_assert_str_equal("Returned path is ok", path, TEST_PATH);
    ku_assert_str_equal("Returned filename is ok", filename, TEST_FILENAME);

    return NULL;
}
Пример #2
0
static char * test_uint(void)
{
#define TSTRING1    "string"
#define UINTVAL     1337
#define EXPECTED TSTRING1 NTOSTR(UINTVAL) TSTRING1
    char actual[80] = JUNK;

    ksprintf(actual, sizeof(actual), TSTRING1 "%u" TSTRING1, (uint32_t)UINTVAL);

    ku_assert_str_equal("String composed correctly.", actual, EXPECTED);

#undef TSTRING1
#undef UINTVAL1
#undef EXPECTED

    return NULL;
}
Пример #3
0
static char * test_hex(void)
{
#define TSTRING1    "string"
#define HEXVALUE    0x00000500
#define EXPECTED TSTRING1 NTOSTR(HEXVALUE) TSTRING1
    char actual[80] = JUNK;

    ksprintf(actual, sizeof(actual), TSTRING1 "%x" TSTRING1,
             (uint32_t)HEXVALUE);

    ku_assert_str_equal("String composed correctly.", actual, EXPECTED);

#undef TSTRING1
#undef HEXVALUE
#undef EXPECTED

    return NULL;
}
Пример #4
0
static char * test_uitoah32(void)
{
#define UINTHEXVAL 0x0000532a
    char actual[80];
    char expected[] = NTOSTR(UINTHEXVAL);
    size_t retVal;

    retVal = uitoah32(actual, (uint32_t)UINTHEXVAL);

    ku_assert_str_equal("Unsigned integer was converted to string.", \
            actual, expected);
    ku_assert_equal("return value is number of printable characters in the string.", \
            (int)retVal, (int)(sizeof(expected) - 1));

#undef UINTVAL

    return 0;
}