示例#1
0
/**
 * Pretty print the current time.
 */
void
ClockPrint(void)
{
    struct timespec time;
    ClockGetTime(&time);

    ClockPrintTime(&time);
}
示例#2
0
static void
test_ClockPrintTime_validate(long sec, long nsec)
{
    struct timespec ts;
    ts.tv_sec = sec;
    ts.tv_nsec = nsec;

    GString *reference = g_string_new("");
    g_string_printf(reference, "*%lds.%ldms*", sec, nsec / NSEC_PER_MSEC);

    if (g_test_trap_fork(1000000, G_TEST_TRAP_SILENCE_STDERR))
    {
        /* Should print "[seconds]s.[milliseconds]ms ". */
        ClockPrintTime(&ts);
        exit(0);
    }
    g_test_trap_assert_passed();
    g_test_trap_assert_stderr(reference->str);

    g_string_free(reference, TRUE);
}