Browse Source

lib_test - add functions and corresponding tests in c to be mirrored in python

master
heck 4 years ago
parent
commit
f493180cb4
  1. 4
      examples/lib/lib_test/Makefile
  2. 4
      examples/lib/lib_test/README.md
  3. 24
      examples/lib/lib_test/functions.h
  4. 37
      examples/lib/lib_test/lib_test.c
  5. 41
      examples/lib/lib_test/main.c

4
examples/lib/lib_test/Makefile

@ -3,8 +3,8 @@ TARGET_CXX=lib_test_cxx
LIB_STATIC=liblib_test.a LIB_STATIC=liblib_test.a
LIB_DYN=liblib_test.so LIB_DYN=liblib_test.so
CFLAGS+=-std=c99 -g CFLAGS+=-std=c99 -g -UNDEBUG
CXXFLAGS+=-std=c++11 -g CXXFLAGS+=-std=c++11 -g -UNDEBUG
SRCS+=$(wildcard *.c) SRCS+=$(wildcard *.c)
OBJS_C+=$(SRCS:.c=.o99) OBJS_C+=$(SRCS:.c=.o99)

4
examples/lib/lib_test/README.md

@ -61,8 +61,8 @@ X = Anonymous (enums onnly) -> enums.h
a = Array (vars (all possible types) and struct fields) a = Array (vars (all possible types) and struct fields)
(//p = Pointer (vars (all possible types) and struct fields)) (//p = Pointer (vars (all possible types) and struct fields))
func_ = Function -> functions.h func_<RETURN>_args_<ARG1_ARG2_...> = Function -> functions.h -> functions.h
var_ = Variable -> vars.h var_ = Variable -> vars.h
prefixed underline (e.g _E) means no typedef/alias exists for this item (enum in this case) prefixed underline (e.g _E) means no typedef/alias exists for this item (enum in this case)

24
examples/lib/lib_test/functions.h

@ -10,32 +10,20 @@
extern "C" { extern "C" {
#endif #endif
void func_void_void(); void func_V_args_V();
int func_int_void(); int func_P_args_V();
void func_void_int(int); void func_V_args_P(int arg1_P);
int func_int_int(int); int func_P_args_P(int arg1_P);
// struct void func_V_args_pP(unsigned int* const arg1_pP);
struct _PS func__PS_V();
// enum int func_P_args_P_pP_pP(int arg1_P, int* arg2_pP, int* arg3_pP);
enum _E func__E_V();
// typedef
T_P func_TP_V();
void func_V_TP(T_P);
T_P func_TP_TP(T_P);
APS func_APS_V();
void func_V_APS(APS);
APS func_APS_APS(APS);
TPS func_TPS_V();
void func_V_TPS(TPS);
TPS func_TPS_TPS(TPS);
#ifdef __cplusplus #ifdef __cplusplus
} }

37
examples/lib/lib_test/lib_test.c

@ -1,5 +1,37 @@
#include "lib_test.h" #include "lib_test.h"
#include<stdio.h>
// FUNCTIONS
void func_V_args_V() {
}
int func_P_args_V() {
return 23;
}
void func_V_args_P(int arg1_P) {
printf("%i", arg1_P);
}
int func_P_args_P(int arg1_P) {
printf("%i", arg1_P);
return ++arg1_P;
}
void func_V_args_pP(unsigned int* const arg1_pP) {
++(*arg1_pP);
}
int func_P_args_P_pP_pP(int arg1_P, int* arg2_pP, int* arg3_pP) {
++(*arg2_pP);
++(*arg3_pP);
return *arg2_pP;
}
// Variables // Variables
// ========= // =========
// _V = Void // _V = Void
@ -551,9 +583,4 @@ extern TaTAXE var_aTaTAXE[3];
// FUNCTIONS
//struct _PS func__PS_V() {
// return var__PS;
//}

41
examples/lib/lib_test/main.c

@ -1,13 +1,44 @@
#include "lib_test.h" #include "lib_test.h"
#include <stdio.h> #include <stdio.h>
#include <assert.h>
int main() { int main() {
printf("lib_test starting...\n"); printf("lib_test starting...\n");
{
TT_HHS a; printf("testing: func_V_args_V\n");
func_V_args_V();
TT_CCS b; }
// printf("%i, %i\n", a.x, a.y); {
printf("testing: func_P_args_V\n");
int ret = func_P_args_V();
assert(ret == 23);
}
{
printf("testing: func_V_args_P\n");
func_V_args_P(23);
}
{
printf("testing: func_P_args_P\n");
int ret = func_P_args_P(22);
assert(ret == 23);
}
{
printf("testing: func_V_args_pP\n");
unsigned int i = 22;
func_V_args_pP(&i);
assert(i == 23);
}
{
printf("testing: func_P_args_P_pP_pP\n");
int i = 23;
int j = 22;
int k = 22;
int ret = func_P_args_P_pP_pP(i,&j,&k);
assert(ret == 23);
assert(i == 23);
assert(j == 23);
assert(k == 23);
}
} }

Loading…
Cancel
Save