Browse Source

lib_test - funcs add type postfix i,l,f,d,c (int,long, float, double,char)

master
heck 4 years ago
parent
commit
5034cf06ed
  1. 10
      examples/ext/lib_test/lib_test/gen/config.json
  2. 20
      examples/ext/lib_test/tests/test_lib_test.py
  3. 10
      examples/lib/lib_test/functions.h
  4. 10
      examples/lib/lib_test/lib_test.c
  5. 22
      examples/lib/lib_test/main.c

10
examples/ext/lib_test/lib_test/gen/config.json

@ -6,11 +6,11 @@
], ],
"functions": [ "functions": [
"func_V_args_V", "func_V_args_V",
"func_P_args_V", "func_Pi_args_V",
"func_V_args_P", "func_V_args_Pi",
"func_P_args_P", "func_Pi_args_Pi",
"func_V_args_pP", "func_V_args_pPi",
"func_P_args_P_pP_pP" "func_Pi_args_Pi_pPi_pPi"
], ],
"debug_ast" : "True", "debug_ast" : "True",
"debug_acid" : "True", "debug_acid" : "True",

20
examples/ext/lib_test/tests/test_lib_test.py

@ -10,32 +10,32 @@ def test_func_V_args_V():
(ret,) = func_V_args_V() (ret,) = func_V_args_V()
assert(ret == None) assert(ret == None)
def test_func_P_args_V(): def test_func_Pi_args_V():
(ret,) = func_P_args_V() (ret,) = func_Pi_args_V()
print("RESULT:", ret) print("RESULT:", ret)
assert (ret == 23) assert (ret == 23)
def test_func_V_args_P(): def test_func_V_args_Pi():
(ret,arg1) = func_V_args_P(23) (ret,arg1) = func_V_args_Pi(23)
print("RESULT:", ret, arg1) print("RESULT:", ret, arg1)
assert(ret == None) assert(ret == None)
assert(arg1 == 23) assert(arg1 == 23)
def test_func_P_args_P(): def test_func_Pi_args_Pi():
(ret,arg1) = func_P_args_P(22) (ret,arg1) = func_Pi_args_Pi(22)
print("RESULT:", ret, arg1) print("RESULT:", ret, arg1)
assert (ret == 23) assert (ret == 23)
assert (arg1 == 22) assert (arg1 == 22)
# @pytest.mark.skip("") # @pytest.mark.skip("")
def test_func_V_args_pP(): def test_func_V_args_pPi():
(ret,arg1) = func_V_args_pP(22) (ret,arg1) = func_V_args_pPi(22)
print("RESULT:", ret, arg1) print("RESULT:", ret, arg1)
assert (ret == None) assert (ret == None)
assert (arg1 == 23) assert (arg1 == 23)
def test_func_P_args_P_pP_pP(): def test_func_Pi_args_Pi_pPi_pPi():
(ret, arg1, arg2, arg3) = func_P_args_P_pP_pP(23, 22, 22) (ret, arg1, arg2, arg3) = func_Pi_args_Pi_pPi_pPi(23, 22, 22)
print("RESULT:", ret, arg1, arg2, arg3) print("RESULT:", ret, arg1, arg2, arg3)
assert (ret == 23) assert (ret == 23)
assert (arg1 == 23) assert (arg1 == 23)

10
examples/lib/lib_test/functions.h

@ -12,15 +12,15 @@ extern "C" {
void func_V_args_V(); void func_V_args_V();
int func_P_args_V(); int func_Pi_args_V();
void func_V_args_P(int arg1_P); void func_V_args_Pi(int arg1_P);
int func_P_args_P(int arg1_P); int func_Pi_args_Pi(int arg1_P);
void func_V_args_pP(unsigned int* const arg1_pP); void func_V_args_pPi(unsigned int* const arg1_pP);
int func_P_args_P_pP_pP(int arg1_P, int* arg2_pP, int* arg3_pP); int func_Pi_args_Pi_pPi_pPi(int arg1_P,unsigned int* const arg2_pP, int* arg3_pP);

10
examples/lib/lib_test/lib_test.c

@ -8,24 +8,24 @@ void func_V_args_V() {
} }
int func_P_args_V() { int func_Pi_args_V() {
return 23; return 23;
} }
void func_V_args_P(int arg1_P) { void func_V_args_Pi(int arg1_P) {
printf("%i", arg1_P); printf("%i", arg1_P);
} }
int func_P_args_P(int arg1_P) { int func_Pi_args_Pi(int arg1_P) {
printf("%i", arg1_P); printf("%i", arg1_P);
return ++arg1_P; return ++arg1_P;
} }
void func_V_args_pP(unsigned int* const arg1_pP) { void func_V_args_pPi(unsigned int* const arg1_pP) {
++(*arg1_pP); ++(*arg1_pP);
} }
int func_P_args_P_pP_pP(int arg1_P, int* arg2_pP, int* arg3_pP) { int func_Pi_args_Pi_pPi_pPi(int arg1_P,unsigned int* const arg2_pP, int* arg3_pP) {
++(*arg2_pP); ++(*arg2_pP);
++(*arg3_pP); ++(*arg3_pP);
return *arg2_pP; return *arg2_pP;

22
examples/lib/lib_test/main.c

@ -11,31 +11,31 @@ int main() {
func_V_args_V(); func_V_args_V();
} }
{ {
printf("testing: func_P_args_V\n"); printf("testing: func_Pi_args_V\n");
int ret = func_P_args_V(); int ret = func_Pi_args_V();
assert(ret == 23); assert(ret == 23);
} }
{ {
printf("testing: func_V_args_P\n"); printf("testing: func_V_args_Pi\n");
func_V_args_P(23); func_V_args_Pi(23);
} }
{ {
printf("testing: func_P_args_P\n"); printf("testing: func_Pi_args_Pi\n");
int ret = func_P_args_P(22); int ret = func_Pi_args_Pi(22);
assert(ret == 23); assert(ret == 23);
} }
{ {
printf("testing: func_V_args_pP\n"); printf("testing: func_V_args_pPi\n");
unsigned int i = 22; unsigned int i = 22;
func_V_args_pP(&i); func_V_args_pPi(&i);
assert(i == 23); assert(i == 23);
} }
{ {
printf("testing: func_P_args_P_pP_pP\n"); printf("testing: func_Pi_args_Pi_pPi_pPi\n");
int i = 23; int i = 23;
int j = 22; unsigned int j = 22;
int k = 22; int k = 22;
int ret = func_P_args_P_pP_pP(i,&j,&k); int ret = func_Pi_args_Pi_pPi_pPi(i,&j,&k);
assert(ret == 23); assert(ret == 23);
assert(i == 23); assert(i == 23);
assert(j == 23); assert(j == 23);

Loading…
Cancel
Save