-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
4,115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
add_executable(cutest_test | ||
tools/__init__.c | ||
tools/help.c | ||
utils/file.c | ||
utils/regex.c | ||
utils/str.c | ||
main.c | ||
test.c | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "__init__.h" | ||
|
||
static int _string_finder(int argc, char* argv[]) | ||
{ | ||
|
||
} | ||
|
||
const test_tool_t test_tool_stringfinder = { | ||
"stringfinder", _string_finder, | ||
"Find string in file.\n" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "file.h" | ||
|
||
#if !defined(_WIN32) | ||
static int fopen_s(FILE** out, const char* path, const char* mode) | ||
{ | ||
if ((*out = fopen(path, mode)) == NULL) | ||
{ | ||
return errno; | ||
} | ||
return 0; | ||
} | ||
#endif | ||
|
||
int test_file_read(const char* path, test_str_t* data) | ||
{ | ||
FILE* f = NULL; | ||
char buf[64]; | ||
|
||
int ret = fopen_s(&f, path, "rb"); | ||
if (ret != 0) | ||
{ | ||
return -ret; | ||
} | ||
|
||
while (!feof(f)) | ||
{ | ||
if (ferror(f)) | ||
{ | ||
return -1; | ||
} | ||
|
||
size_t nread = fread(buf, 1, sizeof(buf), f); | ||
test_str_append(data, buf, nread); | ||
} | ||
|
||
fclose(f); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef __CUTEST_TEST_UTILS_FILE_H__ | ||
#define __CUTEST_TEST_UTILS_FILE_H__ | ||
|
||
#include "str.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Read file content. | ||
* @param[in] path - File path. | ||
* @param[out] data - Buffer to store file content. | ||
* @return - 0: success | ||
* @return - -errno: on error | ||
*/ | ||
int test_file_read(const char* path, test_str_t* data); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
Oops, something went wrong.