mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve tests
This commit is contained in:
parent
3bb4ab39e3
commit
d80b401f12
@ -52,6 +52,43 @@ TEST(Edit, date_fix) {
|
||||
widget_set_text_utf8(w, "20200/21/03");
|
||||
ASSERT_EQ(edit_date_fix_ex(w, TRUE), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"2020/01/03"), 0);
|
||||
|
||||
widget_set_text_utf8(w, "20200/21/03");
|
||||
ASSERT_EQ(edit_date_fix(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"2020/01/03"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, inc_dec) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "20200/12/01");
|
||||
ASSERT_EQ(edit_date_fix_ex(w, TRUE), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"2020/12/01"), 0);
|
||||
|
||||
ASSERT_EQ(edit_date_inc_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"2020/12/02"), 0);
|
||||
|
||||
ASSERT_EQ(edit_date_dec_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"2020/12/01"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, is_valid_char) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "20200/12/01");
|
||||
ASSERT_EQ(edit_date_fix_ex(w, TRUE), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"2020/12/01"), 0);
|
||||
|
||||
widget_set_text_utf8(w, "20200/12/0");
|
||||
ASSERT_EQ(edit_date_is_valid_char(w, '1'), TRUE);
|
||||
ASSERT_EQ(edit_date_pre_input(w, '1'), RET_OK);
|
||||
|
||||
widget_set_text_utf8(w, "20200/12/01");
|
||||
ASSERT_EQ(edit_date_is_valid_char(w, '1'), FALSE);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
@ -46,6 +46,37 @@ TEST(Edit, ipv4_fix) {
|
||||
widget_set_text_utf8(w, "1922.268.0.1");
|
||||
ASSERT_EQ(edit_ipv4_fix_ex(w, TRUE), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"192.26.0.1"), 0);
|
||||
|
||||
widget_set_text_utf8(w, "1922.268.1.1");
|
||||
ASSERT_EQ(edit_ipv4_fix(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"192.26.1.1"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, ipv4_inc_dec) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "192.26.0.1");
|
||||
ASSERT_EQ(edit_ipv4_inc_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"192.26.0.2"), 0);
|
||||
|
||||
ASSERT_EQ(edit_ipv4_dec_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"192.26.0.1"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, ipv4_is_valid_char) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "192.268.0.1");
|
||||
ASSERT_EQ(edit_ipv4_is_valid_char(w, '0'), TRUE);
|
||||
ASSERT_EQ(edit_ipv4_pre_input(w, '0'), RET_OK);
|
||||
|
||||
widget_set_text_utf8(w, "192.268.0.199");
|
||||
ASSERT_EQ(edit_ipv4_is_valid_char(w, '0'), FALSE);
|
||||
ASSERT_EQ(edit_ipv4_pre_input(w, '0'), RET_OK);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
@ -52,6 +52,40 @@ TEST(Edit, time_full_fix) {
|
||||
widget_set_text_utf8(w, "180:60:03");
|
||||
ASSERT_EQ(edit_time_full_fix_ex(w, TRUE), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:00:03"), 0);
|
||||
|
||||
widget_set_text_utf8(w, "180:60:03");
|
||||
ASSERT_EQ(edit_time_full_fix(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:00:03"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, time_full_inc_dec) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "18:12:01");
|
||||
ASSERT_EQ(edit_time_full_inc_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:12:02"), 0);
|
||||
|
||||
ASSERT_EQ(edit_time_full_dec_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:12:01"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, time_full_is_valid_char) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "18:12:0");
|
||||
ASSERT_EQ(edit_time_full_is_valid_char(w, '0'), TRUE);
|
||||
ASSERT_EQ(edit_time_full_pre_input(w, '0'), RET_OK);
|
||||
|
||||
widget_set_text_utf8(w, "18:12:01");
|
||||
ASSERT_EQ(edit_time_full_is_valid_char(w, '0'), FALSE);
|
||||
ASSERT_EQ(edit_time_full_pre_input(w, '0'), RET_OK);
|
||||
|
||||
widget_set_text_utf8(w, "18:12:0");
|
||||
ASSERT_EQ(edit_time_full_is_valid_char(w, 'a'), FALSE);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
@ -45,6 +45,36 @@ TEST(Edit, time_fix) {
|
||||
widget_set_text_utf8(w, "180:60");
|
||||
ASSERT_EQ(edit_time_fix_ex(w, TRUE), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:00"), 0);
|
||||
|
||||
widget_set_text_utf8(w, "180:60");
|
||||
ASSERT_EQ(edit_time_fix(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:00"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, time_inc_dec) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "18:12");
|
||||
ASSERT_EQ(edit_time_inc_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:13"), 0);
|
||||
ASSERT_EQ(edit_time_dec_value(w), RET_OK);
|
||||
ASSERT_EQ(wcscmp(w->text.str, L"18:12"), 0);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
||||
TEST(Edit, time_is_valid_char) {
|
||||
widget_t* w = edit_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(w, "18:1");
|
||||
ASSERT_EQ(edit_time_pre_input(w, '0'), RET_OK);
|
||||
ASSERT_EQ(edit_time_is_valid_char(w, '0'), TRUE);
|
||||
|
||||
widget_set_text_utf8(w, "18:11");
|
||||
ASSERT_EQ(edit_time_pre_input(w, '0'), RET_OK);
|
||||
ASSERT_EQ(edit_time_is_valid_char(w, '0'), FALSE);
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ TEST(MemPool, basic2) {
|
||||
ASSERT_EQ(pool->block_size, 16);
|
||||
ASSERT_EQ(pool->used, 0);
|
||||
ASSERT_EQ(pool->bits_size, 4);
|
||||
|
||||
ASSERT_EQ(mem_pool_match_size(pool, 9), TRUE);
|
||||
addr = mem_pool_get(pool);
|
||||
ASSERT_EQ(addr != NULL, true);
|
||||
ASSERT_EQ(mem_pool_put(pool, addr), RET_OK);
|
||||
|
Loading…
Reference in New Issue
Block a user