add some functions to convert input char to dimension and tensor

This commit is contained in:
2024-02-25 00:53:57 +01:00
parent ef107c11db
commit c1409546ef
18 changed files with 688 additions and 128 deletions
+6 -6
View File
@@ -4,7 +4,7 @@
#include "ftest/ftest.h"
#include "tools_t/tools_t.h"
#define INFINITY -8
#define ININITY_REPS -8
#define INITSTATE -1
#define DONOTHING 0
@@ -33,8 +33,8 @@ struct func_mock_info_struct{
int expect_call;/* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */
long call;/* increment when call (try to executed) and 0 if not : init value */
long failed_call;/* increment when condition not fill and 0 if not : init value */
long init_times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
long times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
long init_times_left;/* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */
long times_left;/* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */
struct func_mock_info_struct *next;
};
@@ -65,8 +65,8 @@ extern struct list_base_fmock *g_list_base_fmock;
#if 0
int expect_call; /* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */\
long init_times_left; /* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
long times_left; /* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
long init_times_left; /* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */\
long times_left; /* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */\
#endif
@@ -191,7 +191,7 @@ extern struct list_base_fmock *g_list_base_fmock;
PRINT_HK_C(RED_K,tab_hk_f[hk_TR]," 1 argument check failed from %s \n",__func__); \
}*/\
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'^',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
if (((tmp_mock->info_mock)->times_left <= ININITY_REPS) || ((tmp_mock->info_mock)->times_left > 0)){\
--((tmp_mock->info_mock)->times_left);\
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'v',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
if(1 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
@@ -118,6 +118,16 @@ GENERATE_ALL(TYPE_DOUBLE)
GENERATE_ALL(TYPE_L_DOUBLE)
GENERATE_ALL(TYPE_STRING)
/* strto_type */
int strto_TYPE_INT(char *str, char **endptr);
unsigned int strto_TYPE_U_INT(char *str, char **endptr);
long int strto_TYPE_L_INT(char *str, char **endptr);
unsigned long int strto_TYPE_U_L_INT(char *str, char **endptr);
size_t strto_TYPE_SIZE_T(char *str, char **endptr);
float strto_TYPE_FLOAT(char *str, char **endptr);
double strto_TYPE_DOUBLE(char *str, char **endptr);
long double strto_TYPE_L_DOUBLE(char *str, char **endptr);
/*
* time calucl
Binary file not shown.
+2 -2
View File
@@ -169,7 +169,7 @@ EXPECT_MOCK_CALL(int,f_mock, (),false, 2) {
EXPECT_MOCK_CALL(int,f_mock, (),1, 1) { EXPECT_EQ_IN_MOCKF(23,21,f_mock);return 10;}
EXPECT_MOCK_CALL(int,f_mock, (),1==2||2<1, 1) {return 18;}
EXPECT_MOCK_CALL(int,f_mock, (),1, INFINITY) {return -18;}
EXPECT_MOCK_CALL(int,f_mock, (),1, ININITY_REPS) {return -18;}
TEST(mockf1){
@@ -238,7 +238,7 @@ EXPECT_MOCK_CALL(int, f2_mock, (int a,int b), (a==b), 1){
EXPECT_MOCK_CALL(int, f2_mock, (int a,int b), (1), INFINITY){
EXPECT_MOCK_CALL(int, f2_mock, (int a,int b), (1), ININITY_REPS){
return a*b;
}
+6 -6
View File
@@ -4,7 +4,7 @@
#include "ftest/ftest.h"
#include "tools_t/tools_t.h"
#define INFINITY -8
#define ININITY_REPS -8
#define INITSTATE -1
#define DONOTHING 0
@@ -33,8 +33,8 @@ struct func_mock_info_struct{
int expect_call;/* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */
long call;/* increment when call (try to executed) and 0 if not : init value */
long failed_call;/* increment when condition not fill and 0 if not : init value */
long init_times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
long times_left;/* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */
long init_times_left;/* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */
long times_left;/* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */
struct func_mock_info_struct *next;
};
@@ -65,8 +65,8 @@ extern struct list_base_fmock *g_list_base_fmock;
#if 0
int expect_call; /* 1 if EXPECT_MOCK_CALL and 0 if WILL_MOCK_CALL */\
long init_times_left; /* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
long times_left; /* DONOTHING do nothing (pass to -> next), INFINITY every time; INITSTATE init; > 0 execute and decrement */\
long init_times_left; /* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */\
long times_left; /* DONOTHING do nothing (pass to -> next), ININITY_REPS every time; INITSTATE init; > 0 execute and decrement */\
#endif
@@ -191,7 +191,7 @@ extern struct list_base_fmock *g_list_base_fmock;
PRINT_HK_C(RED_K,tab_hk_f[hk_TR]," 1 argument check failed from %s \n",__func__); \
}*/\
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'^',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
if (((tmp_mock->info_mock)->times_left <= INFINITY) || ((tmp_mock->info_mock)->times_left > 0)){\
if (((tmp_mock->info_mock)->times_left <= ININITY_REPS) || ((tmp_mock->info_mock)->times_left > 0)){\
--((tmp_mock->info_mock)->times_left);\
PRINT_DEBUG(" %*c VALUES: mock function:%s, conditions:%s t_left:%ld, init_left:%ld| args:%s\n",8,'v',(tmp_mock->info_mock)->str_namefunc, (tmp_mock->info_mock)->str_conditions, (tmp_mock->info_mock)->times_left,(tmp_mock->info_mock)->init_times_left, #args_call_with_parenthesis);\
if(1 == tmp_mock->call_mock_condition args_call_with_parenthesis){\
+1 -1
View File
@@ -204,7 +204,7 @@ char * number_call_translate(long nb){
if(nb>1) sprintf(ret," be called %ld times",nb);
else if(nb == 1) sprintf(ret," be called once");
else if(nb == 0 ) sprintf(ret," not to be executed");
else if(nb==INFINITY) sprintf(ret," be called forever");
else if(nb==ININITY_REPS) sprintf(ret," be called forever");
else if(nb==INITSTATE) sprintf(ret," not expected");
else sprintf(ret," nothing! it's negative:%ld", nb);