コード例 #1
0
ファイル: ut_clock_event.c プロジェクト: rebcabin/BinaryClock
static int test_clock_event_yearInfoToStr_afterDateIncreaseDecrease_correct()
{
    ClockEvent event = clock_event_initDayOfMonth(1,  APRIL, 1392, "Fool's day");

    const char *expectedStr = "621 years - started in 1392";
    const char *expectedNextStr = "622 years - started in 1392";

    int year = 2013;
    DateTime dt = date_time_initDate(year, MARCH, 13);

    //
    // code
    //

    Call( clock_event_initList(&event, 1, year) );
    Call( clock_event_updateList(&event, 1, &dt) );

    char str[EVENT_STRING_BUFFER_SIZE];

    Call( clock_event_yearInfoToStr(&event, str) );
    assert_str(expectedStr, str);

    dt.month++;
    Call( clock_event_updateList(&event, 1, &dt) );
    Call( clock_event_yearInfoToStr(&event, str) );
    assert_str(expectedNextStr, str);

    dt.month--;
    Call( clock_event_updateList(&event, 1, &dt) );
    Call( clock_event_yearInfoToStr(&event, str) );
    assert_str(expectedStr, str);

    return 0;
}
コード例 #2
0
ファイル: check_http.c プロジェクト: okxchg/tproxy
} END_TEST

/* TODO: find two headers with coliding hash and test it */
START_TEST(test_http_headers)
{
    http_hdr_table *t;

    t = http_headers_init();

    fail_if(http_header_parse(t, "") == 0);
    fail_if(http_header_parse(t, "field") == 0);
    fail_if(http_header_parse(t, "field\r\n") == 0);
    fail_if(http_header_parse(t, "field:") == 0);
    fail_if(http_header_parse(t, "field:\r\n") == 0);
    fail_if(http_header_parse(t, "field:value") == 0);
    fail_if(http_header_parse(t, ":value") == 0);
    fail_if(http_header_parse(t, ":value\r\n") == 0);

    fail_unless(http_header_parse(t, "Host: dsl.sk\r\n") == 0);
    assert_str(http_header_get(t, "Host"), "dsl.sk");
    assert_str(http_header_get(t, "host"), "dsl.sk");
    assert_str(http_header_get(t, "HOST"), "dsl.sk");

    http_headers_destroy(t);
} END_TEST
コード例 #3
0
ファイル: ut_clock_event.c プロジェクト: rebcabin/BinaryClock
static int test_clock_event_initDayOfYear_correct()
{
    const char name[] = "Programmer's day";
    ClockEvent event = clock_event_initDayOfYear(256, 2009, name);

    assert_str(event.name, name);
    assert_int(event.yearStarted, 2009);

    assert_false(clock_event_isDayOfMonthEvent(event));
    assert_false(clock_event_isDayOfWeekEvent(event));
    assert_true(clock_event_isDayOfYearEvent(event));

    assert_int(clock_event_getDayOfMonth(event), 0);
    assert_int(clock_event_getMonth(event), 0);
    assert_int(clock_event_getDayOfYear(event), 256);
    assert_int(clock_event_getDayOfWeek(event), 0);
    assert_int(clock_event_getWeekOfMonth(event), 0);
    assert_false(clock_event_isFromBeginningOfMonth(event));

    return 0;
}
コード例 #4
0
ファイル: ut_clock_event.c プロジェクト: rebcabin/BinaryClock
static int test_clock_event_initDayOfWeek_correct()
{
    const char name[] = "Thanksgiving";
    ClockEvent event = clock_event_initDayOfWeek(THURSDAY, 3, WEEK_FROM_START, NOVEMBER, 1574, name);

    assert_str(event.name, name);
    assert_int(event.yearStarted, 1574);

    assert_false(clock_event_isDayOfMonthEvent(event));
    assert_true(clock_event_isDayOfWeekEvent(event));
    assert_false(clock_event_isDayOfYearEvent(event));

    assert_int(clock_event_getDayOfMonth(event), 0);
    assert_int(clock_event_getMonth(event), NOVEMBER);
    assert_int(clock_event_getDayOfYear(event), DAY_OF_WEEK_FLAG);
    assert_int(clock_event_getDayOfWeek(event), THURSDAY);
    assert_int(clock_event_getWeekOfMonth(event), 3);
    assert_true(clock_event_isFromBeginningOfMonth(event));

    return 0;
}
コード例 #5
0
ファイル: ut_clock_event.c プロジェクト: rebcabin/BinaryClock
static int test_clock_event_initDayOfMonth_correct()
{
    const char name[] = "Fool's day";
    ClockEvent event = clock_event_initDayOfMonth(4, APRIL, 1392, name);

    assert_str(event.name, name);
    assert_int(event.yearStarted, 1392);

    assert_true(clock_event_isDayOfMonthEvent(event));
    assert_false(clock_event_isDayOfWeekEvent(event));
    assert_false(clock_event_isDayOfYearEvent(event));

    assert_int(clock_event_getDayOfMonth(event), 4);
    assert_int(clock_event_getMonth(event), APRIL);
    assert_int(clock_event_getDayOfYear(event), 0);
    assert_int(clock_event_getDayOfWeek(event), 0);
    assert_int(clock_event_getWeekOfMonth(event), 0);
    assert_false(clock_event_isFromBeginningOfMonth(event));

    return 0;
}
コード例 #6
0
ファイル: hpack_table_test.c プロジェクト: Zerqkboo/grpc
static void assert_index(const grpc_chttp2_hptbl *tbl, int idx, const char *key,
                         const char *value) {
  grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx);
  assert_str(tbl, md->key, key);
  assert_str(tbl, md->value, value);
}