chore(text): move "_" funcs to private h (#5913)

This commit is contained in:
liamHowatt
2024-04-06 03:01:11 -04:00
committed by GitHub
parent c9a6b25885
commit 3e21769fa6
16 changed files with 435 additions and 386 deletions

View File

@@ -2,6 +2,7 @@
#include "../lvgl.h"
#include "unity/unity.h"
#include "../../../src/misc/lv_text_private.h"
#include <string.h>
void test_txt_should_insert_string_into_another(void)
@@ -13,7 +14,7 @@ void test_txt_should_insert_string_into_another(void)
strcpy(target, msg);
_lv_text_ins(target, msg_len, suffix);
lv_text_ins(target, msg_len, suffix);
TEST_ASSERT_EQUAL_STRING("Hello World", target);
}
@@ -26,21 +27,21 @@ void test_txt_should_handle_null_pointers_when_inserting(void)
strcpy(target, msg);
_lv_text_ins(target, msg_len, NULL);
lv_text_ins(target, msg_len, NULL);
TEST_ASSERT_EQUAL_STRING("Hello ", target);
}
void test_txt_cut_should_handle_null_pointer_to_txt(void)
{
_lv_text_cut(NULL, 0, 6);
lv_text_cut(NULL, 0, 6);
}
void test_txt_cut_happy_path(void)
{
char msg[] = "Hello World";
_lv_text_cut(msg, 0, 6);
lv_text_cut(msg, 0, 6);
TEST_ASSERT_EQUAL_STRING("World", msg);
}
@@ -49,7 +50,7 @@ void test_txt_cut_should_handle_len_longer_than_string_length(void)
{
char msg[] = "Hello World";
_lv_text_cut(msg, 0, 30);
lv_text_cut(msg, 0, 30);
TEST_ASSERT_EQUAL_UINT8(msg[0], 0x00);
}
@@ -59,7 +60,7 @@ void test_txt_get_encoded_next_should_decode_valid_ascii(void)
char msg[] = "Hello World!";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32((uint32_t) 'H', result);
}
@@ -69,7 +70,7 @@ void test_txt_get_encoded_next_detect_valid_2_byte_input(void)
char msg[] = "\xc3\xb1";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32(241, result);
}
@@ -79,7 +80,7 @@ void test_txt_get_encoded_next_detect_invalid_2_byte_input(void)
char msg[] = "\xc3\x28";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32(0, result);
}
@@ -89,7 +90,7 @@ void test_txt_get_encoded_next_detect_valid_3_byte_input(void)
char msg[] = "\xe2\x82\xa1";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32(8353, result);
}
@@ -99,7 +100,7 @@ void test_txt_get_encoded_next_detect_invalid_3_byte_input(void)
char msg[] = "\xe2\x28\xa1";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32(0, result);
}
@@ -109,7 +110,7 @@ void test_txt_get_encoded_next_detect_valid_4_byte_input(void)
char msg[] = "\xf0\x90\x8c\xbc";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32(66364, result);
}
@@ -119,7 +120,7 @@ void test_txt_get_encoded_next_detect_invalid_4_byte_input(void)
char msg[] = "\xf0\x28\x8c\x28";
uint32_t result = 0;
result = _lv_text_encoded_next(msg, NULL);
result = lv_text_encoded_next(msg, NULL);
TEST_ASSERT_EQUAL_UINT32(0, result);
}
@@ -132,7 +133,7 @@ void test_txt_next_line_should_handle_empty_string(void)
int32_t max_width = 0;
lv_text_flag_t flag = LV_TEXT_FLAG_NONE;
uint32_t next_line = _lv_text_get_next_line("", font_ptr, letter_space, max_width, NULL, flag);
uint32_t next_line = lv_text_get_next_line("", font_ptr, letter_space, max_width, NULL, flag);
TEST_ASSERT_EQUAL_UINT32(0, next_line);
}