diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-04-26 12:41:54 +0300 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-04-26 15:50:21 +0300 |
commit | 4ecdb2a83871784f34430ed09d5ef6a2c0855506 (patch) | |
tree | dc36b449e5d32ac3e493e16865cf9d88d9991817 /src/components/config_profile | |
parent | cf58bb97d09c536dce3b492d1517da0b837bc8eb (diff) | |
download | sdl_core-4ecdb2a83871784f34430ed09d5ef6a2c0855506.tar.gz |
Format all code in project
Formated all code in appMain, components, plugins to correct coding-style
Used clang-format-3.6
Used 2 commands :
find src/appMain/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
find src/components/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
find src/plugins/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
Diffstat (limited to 'src/components/config_profile')
-rw-r--r-- | src/components/config_profile/include/config_profile/ini_file.h | 37 | ||||
-rw-r--r-- | src/components/config_profile/src/ini_file.cc | 141 | ||||
-rw-r--r-- | src/components/config_profile/test/ini_file_test.cc | 200 |
3 files changed, 188 insertions, 190 deletions
diff --git a/src/components/config_profile/include/config_profile/ini_file.h b/src/components/config_profile/include/config_profile/ini_file.h index 1b6248246c..3f3ddddf48 100644 --- a/src/components/config_profile/include/config_profile/ini_file.h +++ b/src/components/config_profile/include/config_profile/ini_file.h @@ -37,7 +37,7 @@ namespace profile { -#define INI_FILE_VER 1000 +#define INI_FILE_VER 1000 #if !defined TRUE #define TRUE 1 @@ -56,12 +56,12 @@ namespace profile { /* * @brief Global defines */ -#define INI_LINE_LEN 512 -#define INI_FILE_TEMP_NAME "ini.tmp" +#define INI_LINE_LEN 512 +#define INI_FILE_TEMP_NAME "ini.tmp" -#define INI_FLAG_UPDATE 0x00 -#define INI_FLAG_ITEM_UP_CREA 0x01 -#define INI_FLAG_FILE_UP_CREA 0x10 +#define INI_FLAG_UPDATE 0x00 +#define INI_FLAG_ITEM_UP_CREA 0x01 +#define INI_FLAG_FILE_UP_CREA 0x10 /* * @brief Global typedefs @@ -90,28 +90,27 @@ extern "C" { * * @return NULL if file or desired entry not found, otherwise pointer to fname */ -extern char* ini_write_inst(const char *fname, - uint8_t flag); +extern char* ini_write_inst(const char* fname, uint8_t flag); /* * @brief Read a certain item of the specified chapter of a ini-file * * @return NULL if file or desired entry not found, otherwise pointer to value */ -extern char* ini_read_value(const char *fname, - const char *chapter, - const char *item, - char *value); +extern char* ini_read_value(const char* fname, + const char* chapter, + const char* item, + char* value); /* * @brief Write a certain item of the specified chapter of a ini-file * * @return NULL if file not found, otherwise pointer to value */ -extern char ini_write_value(const char *fname, - const char *chapter, - const char *item, - const char *value, +extern char ini_write_value(const char* fname, + const char* chapter, + const char* item, + const char* value, uint8_t flag); /* @@ -120,9 +119,9 @@ extern char ini_write_value(const char *fname, * * @return NULL if desired entry not found, otherwise pointer to value */ -extern Ini_search_id ini_parse_line(const char *line, - const char *tag, - char *value); +extern Ini_search_id ini_parse_line(const char* line, + const char* tag, + char* value); #ifdef __cplusplus } diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc index fcdf24db31..d6d72060e8 100644 --- a/src/components/config_profile/src/ini_file.cc +++ b/src/components/config_profile/src/ini_file.cc @@ -42,19 +42,19 @@ #ifndef _WIN32 #include <unistd.h> #else -#define PATH_MAX _MAX_PATH +#define PATH_MAX _MAX_PATH #endif #ifdef __linux__ -#define USE_MKSTEMP 1 +#define USE_MKSTEMP 1 #endif #include <string> namespace profile { -char* ini_write_inst(const char *fname, uint8_t flag) { - FILE *fp = 0; +char* ini_write_inst(const char* fname, uint8_t flag) { + FILE* fp = 0; if (NULL == fname) return NULL; @@ -89,15 +89,17 @@ char* ini_write_inst(const char *fname, uint8_t flag) { return const_cast<char*>(fname); } -char* ini_read_value(const char *fname, - const char *chapter, const char *item, char *value) { - FILE *fp = 0; - bool chapter_found = false; - char line[INI_LINE_LEN] = ""; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = ""; - - Ini_search_id result; +char* ini_read_value(const char* fname, + const char* chapter, + const char* item, + char* value) { + FILE* fp = 0; + bool chapter_found = false; + char line[INI_LINE_LEN] = ""; + char val[INI_LINE_LEN] = ""; + char tag[INI_LINE_LEN] = ""; + + Ini_search_id result; *line = '\0'; *val = '\0'; *tag = '\0'; @@ -146,19 +148,21 @@ char* ini_read_value(const char *fname, return NULL; } -char ini_write_value(const char *fname, - const char *chapter, const char *item, - const char *value, uint8_t flag) { - FILE *rd_fp, *wr_fp = 0; - uint16_t i, cr_count; - int32_t wr_result; - bool chapter_found = false; - bool value_written = false; - char line[INI_LINE_LEN] = ""; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = ""; - char temp_fname[PATH_MAX] = ""; - Ini_search_id result; +char ini_write_value(const char* fname, + const char* chapter, + const char* item, + const char* value, + uint8_t flag) { + FILE* rd_fp, * wr_fp = 0; + uint16_t i, cr_count; + int32_t wr_result; + bool chapter_found = false; + bool value_written = false; + char line[INI_LINE_LEN] = ""; + char val[INI_LINE_LEN] = ""; + char tag[INI_LINE_LEN] = ""; + char temp_fname[PATH_MAX] = ""; + Ini_search_id result; *line = '\0'; *val = '\0'; *tag = '\0'; @@ -177,11 +181,10 @@ char ini_write_value(const char *fname, #if USE_MKSTEMP { - const char *temp_str = "./"; + const char* temp_str = "./"; int32_t fd = -1; if (temp_str) { - snprintf(temp_fname, PATH_MAX, - "%s/ini.XXXXXX", temp_str); + snprintf(temp_fname, PATH_MAX, "%s/ini.XXXXXX", temp_str); fd = mkstemp(temp_fname); if (-1 == fd) { @@ -200,16 +203,17 @@ char ini_write_value(const char *fname, #else // #if USE_MKSTEMP tmpnam(temp_fname); if (0 == (wr_fp = fopen(temp_fname, "w"))) { - fclose(rd_fp); - return FALSE; + fclose(rd_fp); + return FALSE; } -#endif // #else #if USE_MKSTEMP +#endif // #else #if USE_MKSTEMP snprintf(tag, INI_LINE_LEN, "%s", chapter); - for (uint32_t i = 0; i < strlen (tag); i++) + for (uint32_t i = 0; i < strlen(tag); i++) tag[i] = toupper(tag[i]); - wr_result = 1; cr_count = 0; + wr_result = 1; + cr_count = 0; while ((NULL != fgets(line, INI_LINE_LEN, rd_fp)) && (0 < wr_result)) { // Now start the line parsing result = ini_parse_line(line, tag, val); @@ -220,7 +224,7 @@ char ini_write_value(const char *fname, chapter_found = true; // coding style snprintf(tag, INI_LINE_LEN, "%s", item); - for (uint32_t i = 0; i < strlen (tag); i++) + for (uint32_t i = 0; i < strlen(tag); i++) tag[i] = toupper(tag[i]); } } else { @@ -241,7 +245,7 @@ char ini_write_value(const char *fname, continue; } } - } /* if (!value_written) */ + } /* if (!value_written) */ if (0 == strcmp(val, "\n")) { cr_count++; @@ -262,7 +266,6 @@ char ini_write_value(const char *fname, } fprintf(wr_fp, "\n"); - fclose(wr_fp); fclose(rd_fp); @@ -275,10 +278,10 @@ char ini_write_value(const char *fname, return (value_written); } -Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { - const char *line_ptr; - char *temp_ptr; - char temp_str[INI_LINE_LEN] = ""; +Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) { + const char* line_ptr; + char* temp_ptr; + char temp_str[INI_LINE_LEN] = ""; *temp_str = '\0'; snprintf(value, INI_LINE_LEN, "%s", line); @@ -286,13 +289,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { /* cut leading spaces */ line_ptr = line; for (uint32_t i = 0; i < strlen(line); i++) { - if ((line[i] == ' ') || - (line[i] == 9) || // TAB - (line[i] == 10) || // LF - (line[i] == 13)) { // CR + if ((line[i] == ' ') || (line[i] == 9) || // TAB + (line[i] == 10) || // LF + (line[i] == 13)) { // CR line_ptr++; } else { - break; + break; } } if ('\0' == *line_ptr) { @@ -300,7 +302,7 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { return INI_NOTHING; } - if ((*line_ptr == ';') || (*line_ptr == '*')) /* remark */ + if ((*line_ptr == ';') || (*line_ptr == '*')) /* remark */ return INI_REMARK; if (*line_ptr == '[' && strrchr(line_ptr, ']') != NULL) { @@ -309,13 +311,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { /* cut leading stuff */ uint16_t len = strlen(line_ptr); for (int32_t i = 0; i < len; i++) { - if ((*line_ptr == ' ') || - (*line_ptr == 9) || // TAB - (*line_ptr == 10) || // LF - (*line_ptr == 13)) { // CR + if ((*line_ptr == ' ') || (*line_ptr == 9) || // TAB + (*line_ptr == 10) || // LF + (*line_ptr == 13)) { // CR line_ptr++; } else { - break; + break; } } if (*line_ptr == '\0') @@ -331,13 +332,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { /* cut trailing stuff */ for (int32_t i = strlen(temp_str) - 1; i > 0; i--) { - if ((temp_str[i] == ' ') || - (temp_str[i] == 9) || // TAB - (temp_str[i] == 10) || // LF - (temp_str[i] == 13)) { // CR + if ((temp_str[i] == ' ') || (temp_str[i] == 9) || // TAB + (temp_str[i] == 10) || // LF + (temp_str[i] == 13)) { // CR temp_str[i] = '\0'; } else { - break; + break; } } @@ -355,11 +355,10 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { strncpy(temp_str, line_ptr, (strchr(line_ptr, '=') - line_ptr)); /* cut trailing stuff */ for (int32_t i = strlen(temp_str) - 1; i > 0; i--) { - if ((temp_str[i] == '=') || - (temp_str[i] == ' ') || - (temp_str[i] == 9) || // TAB - (temp_str[i] == 10) || // LF - (temp_str[i] == 13)) { // CR + if ((temp_str[i] == '=') || (temp_str[i] == ' ') || + (temp_str[i] == 9) || // TAB + (temp_str[i] == 10) || // LF + (temp_str[i] == 13)) { // CR temp_str[i] = '\0'; } else { break; @@ -368,17 +367,16 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { snprintf(value, INI_LINE_LEN, "%s", temp_str); - for (uint32_t i = 0; i < strlen (temp_str); i++) + for (uint32_t i = 0; i < strlen(temp_str); i++) temp_str[i] = toupper(temp_str[i]); if (strcmp(temp_str, tag) == 0) { line_ptr = strchr(line_ptr, '=') + 1; uint16_t len = strlen(line_ptr); /* cut trailing stuff */ for (uint32_t i = 0; i < len; i++) { - if ((*line_ptr == ' ') || - (*line_ptr == 9) || // TAB - (*line_ptr == 10) || // LF - (*line_ptr == 13)) { // CR + if ((*line_ptr == ' ') || (*line_ptr == 9) || // TAB + (*line_ptr == 10) || // LF + (*line_ptr == 13)) { // CR line_ptr++; } else { break; @@ -390,11 +388,10 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { if (value[0] != '\0') { /* cut trailing stuff */ for (int32_t i = strlen(value) - 1; i > 0; i--) { - if ((value[i] == ' ') || - (value[i] == ';') || - (value[i] == 9) || // TAB - (value[i] == 10) || // LF - (value[i] == 13)) { // CR + if ((value[i] == ' ') || (value[i] == ';') || + (value[i] == 9) || // TAB + (value[i] == 10) || // LF + (value[i] == 13)) { // CR value[i] = '\0'; } else { break; diff --git a/src/components/config_profile/test/ini_file_test.cc b/src/components/config_profile/test/ini_file_test.cc index cd124c9ed3..2f256c8b51 100644 --- a/src/components/config_profile/test/ini_file_test.cc +++ b/src/components/config_profile/test/ini_file_test.cc @@ -42,16 +42,16 @@ using namespace ::profile; TEST(IniFileTest, WriteItemReadItem) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * item = "Test_item"; - const char * value = "test_value"; - const bool write_result = ini_write_value(fname, chapter, item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* item = "Test_item"; + const char* value = "test_value"; + const bool write_result = + ini_write_value(fname, chapter, item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); char search_value[INI_LINE_LEN] = {0}; const bool read_result = ini_read_value(fname, chapter, item, search_value); - const char *res = search_value; + const char* res = search_value; EXPECT_TRUE(read_result); EXPECT_STREQ(res, value); @@ -60,18 +60,19 @@ TEST(IniFileTest, WriteItemReadItem) { TEST(IniFileTest, WriteItemWithoutValueReadItem) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * test_item = "Test_item"; - const char * value = ""; - const bool write_result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* test_item = "Test_item"; + const char* value = ""; + const bool write_result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); // Read value from file char search_value[INI_LINE_LEN] = {0}; - const bool read_result = ini_read_value(fname, chapter, test_item, search_value); - const char *res = search_value; + const bool read_result = + ini_read_value(fname, chapter, test_item, search_value); + const char* res = search_value; EXPECT_TRUE(read_result); EXPECT_STREQ(res, value); @@ -80,30 +81,31 @@ TEST(IniFileTest, WriteItemWithoutValueReadItem) { TEST(IniFileTest, WriteSameItemInDifferentChapters) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter1 = "Chapter1"; - const char * test_item = "Test_item"; - const char * value = "test_value"; - const bool write_result = ini_write_value(fname, chapter1, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter1 = "Chapter1"; + const char* test_item = "Test_item"; + const char* value = "test_value"; + const bool write_result = + ini_write_value(fname, chapter1, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); char search_value[INI_LINE_LEN] = {0}; - const bool read_result = ini_read_value(fname, chapter1, test_item, search_value); - const char *res = search_value; + const bool read_result = + ini_read_value(fname, chapter1, test_item, search_value); + const char* res = search_value; EXPECT_TRUE(read_result); EXPECT_STREQ(res, value); // Create new chapter and write the same value - const char *chapter2 = "Chapter2"; + const char* chapter2 = "Chapter2"; - const bool write_result2 = ini_write_value(fname, chapter2, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const bool write_result2 = + ini_write_value(fname, chapter2, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result2); char value2[INI_LINE_LEN] = "test_value"; const bool read_result2 = ini_read_value(fname, chapter2, test_item, value2); - const char *res2 = value2; + const char* res2 = value2; EXPECT_TRUE(read_result2); EXPECT_STREQ(res2, res); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); @@ -111,29 +113,29 @@ TEST(IniFileTest, WriteSameItemInDifferentChapters) { TEST(IniFileTest, RewriteItem) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * item = "Test_item"; - const char * value = "test_value"; - bool write_result = ini_write_value(fname, chapter, item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* item = "Test_item"; + const char* value = "test_value"; + bool write_result = + ini_write_value(fname, chapter, item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); char search_value[INI_LINE_LEN] = {0}; bool read_result = ini_read_value(fname, chapter, item, search_value); - const char *res = search_value; + const char* res = search_value; EXPECT_TRUE(read_result); EXPECT_STREQ(res, value); // Write item again - const char * newvalue = "new_test_value"; - write_result = ini_write_value(fname, chapter, item, newvalue, - INI_FLAG_ITEM_UP_CREA); + const char* newvalue = "new_test_value"; + write_result = + ini_write_value(fname, chapter, item, newvalue, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); char new_search_value[INI_LINE_LEN] = {0}; read_result = ini_read_value(fname, chapter, item, new_search_value); - const char *new_res = new_search_value; + const char* new_res = new_search_value; EXPECT_TRUE(read_result); EXPECT_STREQ(new_res, newvalue); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); @@ -141,92 +143,92 @@ TEST(IniFileTest, RewriteItem) { TEST(IniFileTest, WriteTwoItemsInOneChapter) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * item = "Test_item"; - const char * value1 = "test_value"; + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* item = "Test_item"; + const char* value1 = "test_value"; - bool write_result = ini_write_value(fname, chapter, item, value1, - INI_FLAG_ITEM_UP_CREA); + bool write_result = + ini_write_value(fname, chapter, item, value1, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); // Write another line in the same chapter - const char * item2 = "Test_item2"; - const char * value2 = "test_value2"; + const char* item2 = "Test_item2"; + const char* value2 = "test_value2"; - write_result = ini_write_value(fname, chapter, item2, value2, - INI_FLAG_ITEM_UP_CREA); + write_result = + ini_write_value(fname, chapter, item2, value2, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); // Search both values char search_value[INI_LINE_LEN] = {0}; bool read_result = ini_read_value(fname, chapter, item, search_value); - const char *res = search_value; + const char* res = search_value; EXPECT_TRUE(read_result); EXPECT_STREQ(res, value1); char search_value2[INI_LINE_LEN] = {0}; read_result = ini_read_value(fname, chapter, item2, search_value2); - const char *res2 = search_value2; + const char* res2 = search_value2; EXPECT_TRUE(read_result); EXPECT_STREQ(res2, value2); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); } TEST(IniFileTest, WriteEmptyItemWithValueReadItem) { - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * test_item = ""; - const char * value = "test_value"; - bool result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* test_item = ""; + const char* value = "test_value"; + bool result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_FALSE(result); } TEST(IniFileTest, WriteEmptyItemWithEmptyValue_ExpectFalse) { // Write empty line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * test_item = ""; - const char * value = ""; - bool result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* test_item = ""; + const char* value = ""; + bool result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_FALSE(result); } TEST(IniFileTest, WriteItemInEmptyChapter_ExpectFalse) { // Write line in empty chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = ""; - const char * test_item = "Test_item"; - const char * value = "test_value"; - bool result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = ""; + const char* test_item = "Test_item"; + const char* value = "test_value"; + bool result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_FALSE(result); } -TEST(IniFileTest,ParseEmptyLine) { +TEST(IniFileTest, ParseEmptyLine) { char line[INI_LINE_LEN] = {0}; char val[INI_LINE_LEN] = {0}; - const char * tag = "HMI"; + const char* tag = "HMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_NOTHING, result); } -TEST(IniFileTest,ParseChapter) { - const char * line = "[HMI]"; +TEST(IniFileTest, ParseChapter) { + const char* line = "[HMI]"; char val[INI_LINE_LEN] = {0}; - const char * tag = "HMI"; + const char* tag = "HMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_RIGHT_CHAPTER, result); } -TEST(IniFileTest,ParseChapterTagEmpty) { - const char * line = "[HMI]"; +TEST(IniFileTest, ParseChapterTagEmpty) { + const char* line = "[HMI]"; char val[INI_LINE_LEN] = {0}; char tag[INI_LINE_LEN] = {0}; @@ -235,37 +237,37 @@ TEST(IniFileTest,ParseChapterTagEmpty) { EXPECT_EQ(INI_WRONG_CHAPTER, result); } -TEST(IniFileTest,ParseChapterWithUppercaseTag) { - const char * line = "[Security Manager]"; +TEST(IniFileTest, ParseChapterWithUppercaseTag) { + const char* line = "[Security Manager]"; char val[INI_LINE_LEN] = {0}; - const char * tag = "SECURITY MANAGER"; + const char* tag = "SECURITY MANAGER"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_RIGHT_CHAPTER, result); } -TEST(IniFileTest,ParseChapterWithLowcaseTag) { - const char * line = "[Security Manager]"; +TEST(IniFileTest, ParseChapterWithLowcaseTag) { + const char* line = "[Security Manager]"; char val[INI_LINE_LEN] = {0}; - const char * tag = "Security Manager"; + const char* tag = "Security Manager"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_CHAPTER, result); } -TEST(IniFileTest,ParseWithWrongChapter) { - const char * line = "[HMI]"; +TEST(IniFileTest, ParseWithWrongChapter) { + const char* line = "[HMI]"; char val[INI_LINE_LEN] = {0}; - const char * tag = "MAIN"; + const char* tag = "MAIN"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_CHAPTER, result); } -TEST(IniFileTest,ParseLineWithItem) { +TEST(IniFileTest, ParseLineWithItem) { char line[INI_LINE_LEN] = "LaunchHMI = true"; char val[INI_LINE_LEN] = ""; char tag[INI_LINE_LEN] = "LAUNCHHMI"; @@ -278,21 +280,21 @@ TEST(IniFileTest,ParseLineWithItem) { EXPECT_EQ(*check_val, *val); } -TEST(IniFileTest,ParseLineWithoutItem) { - const char * line = "LaunchHMI = "; +TEST(IniFileTest, ParseLineWithoutItem) { + const char* line = "LaunchHMI = "; char val[INI_LINE_LEN] = {0}; - const char * tag = "LAUNCHHMI"; + const char* tag = "LAUNCHHMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); - const char *res = val; - const char *check_val=""; + const char* res = val; + const char* check_val = ""; EXPECT_EQ(INI_RIGHT_ITEM, result); EXPECT_STREQ(check_val, res); } -TEST(IniFileTest,ParseLineWithEmptytag) { - const char * line = "LaunchHMI = true"; +TEST(IniFileTest, ParseLineWithEmptytag) { + const char* line = "LaunchHMI = true"; char val[INI_LINE_LEN] = {0}; char tag[INI_LINE_LEN] = {0}; @@ -301,24 +303,24 @@ TEST(IniFileTest,ParseLineWithEmptytag) { EXPECT_EQ(INI_WRONG_ITEM, result); } -TEST(IniFileTest,ParseLineWithLowcaseTag) { - const char * line = "LaunchHMI = true"; +TEST(IniFileTest, ParseLineWithLowcaseTag) { + const char* line = "LaunchHMI = true"; char val[INI_LINE_LEN] = {0}; - const char * tag = "LaunchHmi"; + const char* tag = "LaunchHmi"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_ITEM, result); } -TEST(IniFileTest,ParseLineWithComment) { - const char * line = "; [HMI]"; +TEST(IniFileTest, ParseLineWithComment) { + const char* line = "; [HMI]"; char val[INI_LINE_LEN] = {0}; - const char * tag = "HMI"; + const char* tag = "HMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); - const char *res = val; + const char* res = val; EXPECT_EQ(INI_REMARK, result); EXPECT_STREQ(line, res); } |