import RT-Thread@9217865c without bsp, libcpu and components/net
This commit is contained in:
commit
e2376a3709
1414 changed files with 390370 additions and 0 deletions
|
@ -0,0 +1,31 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int clearerr_entry(void)
|
||||
{
|
||||
putc( 'c', stdin );
|
||||
if( ferror( stdin ) )
|
||||
{
|
||||
perror( "Write error" );
|
||||
clearerr( stdin );
|
||||
}
|
||||
|
||||
if( ferror( stdin ))
|
||||
{
|
||||
perror( "clearerr error" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_clearerr(void)
|
||||
{
|
||||
uassert_int_equal(clearerr_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_clearerr);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.clearerr.c", RT_NULL, RT_NULL, 10);
|
||||
|
34
examples/utest/testcases/posix/stdio_h/functions/fclose_tc.c
Normal file
34
examples/utest/testcases/posix/stdio_h/functions/fclose_tc.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int fclose_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
stream = fopen("fopen_file.txt","a+");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
return -1;
|
||||
}
|
||||
if(fclose(stream) != 0)
|
||||
{
|
||||
perror("fclose fail");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("fclose success \n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fclose(void)
|
||||
{
|
||||
uassert_int_equal(fclose_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fclose);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fclose.c", RT_NULL, RT_NULL, 10);
|
||||
|
39
examples/utest/testcases/posix/stdio_h/functions/fdopen_tc.c
Normal file
39
examples/utest/testcases/posix/stdio_h/functions/fdopen_tc.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static int fdopen_entry(void)
|
||||
{
|
||||
int fd;
|
||||
FILE *stream;
|
||||
|
||||
fd = open("fdopen_file.txt", O_CREAT | O_RDWR | O_APPEND);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("open fail.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO */
|
||||
stream = fdopen(fd, "w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
printf("fdopen fail.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fdopen(void)
|
||||
{
|
||||
uassert_int_equal(fdopen_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fdopen);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fdopen_tc.c", RT_NULL, RT_NULL, 10);
|
||||
|
55
examples/utest/testcases/posix/stdio_h/functions/feof_tc.c
Normal file
55
examples/utest/testcases/posix/stdio_h/functions/feof_tc.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int feof_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char data[] = "test fgetc";
|
||||
char getc[sizeof(data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
int i=0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w+");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
fwrite(data, sizeof(data), 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
while(1)
|
||||
{
|
||||
getc[i] = fgetc(stream);
|
||||
i++;
|
||||
if( feof(stream) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(getc, data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
__exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_feof(void)
|
||||
{
|
||||
uassert_int_equal(feof_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_feof);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.feof.c", RT_NULL, RT_NULL, 10);
|
||||
|
28
examples/utest/testcases/posix/stdio_h/functions/ferror_tc.c
Normal file
28
examples/utest/testcases/posix/stdio_h/functions/ferror_tc.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int ferror_entry(void)
|
||||
{
|
||||
int c;
|
||||
putc( 'c', stdin );
|
||||
if( ferror( stdin ) )
|
||||
{
|
||||
clearerr( stdin );
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_ferror(void)
|
||||
{
|
||||
uassert_int_equal(ferror_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_ferror);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.ferror.c", RT_NULL, RT_NULL, 10);
|
||||
|
29
examples/utest/testcases/posix/stdio_h/functions/fflush_tc.c
Normal file
29
examples/utest/testcases/posix/stdio_h/functions/fflush_tc.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int fflush_entry(void)
|
||||
{
|
||||
fflush(stdout);
|
||||
printf("test fflush\n");
|
||||
|
||||
printf("t");
|
||||
printf("e");
|
||||
printf("s");
|
||||
printf("t");
|
||||
fflush(stdout);
|
||||
printf(" fflush");
|
||||
fflush(stdout);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fflush(void)
|
||||
{
|
||||
uassert_int_equal(fflush_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fflush);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fflush.c", RT_NULL, RT_NULL, 10);
|
||||
|
54
examples/utest/testcases/posix/stdio_h/functions/fgetc_tc.c
Normal file
54
examples/utest/testcases/posix/stdio_h/functions/fgetc_tc.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fgetc_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char data[] = "test fgetc";
|
||||
char getc[sizeof(data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
int i=0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w+");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
fwrite(data, sizeof(data), 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
while(1)
|
||||
{
|
||||
getc[i] = fgetc(stream);
|
||||
i++;
|
||||
if( feof(stream) )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(getc, data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
fclose(stream);
|
||||
__exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fgetc(void)
|
||||
{
|
||||
uassert_int_equal(fgetc_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fgetc);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fgetc.c", RT_NULL, RT_NULL, 10);
|
||||
|
50
examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c
Normal file
50
examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int fgets_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char data[] = "test fgets";
|
||||
char gets[sizeof(data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fwrite(data, sizeof(data), 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fgets(gets, sizeof(gets), stream);
|
||||
|
||||
if(strcmp(gets, data))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
fclose(stream);
|
||||
|
||||
__exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fgets(void)
|
||||
{
|
||||
uassert_int_equal(fgets_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fgets);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fgets.c", RT_NULL, RT_NULL, 10);
|
||||
|
26
examples/utest/testcases/posix/stdio_h/functions/fileno_tc.c
Normal file
26
examples/utest/testcases/posix/stdio_h/functions/fileno_tc.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int fdopen_entry(void)
|
||||
{
|
||||
int stdin_no = fileno(stdin);
|
||||
int stdout_no = fileno(stdout);
|
||||
int stderr_no = fileno(stderr);
|
||||
|
||||
if((stdin_no == 0) && (stdout_no == 1) && (stderr_no == 2))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fdopen(void)
|
||||
{
|
||||
uassert_int_equal(fdopen_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fdopen);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fileno.c", RT_NULL, RT_NULL, 10);
|
||||
|
28
examples/utest/testcases/posix/stdio_h/functions/fopen_tc.c
Normal file
28
examples/utest/testcases/posix/stdio_h/functions/fopen_tc.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int fopen_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
/* TODO: other mode fopen */
|
||||
stream = fopen("fopen_file.txt","a+");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fopen(void)
|
||||
{
|
||||
uassert_int_equal(fopen_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fopen);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fopen.c", RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fdopen_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char test_data[] = "1a2bxx";
|
||||
char gets[sizeof(test_data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fprintf(stream, "%d%c%d%c%s",1,'a',2,'b',"xx");
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
fgets(gets, sizeof(gets), stream);
|
||||
|
||||
if(strcmp(test_data, gets))
|
||||
{
|
||||
printf("%s\n",gets);
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fdopen(void)
|
||||
{
|
||||
uassert_int_equal(fdopen_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fdopen);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fprintf.c", RT_NULL, RT_NULL, 10);
|
||||
|
44
examples/utest/testcases/posix/stdio_h/functions/fputc_tc.c
Normal file
44
examples/utest/testcases/posix/stdio_h/functions/fputc_tc.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int fputc_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
int ch = 'a';
|
||||
int getc = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fputc(ch, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
getc = fgetc(stream);
|
||||
|
||||
if(getc != ch)
|
||||
{
|
||||
perror("fputc");
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fputc(void)
|
||||
{
|
||||
uassert_int_equal(fputc_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fputc);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
45
examples/utest/testcases/posix/stdio_h/functions/fputs_tc.c
Normal file
45
examples/utest/testcases/posix/stdio_h/functions/fputs_tc.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fputs_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char test_data[] = "1a2bxx";
|
||||
char gets[sizeof(test_data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fputs(test_data, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
fgets(gets, sizeof(gets), stream);
|
||||
|
||||
if(strcmp(test_data, gets))
|
||||
{
|
||||
printf("%s\n",gets);
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fputs(void)
|
||||
{
|
||||
uassert_int_equal(fputs_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fputs);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
44
examples/utest/testcases/posix/stdio_h/functions/fread_tc.c
Normal file
44
examples/utest/testcases/posix/stdio_h/functions/fread_tc.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static int fread_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char data[] = "test fread";
|
||||
char gets[sizeof(data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fwrite(data, sizeof(data), 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
fread(gets, sizeof(gets), 1, stream);
|
||||
if(strcmp(gets, data))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fread(void)
|
||||
{
|
||||
uassert_int_equal(fread_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fread);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
44
examples/utest/testcases/posix/stdio_h/functions/fscanf_tc.c
Normal file
44
examples/utest/testcases/posix/stdio_h/functions/fscanf_tc.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fscanf_entry(void)
|
||||
{
|
||||
long l;
|
||||
char s[81] = {0};
|
||||
char c;
|
||||
int ret = 0;
|
||||
FILE* stream = fopen("fopen_file.txt","w+");
|
||||
if(stream == NULL)
|
||||
{
|
||||
ret = -1;
|
||||
perror("fopen");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream,"%s %d %c","a_string",6500,'x');
|
||||
fseek(stream,0L,SEEK_SET);
|
||||
fscanf(stream,"%s",s);
|
||||
fscanf(stream,"%ld",&l);
|
||||
fscanf(stream," %c",&c);
|
||||
|
||||
if((strcmp(s,"a_string") != 0) || (l != 6500) || (c != 'x'))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fscanf(void)
|
||||
{
|
||||
uassert_int_equal(fscanf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fscanf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fscanf.c", RT_NULL, RT_NULL, 10);
|
||||
|
44
examples/utest/testcases/posix/stdio_h/functions/fseek_tc.c
Normal file
44
examples/utest/testcases/posix/stdio_h/functions/fseek_tc.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fdopen_entry(void)
|
||||
{
|
||||
long l;
|
||||
char s[81] = {0};
|
||||
char c;
|
||||
int ret = 0;
|
||||
FILE* stream = fopen("fopen_file.txt","w+");
|
||||
if(stream == NULL)
|
||||
{
|
||||
ret = -1;
|
||||
perror("fopen");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream,"%s %d %c","a_string",6500,'x');
|
||||
fseek(stream,0L,SEEK_SET);
|
||||
fscanf(stream,"%s",s);
|
||||
fscanf(stream,"%ld",&l);
|
||||
fscanf(stream," %c",&c);
|
||||
|
||||
if((strcmp(s,"a_string") != 0) || (l != 6500) || (c != 'x'))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fdopen(void)
|
||||
{
|
||||
uassert_int_equal(fdopen_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fdopen);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
38
examples/utest/testcases/posix/stdio_h/functions/ftell_tc.c
Normal file
38
examples/utest/testcases/posix/stdio_h/functions/ftell_tc.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int ftell_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char str[] = "123456789";
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen");
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, "%s",str);
|
||||
if(ftell(stream) != strlen(str))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
fclose(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_ftell(void)
|
||||
{
|
||||
uassert_int_equal(ftell_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_ftell);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
45
examples/utest/testcases/posix/stdio_h/functions/fwrite_tc.c
Normal file
45
examples/utest/testcases/posix/stdio_h/functions/fwrite_tc.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int fwrite_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char test_data[] = "1a2bxx";
|
||||
char gets[sizeof(test_data)] = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
fwrite(test_data, sizeof(test_data), 1,stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
fgets(gets, sizeof(gets), stream);
|
||||
|
||||
if(strcmp(test_data, gets))
|
||||
{
|
||||
printf("%s\n",gets);
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_fwrite(void)
|
||||
{
|
||||
uassert_int_equal(fwrite_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_fwrite);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
27
examples/utest/testcases/posix/stdio_h/functions/perror_tc.c
Normal file
27
examples/utest/testcases/posix/stdio_h/functions/perror_tc.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int perror_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
stream = fopen( "nulltest.txt", "r" );
|
||||
if(stream == NULL)
|
||||
{
|
||||
printf("perror test:");
|
||||
perror("nulltest.txt");
|
||||
return -1;
|
||||
}
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_perror(void)
|
||||
{
|
||||
uassert_int_equal(perror_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_perror);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
19
examples/utest/testcases/posix/stdio_h/functions/printf_tc.c
Normal file
19
examples/utest/testcases/posix/stdio_h/functions/printf_tc.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int printf_entry(void)
|
||||
{
|
||||
printf("printf test:%s-%d-%c %f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_printf(void)
|
||||
{
|
||||
uassert_int_equal(printf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_printf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
44
examples/utest/testcases/posix/stdio_h/functions/putc_tc.c
Normal file
44
examples/utest/testcases/posix/stdio_h/functions/putc_tc.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int putc_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
int ch = 'a';
|
||||
int getc = {0};
|
||||
size_t size = 0;
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
putc(ch, stream);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
getc = fgetc(stream);
|
||||
|
||||
if(getc != ch)
|
||||
{
|
||||
printf("fputc test:getc %c",getc);
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_putc(void)
|
||||
{
|
||||
uassert_int_equal(putc_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_putc);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int putchar_entry(void)
|
||||
{
|
||||
char data[] = "putchar testcase\n";
|
||||
int i = 0;
|
||||
for(;i < sizeof(data);i++)
|
||||
{
|
||||
putchar(data[i]);
|
||||
}
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_putchar(void)
|
||||
{
|
||||
uassert_int_equal(putchar_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_putchar);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
22
examples/utest/testcases/posix/stdio_h/functions/puts_tc.c
Normal file
22
examples/utest/testcases/posix/stdio_h/functions/puts_tc.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int puts_entry(void)
|
||||
{
|
||||
char data[] = "puts testcase\n";
|
||||
printf("puts testcase:");
|
||||
puts(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_puts(void)
|
||||
{
|
||||
uassert_int_equal(puts_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_puts);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.puts.c", RT_NULL, RT_NULL, 10);
|
||||
|
35
examples/utest/testcases/posix/stdio_h/functions/remove_tc.c
Normal file
35
examples/utest/testcases/posix/stdio_h/functions/remove_tc.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int remove_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if(stream)
|
||||
{
|
||||
fclose(stream);
|
||||
remove("fopen_file.txt");
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
if(stream)
|
||||
{
|
||||
fclose(stream);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_remove(void)
|
||||
{
|
||||
uassert_int_equal(remove_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_remove);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
37
examples/utest/testcases/posix/stdio_h/functions/rename_tc.c
Normal file
37
examples/utest/testcases/posix/stdio_h/functions/rename_tc.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static int rename_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
if(stream == NULL)
|
||||
{
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if(stream == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
fclose(stream);
|
||||
|
||||
rename("fopen_file.txt", "rename_test.txt");
|
||||
stream = fopen("rename_test.txt","r");
|
||||
if(stream == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
fclose(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_rename(void)
|
||||
{
|
||||
uassert_int_equal(rename_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_rename);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.rename.c", RT_NULL, RT_NULL, 10);
|
||||
|
44
examples/utest/testcases/posix/stdio_h/functions/rewind_tc.c
Normal file
44
examples/utest/testcases/posix/stdio_h/functions/rewind_tc.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int rewind_entry(void)
|
||||
{
|
||||
long l;
|
||||
char s[81] = {0};
|
||||
char c;
|
||||
int ret = 0;
|
||||
FILE* stream = fopen("fopen_file.txt","w+");
|
||||
if(stream == NULL)
|
||||
{
|
||||
ret = -1;
|
||||
perror("fopen");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream,"%s %d %c","a_string",6500,'x');
|
||||
rewind(stream);
|
||||
fscanf(stream,"%s",s);
|
||||
fscanf(stream,"%ld",&l);
|
||||
fscanf(stream," %c",&c);
|
||||
|
||||
if((strcmp(s,"a_string") != 0) || (l != 6500) || (c != 'x'))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_rewind(void)
|
||||
{
|
||||
uassert_int_equal(rewind_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_rewind);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.rewind.c", RT_NULL, RT_NULL, 10);
|
||||
|
41
examples/utest/testcases/posix/stdio_h/functions/setbuf_tc.c
Normal file
41
examples/utest/testcases/posix/stdio_h/functions/setbuf_tc.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static char outbuf[BUFSIZ];
|
||||
static int setbuf_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char test_data[] = "test setbuf";
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
setbuf(stream, outbuf);
|
||||
fwrite(test_data, sizeof(test_data), 1,stream);
|
||||
|
||||
if(strcmp(test_data, outbuf))
|
||||
{
|
||||
printf("setbuf test:%s\n",test_data);
|
||||
ret = -1;
|
||||
}
|
||||
fclose(stream);
|
||||
__exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_setbuf(void)
|
||||
{
|
||||
uassert_int_equal(setbuf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_setbuf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.setbuf.c", RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static char outbuf[BUFSIZ];
|
||||
static int setvbuf_entry(void)
|
||||
{
|
||||
FILE *stream;
|
||||
char test_data[] = "test setbuf";
|
||||
int ret = 0;
|
||||
|
||||
stream = fopen("fopen_file.txt","w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
perror("fopen fail");
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
setvbuf(stream, outbuf, _IOLBF, BUFSIZ);
|
||||
fwrite(test_data, sizeof(test_data), 1,stream);
|
||||
|
||||
if(strcmp(test_data, outbuf))
|
||||
{
|
||||
printf("setvbuf test:%s\n",test_data);
|
||||
ret = -1;
|
||||
}
|
||||
__exit:
|
||||
fclose(stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_setvbuf(void)
|
||||
{
|
||||
uassert_int_equal(setvbuf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_setvbuf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.setvbuf.c", RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int snprintf_entry(void)
|
||||
{
|
||||
char buf[64] = {0};
|
||||
char test_data[] = "snprintf test:2021-8-";
|
||||
snprintf(buf, 22,"snprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
|
||||
if(strcmp(buf, test_data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_snprintf(void)
|
||||
{
|
||||
uassert_int_equal(snprintf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_snprintf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.snprintf.c", RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int sprintf_entry(void)
|
||||
{
|
||||
char buf[64] = {0};
|
||||
char test_data[] = "sprintf test:2021-8-1 3.14 0xff";
|
||||
sprintf(buf, "sprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
|
||||
if(strcmp(buf, test_data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_sprintf(void)
|
||||
{
|
||||
uassert_int_equal(sprintf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_sprintf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.sprintf.c", RT_NULL, RT_NULL, 10);
|
||||
|
30
examples/utest/testcases/posix/stdio_h/functions/sscanf_tc.c
Normal file
30
examples/utest/testcases/posix/stdio_h/functions/sscanf_tc.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int sscanf_entry(void)
|
||||
{
|
||||
int day, year;
|
||||
char weekday[20], month[20], dtm[100];
|
||||
|
||||
strcpy( dtm, "Friday January 1 2021" );
|
||||
sscanf( dtm, "%s %s %d %d", weekday, month, &day, &year );
|
||||
|
||||
if(strcmp(month,"January") || strcmp(weekday,"Friday")
|
||||
|| (year != 2021) ||(day != 1))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_sscanf(void)
|
||||
{
|
||||
uassert_int_equal(sscanf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_sscanf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.sscanf.c", RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
static void WriteFrmtd(FILE *stream ,char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vfprintf(stream, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static int vfprintf_entry(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char buf[64] = {0};
|
||||
char test_data[] = "vfprintf test:2021-8-1 3.14 0xff";
|
||||
FILE *stream = fopen("fopen_file.txt", "w");
|
||||
if(stream)
|
||||
{
|
||||
WriteFrmtd(stream, "vfprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
fclose(stream);
|
||||
|
||||
stream = fopen("fopen_file.txt","r");
|
||||
fread(buf, 1, sizeof(test_data), stream);
|
||||
if(strcmp(buf, test_data))
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
fclose(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_vfprintf(void)
|
||||
{
|
||||
uassert_int_equal(vfprintf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_vfprintf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
static void WriteFrmtd(char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static int vprintf_entry(void)
|
||||
{
|
||||
WriteFrmtd("vprintf test:%s-%d-%c %.02f 0x%x\n","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_vprintf(void)
|
||||
{
|
||||
uassert_int_equal(vprintf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_vprintf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "posix.stdio_h.vprintf.c", RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
static char buf[64] = {0};
|
||||
static void WriteFrmtd(char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsnprintf(buf, 22, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static int vsnprintf_entry(void)
|
||||
{
|
||||
char buf[64] = {0};
|
||||
char test_data[] = "vsnprintf test:2021-8";
|
||||
snprintf(buf, 22,"vsnprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
|
||||
if(strcmp(buf, test_data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_vsnprintf(void)
|
||||
{
|
||||
uassert_int_equal(vsnprintf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_vsnprintf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
static char buf[64] = {0};
|
||||
static void WriteFrmtd(char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsprintf(buf, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static int vsprintf_entry(void)
|
||||
{
|
||||
char buf[64] = {0};
|
||||
char test_data[] = "vsprintf test:2021-8-1 3.14 0xff";
|
||||
sprintf(buf, "vsprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
|
||||
|
||||
if(strcmp(buf, test_data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <utest.h>
|
||||
static void test_vsprintf(void)
|
||||
{
|
||||
uassert_int_equal(vsprintf_entry(), 0);
|
||||
}
|
||||
static void testcase(void)
|
||||
{
|
||||
UTEST_UNIT_RUN(test_vsprintf);
|
||||
}
|
||||
UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue