1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-02-04 07:13:00 +08:00

chore(test): format test cases (#3071)

This commit is contained in:
Carlos Diaz 2022-02-03 02:59:55 -06:00 committed by GitHub
parent e400a87df9
commit 2c7760c687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 474 additions and 447 deletions

View File

@ -0,0 +1,26 @@
--style=kr
--indent=spaces=4
--indent-classes
--indent-switches
--indent-cases
--indent-preproc-block
--indent-preproc-define
--indent-col1-comments
--pad-oper
--unpad-paren
--align-pointer=middle
--align-reference=middle
--convert-tabs
--max-code-length=120
--break-after-logical
--break-closing-braces
--attach-closing-while
--min-conditional-indent=0
--max-continuation-indent=120
--mode=c
--lineend=linux
--recursive
--suffix=none
--preserve-date
--formatted
--exclude=../tests/src/test_cases/_test_template.c

View File

@ -3,3 +3,4 @@
import os import os
os.system('astyle --options=code-format.cfg "../src/*.c,*.h"') os.system('astyle --options=code-format.cfg "../src/*.c,*.h"')
os.system('astyle --options=code-format-tests.cfg "../tests/src/test_cases/*.c"')

View File

@ -15,8 +15,8 @@ void test_arc_should_update_angles_when_changing_to_symmetrical_mode(void);
void test_arc_should_update_angles_when_changing_to_symmetrical_mode_value_more_than_middle_range(void); void test_arc_should_update_angles_when_changing_to_symmetrical_mode_value_more_than_middle_range(void);
void test_arc_angles_when_reversed(void); void test_arc_angles_when_reversed(void);
static lv_obj_t *active_screen = NULL; static lv_obj_t * active_screen = NULL;
static lv_obj_t *arc = NULL; static lv_obj_t * arc = NULL;
static uint32_t event_cnt; static uint32_t event_cnt;
static void dummy_event_cb(lv_event_t * e); static void dummy_event_cb(lv_event_t * e);
@ -109,7 +109,7 @@ void test_arc_angles_when_reversed(void)
uint16_t expected_end_angle = 90; uint16_t expected_end_angle = 90;
int16_t expected_value = 40; int16_t expected_value = 40;
lv_obj_t *arcBlack; lv_obj_t * arcBlack;
arcBlack = lv_arc_create(lv_scr_act()); arcBlack = lv_arc_create(lv_scr_act());
lv_arc_set_mode(arcBlack, LV_ARC_MODE_REVERSE); lv_arc_set_mode(arcBlack, LV_ARC_MODE_REVERSE);

View File

@ -5,8 +5,8 @@
#include "lv_test_indev.h" #include "lv_test_indev.h"
static lv_obj_t *active_screen = NULL; static lv_obj_t * active_screen = NULL;
static lv_obj_t *bar = NULL; static lv_obj_t * bar = NULL;
void setUp(void) void setUp(void)
{ {

View File

@ -12,16 +12,16 @@ void test_checkbox_should_have_default_text_when_created(void);
void test_checkbox_should_return_dinamically_allocated_text(void); void test_checkbox_should_return_dinamically_allocated_text(void);
void test_checkbox_should_allocate_memory_for_static_text(void); void test_checkbox_should_allocate_memory_for_static_text(void);
static lv_obj_t *active_screen = NULL; static lv_obj_t * active_screen = NULL;
static lv_obj_t *checkbox = NULL; static lv_obj_t * checkbox = NULL;
static volatile bool event_called = false; static volatile bool event_called = false;
static void event_handler(lv_event_t *e) static void event_handler(lv_event_t * e)
{ {
lv_event_code_t code = lv_event_get_code(e); lv_event_code_t code = lv_event_get_code(e);
if (LV_EVENT_VALUE_CHANGED == code) { if(LV_EVENT_VALUE_CHANGED == code) {
event_called = true; event_called = true;
} }
} }
@ -51,7 +51,7 @@ void test_checkbox_should_call_event_handler_on_click_when_enabled(void)
void test_checkbox_should_have_default_text_when_created(void) void test_checkbox_should_have_default_text_when_created(void)
{ {
const char *default_text = "Check box"; const char * default_text = "Check box";
active_screen = lv_scr_act(); active_screen = lv_scr_act();
checkbox = lv_checkbox_create(active_screen); checkbox = lv_checkbox_create(active_screen);
@ -62,7 +62,7 @@ void test_checkbox_should_have_default_text_when_created(void)
void test_checkbox_should_return_dinamically_allocated_text(void) void test_checkbox_should_return_dinamically_allocated_text(void)
{ {
const char *message = "Hello World!"; const char * message = "Hello World!";
active_screen = lv_scr_act(); active_screen = lv_scr_act();
checkbox = lv_checkbox_create(active_screen); checkbox = lv_checkbox_create(active_screen);
@ -76,7 +76,7 @@ void test_checkbox_should_return_dinamically_allocated_text(void)
void test_checkbox_should_allocate_memory_for_static_text(void) void test_checkbox_should_allocate_memory_for_static_text(void)
{ {
uint32_t initial_available_memory = 0; uint32_t initial_available_memory = 0;
const char *static_text = "Keep me while you exist"; const char * static_text = "Keep me while you exist";
lv_mem_monitor_t m1; lv_mem_monitor_t m1;
lv_mem_monitor(&m1); lv_mem_monitor(&m1);

View File

@ -10,7 +10,7 @@
static void loop_through_stress_test(void) static void loop_through_stress_test(void)
{ {
#if LV_USE_DEMO_STRESS #if LV_USE_DEMO_STRESS
lv_test_indev_wait(LV_DEMO_STRESS_TIME_STEP*33); /* FIXME: remove magic number of states */ lv_test_indev_wait(LV_DEMO_STRESS_TIME_STEP * 33); /* FIXME: remove magic number of states */
#endif #endif
} }
void test_demo_stress(void) void test_demo_stress(void)

View File

@ -3,7 +3,7 @@
#include "unity/unity.h" #include "unity/unity.h"
static void event_object_deletion_cb(const lv_obj_class_t *cls, lv_event_t *e) static void event_object_deletion_cb(const lv_obj_class_t * cls, lv_event_t * e)
{ {
LV_UNUSED(cls); LV_UNUSED(cls);
if(lv_event_get_code(e) == LV_EVENT_VALUE_CHANGED) { if(lv_event_get_code(e) == LV_EVENT_VALUE_CHANGED) {

View File

@ -63,10 +63,10 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
TEST_ASSERT_NOT_NULL_MESSAGE(f1, "font not null"); TEST_ASSERT_NOT_NULL_MESSAGE(f1, "font not null");
TEST_ASSERT_NOT_NULL_MESSAGE(f2, "font not null"); TEST_ASSERT_NOT_NULL_MESSAGE(f2, "font not null");
// Skip these test because -Wpedantic tells // Skip these test because -Wpedantic tells
// ISO C forbids passing argument 1 of lv_test_assert_ptr_eq between function pointer and void * // ISO C forbids passing argument 1 of lv_test_assert_ptr_eq between function pointer and void *
// TEST_ASSERT_EQUAL_PTR_MESSAGE(f1->get_glyph_dsc, f2->get_glyph_dsc, "glyph_dsc"); // TEST_ASSERT_EQUAL_PTR_MESSAGE(f1->get_glyph_dsc, f2->get_glyph_dsc, "glyph_dsc");
// TEST_ASSERT_EQUAL_PTR_MESSAGE(f1->get_glyph_bitmap, f2->get_glyph_bitmap, "glyph_bitmap"); // TEST_ASSERT_EQUAL_PTR_MESSAGE(f1->get_glyph_bitmap, f2->get_glyph_bitmap, "glyph_bitmap");
TEST_ASSERT_EQUAL_INT_MESSAGE(f1->line_height, f2->line_height, "line_height"); TEST_ASSERT_EQUAL_INT_MESSAGE(f1->line_height, f2->line_height, "line_height");
TEST_ASSERT_EQUAL_INT_MESSAGE(f1->base_line, f2->base_line, "base_line"); TEST_ASSERT_EQUAL_INT_MESSAGE(f1->base_line, f2->base_line, "base_line");
@ -119,10 +119,10 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
} }
// kern_dsc // kern_dsc
if (dsc1->kern_classes == 1 && dsc2->kern_classes == 1) { if(dsc1->kern_classes == 1 && dsc2->kern_classes == 1) {
lv_font_fmt_txt_kern_classes_t * kern1 = (lv_font_fmt_txt_kern_classes_t *)dsc1->kern_dsc; lv_font_fmt_txt_kern_classes_t * kern1 = (lv_font_fmt_txt_kern_classes_t *)dsc1->kern_dsc;
lv_font_fmt_txt_kern_classes_t * kern2 = (lv_font_fmt_txt_kern_classes_t *)dsc2->kern_dsc; lv_font_fmt_txt_kern_classes_t * kern2 = (lv_font_fmt_txt_kern_classes_t *)dsc2->kern_dsc;
if (kern1 != NULL && kern2 != NULL) { if(kern1 != NULL && kern2 != NULL) {
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->right_class_cnt, kern2->right_class_cnt, "right_class_cnt"); TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->right_class_cnt, kern2->right_class_cnt, "right_class_cnt");
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->left_class_cnt, kern2->left_class_cnt, "left_class_cnt"); TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->left_class_cnt, kern2->left_class_cnt, "left_class_cnt");
@ -148,16 +148,16 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
TEST_ASSERT_EQUAL_PTR_MESSAGE(kern1, kern2, "kern"); TEST_ASSERT_EQUAL_PTR_MESSAGE(kern1, kern2, "kern");
} }
} }
else if (dsc1->kern_classes == 0 && dsc2->kern_classes == 0) { else if(dsc1->kern_classes == 0 && dsc2->kern_classes == 0) {
lv_font_fmt_txt_kern_pair_t * kern1 = (lv_font_fmt_txt_kern_pair_t *)dsc1->kern_dsc; lv_font_fmt_txt_kern_pair_t * kern1 = (lv_font_fmt_txt_kern_pair_t *)dsc1->kern_dsc;
lv_font_fmt_txt_kern_pair_t * kern2 = (lv_font_fmt_txt_kern_pair_t *)dsc2->kern_dsc; lv_font_fmt_txt_kern_pair_t * kern2 = (lv_font_fmt_txt_kern_pair_t *)dsc2->kern_dsc;
if (kern1 != NULL && kern2 != NULL) { if(kern1 != NULL && kern2 != NULL) {
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->glyph_ids_size, kern2->glyph_ids_size, "glyph_ids_size"); TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->glyph_ids_size, kern2->glyph_ids_size, "glyph_ids_size");
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->pair_cnt, kern2->pair_cnt, "pair_cnt"); TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->pair_cnt, kern2->pair_cnt, "pair_cnt");
int ids_size; int ids_size;
if (kern1->glyph_ids_size == 0) { if(kern1->glyph_ids_size == 0) {
ids_size = sizeof(int8_t) * 2 * kern1->pair_cnt; ids_size = sizeof(int8_t) * 2 * kern1->pair_cnt;
} }
else { else {
@ -166,8 +166,8 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(kern1->glyph_ids, kern2->glyph_ids, ids_size, "glyph_ids"); TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(kern1->glyph_ids, kern2->glyph_ids, ids_size, "glyph_ids");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE( TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
(uint8_t * ) kern1->values, (uint8_t *) kern1->values,
(uint8_t * ) kern2->values, (uint8_t *) kern2->values,
kern1->pair_cnt, kern1->pair_cnt,
"glyph_values"); "glyph_values");
} }
@ -177,10 +177,10 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
lv_font_fmt_txt_glyph_dsc_t * glyph_dsc2 = (lv_font_fmt_txt_glyph_dsc_t *)dsc2->glyph_dsc; lv_font_fmt_txt_glyph_dsc_t * glyph_dsc2 = (lv_font_fmt_txt_glyph_dsc_t *)dsc2->glyph_dsc;
for(int i = 0; i < total_glyphs; ++i) { for(int i = 0; i < total_glyphs; ++i) {
if (i < total_glyphs - 1) { if(i < total_glyphs - 1) {
int size1 = glyph_dsc1[i+1].bitmap_index - glyph_dsc1[i].bitmap_index; int size1 = glyph_dsc1[i + 1].bitmap_index - glyph_dsc1[i].bitmap_index;
if (size1 > 0) { if(size1 > 0) {
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE( TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
dsc1->glyph_bitmap + glyph_dsc1[i].bitmap_index, dsc1->glyph_bitmap + glyph_dsc1[i].bitmap_index,
dsc2->glyph_bitmap + glyph_dsc2[i].bitmap_index, dsc2->glyph_bitmap + glyph_dsc2[i].bitmap_index,

View File

@ -15,7 +15,7 @@ void test_snapshot_should_not_leak_memory(void)
uint32_t final_available_memory = 0; uint32_t final_available_memory = 0;
lv_mem_monitor_t monitor; lv_mem_monitor_t monitor;
lv_img_dsc_t *snapshots[NUM_SNAPSHOTS] = {NULL}; lv_img_dsc_t * snapshots[NUM_SNAPSHOTS] = {NULL};
lv_mem_monitor(&monitor); lv_mem_monitor(&monitor);
initial_available_memory = monitor.free_size; initial_available_memory = monitor.free_size;

View File

@ -9,8 +9,8 @@
#define SWITCHES_CNT 10 #define SWITCHES_CNT 10
uint8_t value_changed_event_cnt = 0; uint8_t value_changed_event_cnt = 0;
lv_obj_t *scr = NULL; lv_obj_t * scr = NULL;
lv_obj_t *sw = NULL; lv_obj_t * sw = NULL;
void setUp(void) void setUp(void)
{ {
@ -30,11 +30,11 @@ static void mouse_click_on_switch(void)
lv_test_mouse_click_at(sw->coords.x1, sw->coords.y1); lv_test_mouse_click_at(sw->coords.x1, sw->coords.y1);
} }
static void event_handler(lv_event_t *e) static void event_handler(lv_event_t * e)
{ {
lv_event_code_t event = lv_event_get_code(e); lv_event_code_t event = lv_event_get_code(e);
if (LV_EVENT_VALUE_CHANGED == event) { if(LV_EVENT_VALUE_CHANGED == event) {
value_changed_event_cnt++; value_changed_event_cnt++;
} }
@ -52,16 +52,16 @@ void test_switch_should_not_leak_memory_after_deletion(void)
uint32_t initial_available_memory = 0; uint32_t initial_available_memory = 0;
uint32_t final_available_memory = 0; uint32_t final_available_memory = 0;
lv_mem_monitor_t monitor; lv_mem_monitor_t monitor;
lv_obj_t *switches[SWITCHES_CNT] = {NULL}; lv_obj_t * switches[SWITCHES_CNT] = {NULL};
lv_mem_monitor(&monitor); lv_mem_monitor(&monitor);
initial_available_memory = monitor.free_size; initial_available_memory = monitor.free_size;
for (idx = 0; idx < SWITCHES_CNT; idx++) { for(idx = 0; idx < SWITCHES_CNT; idx++) {
switches[idx] = lv_switch_create(scr); switches[idx] = lv_switch_create(scr);
} }
for (idx = 0; idx < SWITCHES_CNT; idx++) { for(idx = 0; idx < SWITCHES_CNT; idx++) {
lv_obj_del(switches[idx]); lv_obj_del(switches[idx]);
} }

View File

@ -73,8 +73,8 @@ void test_txt_should_identify_space_after_parameter(void)
void test_txt_should_insert_string_into_another(void) void test_txt_should_insert_string_into_another(void)
{ {
const char *msg = "Hello "; const char * msg = "Hello ";
const char *suffix = "World"; const char * suffix = "World";
char target[20] = {0}; char target[20] = {0};
size_t msg_len = strlen(msg); size_t msg_len = strlen(msg);
@ -87,7 +87,7 @@ void test_txt_should_insert_string_into_another(void)
void test_txt_should_handle_null_pointers_when_inserting(void) void test_txt_should_handle_null_pointers_when_inserting(void)
{ {
const char *msg = "Hello "; const char * msg = "Hello ";
char target[20] = {0}; char target[20] = {0};
size_t msg_len = strlen(msg); size_t msg_len = strlen(msg);
@ -194,7 +194,7 @@ void test_txt_get_encoded_next_detect_invalid_4_byte_input(void)
/* See #2615 for more information */ /* See #2615 for more information */
void test_txt_next_line_should_handle_empty_string(void) void test_txt_next_line_should_handle_empty_string(void)
{ {
const lv_font_t *font_ptr = NULL; const lv_font_t * font_ptr = NULL;
lv_coord_t letter_space = 0; lv_coord_t letter_space = 0;
lv_coord_t max_width = 0; lv_coord_t max_width = 0;
lv_text_flag_t flag = LV_TEXT_FLAG_NONE; lv_text_flag_t flag = LV_TEXT_FLAG_NONE;