Skip to content

Commit 8a5f02d

Browse files
committed
add poly_type main c
1 parent 1830456 commit 8a5f02d

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

src/poly_type/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
set_directory_properties(PROPERTIES LABELS poly_type)
22

3-
add_executable(cpp_poly_type main.cpp lib.f90)
3+
add_library(poly_type_lib OBJECT lib.f90)
4+
5+
add_executable(c_poly_type main.c)
6+
target_link_libraries(c_poly_type PRIVATE poly_type_lib)
7+
add_test(NAME C_Fortran_poly_type COMMAND c_poly_type)
8+
9+
add_executable(cpp_poly_type main.cpp)
10+
target_link_libraries(cpp_poly_type PRIVATE poly_type_lib)
411
add_test(NAME C++_Fortran_poly_type COMMAND cpp_poly_type)
512

613
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)

src/poly_type/main.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <stdio.h>
2+
3+
extern void init_type(int*, void**);
4+
extern void add_one_C(int*, void**, int*, int*);
5+
6+
7+
int main(){
8+
9+
void* x3;
10+
void* x4;
11+
int xtype=3;
12+
int A, C;
13+
14+
xtype = 3;
15+
init_type(&xtype, &x3);
16+
17+
add_one_C(&xtype, &x3, &A, &C);
18+
if(A != 4) {
19+
fprintf(stderr, "Error: %d != 4\n", A);
20+
return 1;
21+
}
22+
printf("C:3 = %d\n", C);
23+
add_one_C(&xtype, &x3, &A, &C);
24+
printf("C:3 = %d\n", C);
25+
add_one_C(&xtype, &x3, &A, &C);
26+
printf("C:3 = %d\n", C);
27+
28+
xtype = 4;
29+
init_type(&xtype, &x4);
30+
31+
add_one_C(&xtype, &x4, &A, &C);
32+
if(A != 5) {
33+
fprintf(stderr, "Error: %d != 5\n", A);
34+
return 1;
35+
}
36+
printf("C:4 = %d\n", C);
37+
add_one_C(&xtype, &x4, &A, &C);
38+
printf("C:4 = %d\n", C);
39+
add_one_C(&xtype, &x4, &A, &C);
40+
printf("C:4 = %d\n", C);
41+
42+
printf("OK: poly_type\n");
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)