format code

This commit is contained in:
lixianjing 2022-06-02 16:43:16 +08:00
parent 7c97f63135
commit baf83a61b8
26 changed files with 126 additions and 92 deletions

View File

@ -556,7 +556,8 @@ ret_t bitmap_init(bitmap_t* bitmap, uint32_t w, uint32_t h, bitmap_format_t form
return bitmap_init_ex(bitmap, w, h, line_length, format, data);
}
ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format, uint8_t* data) {
ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length,
bitmap_format_t format, uint8_t* data) {
uint32_t bpp = bitmap_get_bpp_of_format(format);
return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS);

View File

@ -319,7 +319,8 @@ ret_t bitmap_init(bitmap_t* bitmap, uint32_t w, uint32_t h, bitmap_format_t form
*
* @return {ret_t} RET_OK表示成功
*/
ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format, uint8_t* data);
ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length,
bitmap_format_t format, uint8_t* data);
#if defined(WITH_STB_IMAGE) || defined(WITH_FS_RES)
/*for helping debug drawing bugs*/

View File

@ -426,7 +426,8 @@ ret_t soft_rotate_image_ex(bitmap_t* dst, bitmap_t* src, const rect_t* src_r, xy
return RET_NOT_IMPL;
}
static rect_t soft_blend_image_rotate_get_dst_point(bitmap_t* dst, const rectf_t* dst_r, lcd_orientation_t o) {
static rect_t soft_blend_image_rotate_get_dst_point(bitmap_t* dst, const rectf_t* dst_r,
lcd_orientation_t o) {
rectf_t r;
uint32_t w = dst->w;
uint32_t h = dst->h;
@ -456,8 +457,8 @@ ret_t soft_blend_image_rotate(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r
} else if (alpha > 0xf8) {
rect_t tmp_src = rect_from_rectf(src_r);
rect_t tmp_dst = soft_blend_image_rotate_get_dst_point(dst, dst_r, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x,
tmp_dst.y, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x, tmp_dst.y,
o);
} else {
return blend_image_rotate_bgr565_bgr565(dst, src, dst_r, src_r, alpha, o);
}
@ -490,8 +491,8 @@ ret_t soft_blend_image_rotate(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r
} else if (alpha > 0xf8) {
rect_t tmp_src = rect_from_rectf(src_r);
rect_t tmp_dst = soft_blend_image_rotate_get_dst_point(dst, dst_r, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x,
tmp_dst.y, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x, tmp_dst.y,
o);
} else {
return blend_image_rotate_rgb565_rgb565(dst, src, dst_r, src_r, alpha, o);
}
@ -527,8 +528,8 @@ ret_t soft_blend_image_rotate(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r
} else if (alpha > 0xf8) {
rect_t tmp_src = rect_from_rectf(src_r);
rect_t tmp_dst = soft_blend_image_rotate_get_dst_point(dst, dst_r, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x,
tmp_dst.y, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x, tmp_dst.y,
o);
} else {
return blend_image_rotate_bgr888_bgr888(dst, src, dst_r, src_r, alpha, o);
}
@ -561,8 +562,8 @@ ret_t soft_blend_image_rotate(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r
} else if (alpha > 0xf8) {
rect_t tmp_src = rect_from_rectf(src_r);
rect_t tmp_dst = soft_blend_image_rotate_get_dst_point(dst, dst_r, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x,
tmp_dst.y, o);
return soft_rotate_image_ex(dst, src, (const rect_t*)(&tmp_src), tmp_dst.x, tmp_dst.y,
o);
} else {
return blend_image_rotate_rgb888_rgb888(dst, src, dst_r, src_r, alpha, o);
}

View File

@ -49,7 +49,7 @@ static void my_xml_builder_on_start(XmlBuilder* thiz, const char* tag, const cha
value_t v;
const char* name = attrs[i];
const char* value = attrs[i + 1];
str_clear(str);
str_decode_xml_entity(str, value);
node = conf_doc_create_node(b->doc, name);
@ -136,8 +136,8 @@ static ret_t conf_doc_save_prop(conf_node_t* node, str_t* str) {
conf_node_get_value(node, &v);
return_value_if_fail(str_append_more(str, " ", key, "=\"", NULL) == RET_OK, RET_OOM);
return_value_if_fail(str_encode_xml_entity(str, value_str_ex(&v, buff, sizeof(buff) - 1)) == RET_OK,
RET_OOM);
return_value_if_fail(
str_encode_xml_entity(str, value_str_ex(&v, buff, sizeof(buff) - 1)) == RET_OK, RET_OOM);
return_value_if_fail(str_append(str, "\"") == RET_OK, RET_OOM);
return RET_OK;
@ -187,7 +187,7 @@ ret_t conf_doc_save_xml(conf_doc_t* doc, str_t* str) {
str_clear(str);
while (iter != NULL) {
if(conf_doc_save_xml_node(doc, str, iter, 0) != RET_OK) {
if (conf_doc_save_xml_node(doc, str, iter, 0) != RET_OK) {
return RET_OOM;
}
iter = iter->next;

View File

@ -104,7 +104,8 @@ widget_t* list_item_seperator_create(widget_t* parent, xy_t x, xy_t y, wh_t w, w
*/
widget_t* list_item_seperator_cast(widget_t* widget);
#define LIST_ITEM_SEPERATOR(widget) ((list_item_seperator_t*)(list_item_seperator_cast(WIDGET(widget))))
#define LIST_ITEM_SEPERATOR(widget) \
((list_item_seperator_t*)(list_item_seperator_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(list_item_seperator);

View File

@ -91,7 +91,7 @@ static ret_t lcd_sdl2_flush(lcd_t* lcd) {
if (system_info()->flags & SYSTEM_INFO_FLAG_FAST_LCD_PORTRAIT) {
sr.w = lcd_w = lcd_get_physical_width(lcd);
sr.h = lcd_h = lcd_get_physical_height(lcd);
} else
} else
#endif
{
sr.w = lcd_w = lcd->w;
@ -117,7 +117,7 @@ static ret_t lcd_sdl2_flush(lcd_t* lcd) {
rr = lcd_orientation_rect_rotate_by_anticlockwise(dr, o, src.w, src.h);
}
image_copy(&dst, &src, &rr, rr.x, rr.y);
} else
} else
#endif
{
if (o == LCD_ORIENTATION_0) {
@ -139,7 +139,7 @@ static ret_t lcd_sdl2_flush(lcd_t* lcd) {
rr = lcd_orientation_rect_rotate_by_anticlockwise(dr, o, src.w, src.h);
}
image_copy(&dst, &src, &rr, rr.x, rr.y);
} else
} else
#endif
{
const rect_t* dr = (const rect_t*)dirty_rects->rects + i;

View File

@ -216,9 +216,9 @@ ret_t str_encode_xml_entity_with_len(str_t* str, const char* text, uint32_t len)
uint32_t i = 0;
return_value_if_fail(str != NULL && text != NULL, RET_BAD_PARAMS);
for(i = 0; i < len; i++) {
for (i = 0; i < len; i++) {
char c = text[i];
switch(c) {
switch (c) {
case '<': {
return_value_if_fail(str_append(str, "&lt;") == RET_OK, RET_OOM);
break;

View File

@ -387,8 +387,8 @@ enum { TK_NAME_LEN = 31, TK_FUNC_NAME_LEN = 63 };
#define tk_str_ieq(s1, s2) \
(((s1) == NULL && (s2) == NULL) || \
(((s1) != NULL) && ((s2) != NULL) && strcasecmp((s1), (s2)) == 0))
#define tk_wstr_eq(s1, s2) \
(((s1) == NULL && (s2) == NULL) || \
#define tk_wstr_eq(s1, s2) \
(((s1) == NULL && (s2) == NULL) || \
(((s1) != NULL) && ((s2) != NULL) && *((const wchar_t*)s1) == *((const wchar_t*)s2) && \
wcscmp((s1), (s2)) == 0))
#endif /*WITH_CPPCHECK*/

View File

@ -271,10 +271,10 @@ wchar_t* tk_utf8_to_utf16_ex(const char* str, uint32_t size, wchar_t* out, uint3
while (p != NULL && p < end && (i + 1) < out_size) {
val = utf8_get_char(p, &next);
return_value_if_fail(val != -1, NULL);
if (sizeof(wchar_t) == 4) {
out[i++] = val;
} else if (sizeof(wchar_t) == 2){
} else if (sizeof(wchar_t) == 2) {
if (val < 0x10000) {
out[i++] = val;
} else {
@ -286,7 +286,7 @@ wchar_t* tk_utf8_to_utf16_ex(const char* str, uint32_t size, wchar_t* out, uint3
} else {
return NULL;
}
p = next;
}
out[i] = '\0';

View File

@ -257,8 +257,9 @@ widget_t* check_button_get_checked_button(widget_t* widget) {
return NULL;
}
widget_t* check_button_create_ex(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h, const char* type, bool_t radio) {
const widget_vtable_t* vt = radio ? TK_REF_VTABLE(radio_button) : TK_REF_VTABLE(check_button);
widget_t* check_button_create_ex(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h, const char* type,
bool_t radio) {
const widget_vtable_t* vt = radio ? TK_REF_VTABLE(radio_button) : TK_REF_VTABLE(check_button);
widget_t* widget = widget_create(parent, vt, x, y, w, h);
check_button_t* check_button = CHECK_BUTTON(widget);
return_value_if_fail(check_button != NULL, NULL);

View File

@ -201,7 +201,8 @@ TK_EXTERN_VTABLE(check_button);
*
* @return {widget_t*} widget对象
*/
widget_t* check_button_create_ex(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h, const char* type, bool_t radio);
widget_t* check_button_create_ex(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h, const char* type,
bool_t radio);
END_C_DECLS

View File

@ -174,7 +174,7 @@ static ret_t window_manager_default_snap_prev_window_draw_dialog_highlighter_and
dialog_highlighter_draw_mask(dialog_highlighter, c, 1.0f);
*alpha = dialog_highlighter_get_alpha(dialog_highlighter, 1.0f);
widget_off_by_func(widget, EVT_DESTROY, dialog_highlighter_on_dialog_destroy,
dialog_highlighter);
dialog_highlighter);
dialog_highlighter_destroy(dialog_highlighter);
return RET_OK;
}
@ -332,13 +332,13 @@ static ret_t window_manager_create_highlighter(widget_t* widget, widget_t* curr_
static bool_t window_manager_curr_win_is_top_animator_window(widget_t* wm, widget_t* curr_win) {
bool_t is_find = FALSE;
WIDGET_FOR_EACH_CHILD_BEGIN_R(wm, iter, i)
if (widget_is_normal_window(iter) && !is_find && curr_win != iter) {
return FALSE;
}
if (iter == curr_win) {
is_find = TRUE;
break;
}
if (widget_is_normal_window(iter) && !is_find && curr_win != iter) {
return FALSE;
}
if (iter == curr_win) {
is_find = TRUE;
break;
}
WIDGET_FOR_EACH_CHILD_END()
return TRUE;
}
@ -356,7 +356,8 @@ static ret_t window_manager_create_animator(window_manager_default_t* wm, widget
return_value_if_fail(wm != NULL && prev_win != NULL && curr_win != NULL, RET_BAD_PARAMS);
if (wm->animator != NULL || !window_manager_curr_win_is_top_animator_window(WIDGET(wm), curr_win)) {
if (wm->animator != NULL ||
!window_manager_curr_win_is_top_animator_window(WIDGET(wm), curr_win)) {
return RET_FAIL;
}

View File

@ -213,12 +213,12 @@ TEST(Button, tr_text1) {
widget_set_text_utf8(w1, "hello");
widget_set_tr_text(w1, "");
ASSERT_EQ(w1->tr_text == NULL, true);
widget_get_text_utf8(w1, text, sizeof(text)-1);
widget_get_text_utf8(w1, text, sizeof(text) - 1);
ASSERT_STREQ(text, "hello");
widget_set_tr_text(w1, NULL);
ASSERT_EQ(w1->tr_text == NULL, true);
widget_get_text_utf8(w1, text, sizeof(text)-1);
widget_get_text_utf8(w1, text, sizeof(text) - 1);
ASSERT_STREQ(text, "hello");
widget_destroy(w1);

View File

@ -30,10 +30,10 @@ TEST(Xml, basic1) {
ASSERT_EQ(conf_doc_get(doc, "hello.name", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "abc");
ASSERT_EQ(conf_doc_get(doc, "hello.world.name", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "cde");
ASSERT_EQ(conf_doc_get(doc, "hello.world.value", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "123");
@ -52,20 +52,21 @@ TEST(Xml, basic2) {
value_t v;
str_t str;
conf_node_t* node = NULL;
conf_doc_t* doc = conf_doc_load_xml("<hello name='abc'><world name='cde' value='123'/><foo name='oo' value='456'/></hello>");
conf_doc_t* doc = conf_doc_load_xml(
"<hello name='abc'><world name='cde' value='123'/><foo name='oo' value='456'/></hello>");
ASSERT_EQ(conf_doc_get(doc, "hello.name", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "abc");
ASSERT_EQ(conf_doc_get(doc, "hello.world.name", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "cde");
ASSERT_EQ(conf_doc_get(doc, "hello.world.value", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "123");
ASSERT_EQ(conf_doc_get(doc, "hello.foo.name", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "oo");
ASSERT_EQ(conf_doc_get(doc, "hello.foo.value", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "456");
@ -75,7 +76,9 @@ TEST(Xml, basic2) {
str_init(&str, 100);
conf_doc_save_xml(doc, &str);
ASSERT_STREQ(str.str, "<hello name=\"abc\">\n <world name=\"cde\" value=\"123\"/>\n <foo name=\"oo\" value=\"456\"/>\n</hello>\n");
ASSERT_STREQ(str.str,
"<hello name=\"abc\">\n <world name=\"cde\" value=\"123\"/>\n <foo name=\"oo\" "
"value=\"456\"/>\n</hello>\n");
str_reset(&str);
conf_doc_destroy(doc);
}
@ -83,14 +86,18 @@ TEST(Xml, basic2) {
TEST(Xml, basic3) {
value_t v;
str_t str;
conf_doc_t* doc = conf_doc_load_xml("<hello name='abc'><world name='cde' value='123'/><foo name='oo' value='456'/></hello><awtk name='ttt'/>");
conf_doc_t* doc = conf_doc_load_xml(
"<hello name='abc'><world name='cde' value='123'/><foo name='oo' value='456'/></hello><awtk "
"name='ttt'/>");
ASSERT_EQ(conf_doc_get(doc, "awtk.name", &v), RET_OK);
ASSERT_STREQ(value_str(&v), "ttt");
str_init(&str, 100);
conf_doc_save_xml(doc, &str);
ASSERT_STREQ(str.str, "<hello name=\"abc\">\n <world name=\"cde\" value=\"123\"/>\n <foo name=\"oo\" value=\"456\"/>\n</hello>\n<awtk name=\"ttt\"/>\n");
ASSERT_STREQ(str.str,
"<hello name=\"abc\">\n <world name=\"cde\" value=\"123\"/>\n <foo name=\"oo\" "
"value=\"456\"/>\n</hello>\n<awtk name=\"ttt\"/>\n");
str_reset(&str);
conf_doc_destroy(doc);
}

View File

@ -649,16 +649,16 @@ TEST(Edit, set_text_for_float) {
TEST(Edit, set_props) {
widget_t* e = edit_create(NULL, 10, 20, 30, 40);
widget_set_props(e, "input_type=int");
ASSERT_EQ(EDIT(e)->input_type, INPUT_INT);
widget_set_props(e, "min=10");
ASSERT_EQ(EDIT(e)->min, 10);
widget_set_props(e, "max=100");
ASSERT_EQ(EDIT(e)->max, 100);
widget_set_props(e, "max=11&min=1");
ASSERT_EQ(EDIT(e)->min, 1);
ASSERT_EQ(EDIT(e)->max, 11);

View File

@ -16,5 +16,5 @@ TEST(FPS, basic) {
cost = time_now_ms() - start;
log_debug("cost=%u\n", cost);
ASSERT_EQ(fps_get(&fps), tk_roundi(180 * 1000.0/cost));
ASSERT_EQ(fps_get(&fps), tk_roundi(180 * 1000.0 / cost));
}

View File

@ -34,4 +34,3 @@ TEST(FExr, json_save) {
TK_OBJECT_UNREF(obj);
}

View File

@ -2705,51 +2705,51 @@ TEST(FScript, binary) {
fscript_eval(obj, "a=binary(i8(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 1);
value_reset(&v);
fscript_eval(obj, "a=binary(u8(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 1);
value_reset(&v);
fscript_eval(obj, "a=binary(i16(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 2);
value_reset(&v);
fscript_eval(obj, "a=binary(u16(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 2);
value_reset(&v);
fscript_eval(obj, "a=binary(i32(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 4);
value_reset(&v);
fscript_eval(obj, "a=binary(u32(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 4);
value_reset(&v);
fscript_eval(obj, "a=binary(i64(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 8);
value_reset(&v);
fscript_eval(obj, "a=binary(u64(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 8);
value_reset(&v);
fscript_eval(obj, "a=binary(f32(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 4);
value_reset(&v);
fscript_eval(obj, "a=binary(f64(1));len(a)", &v);
ASSERT_EQ(value_int(&v), 8);
value_reset(&v);
fscript_eval(obj, "a=binary('abc');len(a)", &v);
ASSERT_EQ(value_int(&v), 3);
value_reset(&v);
fscript_eval(obj, "a=binary('abc');str(value_get_binary_data(a), true)", &v);
ASSERT_STREQ(value_str(&v), "abc");
value_reset(&v);
fscript_eval(obj, "a=binary('abc', 2);str(value_get_binary_data(a), true)", &v);
ASSERT_STREQ(value_str(&v), "ab");
value_reset(&v);
@ -2757,12 +2757,16 @@ TEST(FScript, binary) {
fscript_eval(obj, "a=binary('abc', 2, true);str(value_get_binary_data(a), true)", &v);
ASSERT_STREQ(value_str(&v), "ab");
value_reset(&v);
fscript_eval(obj, "a=binary('abcdef');b=binary(a, 4, true);str(value_get_binary_data(b), true)", &v);
fscript_eval(obj, "a=binary('abcdef');b=binary(a, 4, true);str(value_get_binary_data(b), true)",
&v);
ASSERT_STREQ(value_str(&v), "abcd");
value_reset(&v);
fscript_eval(obj, "a=binary('abcdef');b=binary(value_get_binary_data(a), 2, true);str(value_get_binary_data(b), true)", &v);
fscript_eval(obj,
"a=binary('abcdef');b=binary(value_get_binary_data(a), 2, "
"true);str(value_get_binary_data(b), true)",
&v);
ASSERT_STREQ(value_str(&v), "ab");
value_reset(&v);

View File

@ -78,13 +78,15 @@ TEST(FuncCallParser, object) {
}
TEST(FuncCallParser, str) {
const char* str = "path(w=1024,h=1028,data='m420.5,522l-247.5,-113l177,3l157,19l-86,-60l-0.5,151z')";
const char* str =
"path(w=1024,h=1028,data='m420.5,522l-247.5,-113l177,3l157,19l-86,-60l-0.5,151z')";
tk_object_t* obj = func_call_parse(str, strlen(str));
ASSERT_STREQ(obj->name, "path");
ASSERT_EQ(tk_object_get_prop_int(obj, "w", 0), 1024);
ASSERT_EQ(tk_object_get_prop_int(obj, "h", 0), 1028);
ASSERT_STREQ(tk_object_get_prop_str(obj, "data"), "m420.5,522l-247.5,-113l177,3l157,19l-86,-60l-0.5,151z");
ASSERT_STREQ(tk_object_get_prop_str(obj, "data"),
"m420.5,522l-247.5,-113l177,3l157,19l-86,-60l-0.5,151z");
tk_object_unref(obj);
}

View File

@ -85,7 +85,10 @@ TEST(Image, animator) {
TEST(Image, animator2) {
widget_t* w = (image_create(NULL, 0, 0, 400, 300));
ASSERT_EQ(widget_create_animator(w, ";move(y_from=0, y_to=128);;rotation(to=6.28, yoyo_times=0, duration=1000, easing=sin_out)"), RET_OK);
ASSERT_EQ(widget_create_animator(w,
";move(y_from=0, y_to=128);;rotation(to=6.28, yoyo_times=0, "
"duration=1000, easing=sin_out)"),
RET_OK);
ASSERT_EQ(widget_start_animator(w, "move"), RET_OK);
ASSERT_EQ(widget_pause_animator(w, "move"), RET_OK);
ASSERT_EQ(widget_find_animator(w, "move") != NULL, TRUE);

View File

@ -33,7 +33,14 @@ TEST(SpinBox, to_xml) {
str_init(&str, 1024);
ASSERT_EQ(widget_to_xml(w1, &str), RET_OK);
ASSERT_EQ(string(str.str), string("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<spin_box x=\"10\" y=\"20\" w=\"30\" h=\"40\" focusable=\"true\" min=\"0\" max=\"1024\" step=\"1.000000\" input_type=\"1\" readonly=\"false\" cancelable=\"false\" auto_fix=\"false\" left_margin=\"2\" right_margin=\"21\" top_margin=\"2\" bottom_margin=\"2\" action_text=\"done\" password_visible=\"false\">\n</spin_box>\n"));
ASSERT_EQ(
string(str.str),
string(
"<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<spin_box x=\"10\" y=\"20\" "
"w=\"30\" h=\"40\" focusable=\"true\" min=\"0\" max=\"1024\" step=\"1.000000\" "
"input_type=\"1\" readonly=\"false\" cancelable=\"false\" auto_fix=\"false\" "
"left_margin=\"2\" right_margin=\"21\" top_margin=\"2\" bottom_margin=\"2\" "
"action_text=\"done\" password_visible=\"false\">\n</spin_box>\n"));
str_reset(&str);
widget_destroy(w1);

View File

@ -433,7 +433,8 @@ TEST(ThemeGen, gradient) {
TEST(ThemeGen, bool) {
theme_t* theme = NULL;
const uint8_t* style_data = NULL;
const char* str = "<widget><style><normal feedback=\"true\" focusable=\"2\" clear_bg=\"1\"/></style></widget>";
const char* str =
"<widget><style><normal feedback=\"true\" focusable=\"2\" clear_bg=\"1\"/></style></widget>";
style_t* s = style_factory_create_style(NULL, theme_get_style_type(theme));

View File

@ -195,13 +195,13 @@ TEST(Tokenizer, str) {
ASSERT_STREQ(tokenizer_next(t), "a");
ASSERT_STREQ(tokenizer_next_str(t), "a=b && c=d");
ASSERT_STREQ(tokenizer_next(t), "b");
ASSERT_STREQ(tokenizer_next_str(t), "123");
ASSERT_STREQ(tokenizer_next(t), "c");
ASSERT_STREQ(tokenizer_next_str(t), "e=123");
ASSERT_STREQ(tokenizer_next(t), "d");
ASSERT_STREQ(tokenizer_next(t), "'123");

View File

@ -216,9 +216,9 @@ TEST(TypedArray, insert_bool) {
ASSERT_EQ(a->element_size, sizeof(uint8_t));
for (i = 0; i < 255; i++) {
ASSERT_EQ(a->size, (uint32_t)i);
ASSERT_EQ(typed_array_insert(a, 0, value_set_bool(&v, i%2==1)), RET_OK);
ASSERT_EQ(typed_array_insert(a, 0, value_set_bool(&v, i % 2 == 1)), RET_OK);
ASSERT_EQ(typed_array_get(a, 0, &v), RET_OK);
ASSERT_EQ(value_bool(&v), i%2==1);
ASSERT_EQ(value_bool(&v), i % 2 == 1);
}
ASSERT_EQ(typed_array_clear(a), RET_OK);

View File

@ -51,10 +51,11 @@ TEST(Utf8, chinese) {
TEST(Utf8, chinese2) {
/* 4 utf8 */
char buf[100] = {(char)0xf0, (char)0x90, (char)0xa4, (char)0x92, (char)0xf0, (char)0x90, (char)0x87, (char)0xaf, 0};
char buf[100] = {(char)0xf0, (char)0x90, (char)0xa4, (char)0x92, (char)0xf0,
(char)0x90, (char)0x87, (char)0xaf, 0};
const char* str = buf;
const wchar_t* wstr2 = L"𐤒𐇯";
char res_str[128];
wchar_t res_wstr[128];
tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
@ -68,7 +69,7 @@ TEST(Utf8, chinese2) {
0x4000001 6 utf8
utf16 utf16只能编码 0x10FFFF
windows的 wchar_t utf16, windows
*/
*/
if (sizeof(wchar_t) == 4) {
/* 5 utf8 */
char buf2[100] = {(char)0xf8, (char)0x88, (char)0x80, (char)0x80, (char)0x81, 0};
@ -85,13 +86,16 @@ TEST(Utf8, chinese2) {
ASSERT_EQ(strcmp(res_str, str), 0);
/* mixed */
char buf4[100] = {'a', 'B', (char)0xf0, (char)0x90, (char)0xa4, (char)0x92, (char)0xf0, (char)0x90, (char)0x87, (char)0xaf, (char)0xfc, (char)0x84, (char)0x80, (char)0x80, (char)0x80, (char)0x81, (char)0xf8, (char)0x88, (char)0x80, (char)0x80, (char)0x81, 0};
char buf4[100] = {'a', 'B', (char)0xf0, (char)0x90, (char)0xa4, (char)0x92,
(char)0xf0, (char)0x90, (char)0x87, (char)0xaf, (char)0xfc, (char)0x84,
(char)0x80, (char)0x80, (char)0x80, (char)0x81, (char)0xf8, (char)0x88,
(char)0x80, (char)0x80, (char)0x81, 0};
str = buf4;
tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
tk_utf8_from_utf16(res_wstr, res_str, ARRAY_SIZE(res_str));
ASSERT_EQ(strcmp(res_str, str), 0);
}
#endif
#endif
}
TEST(Utf8, out_len_invalid) {
@ -109,7 +113,8 @@ TEST(Utf8, dup) {
ASSERT_STREQ(str, text);
TKMEM_FREE(text);
char str2[9] = {(char)0xf0, (char)0x90, (char)0xa4, (char)0x92, (char)0xf0, (char)0x90, (char)0x87, (char)0xaf, 0};
char str2[9] = {(char)0xf0, (char)0x90, (char)0xa4, (char)0x92, (char)0xf0,
(char)0x90, (char)0x87, (char)0xaf, 0};
const wchar_t* wstr2 = L"𐤒𐇯";
text = tk_utf8_dup_utf16(wstr2, -1);

View File

@ -718,7 +718,7 @@ TEST(Utils, tk_memdup) {
s = (char*)tk_memdup("hello", 5);
ASSERT_STREQ(s, "hello");
TKMEM_FREE(s);
s = (char*)tk_memdup("hello", 10);
ASSERT_STREQ(s, "hello");
TKMEM_FREE(s);
@ -728,12 +728,12 @@ TEST(Utils, str_eq) {
ASSERT_EQ(tk_str_eq(NULL, NULL), TRUE);
ASSERT_EQ(tk_str_eq("a", NULL), FALSE);
ASSERT_EQ(tk_str_eq("a", "a"), TRUE);
ASSERT_EQ(tk_str_ieq(NULL, NULL), TRUE);
ASSERT_EQ(tk_str_ieq("a", NULL), FALSE);
ASSERT_EQ(tk_str_ieq("a", "a"), TRUE);
ASSERT_EQ(tk_str_ieq("a", "A"), TRUE);
ASSERT_EQ(tk_wstr_eq(NULL, NULL), TRUE);
ASSERT_EQ(tk_wstr_eq(L"a", NULL), FALSE);
ASSERT_EQ(tk_wstr_eq(L"a", L"a"), TRUE);
@ -749,4 +749,3 @@ TEST(Utils, replace_char) {
tk_strcpy(str, "a/b/c");
ASSERT_STREQ(tk_replace_char(str, '\\', '/'), "a/b/c");
}