Skip to content

Commit

Permalink
Merge pull request #79 from czgdp1807/structs_02
Browse files Browse the repository at this point in the history
Test including user defined header files
  • Loading branch information
czgdp1807 authored Feb 1, 2024
2 parents 531fe9a + 94c6cea commit fdb4d3c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,6 @@ RUN(NAME array_22.cpp LABELS gcc llvm NOFAST)
RUN(NAME array_23.cpp LABELS gcc llvm NOFAST)

RUN(NAME struct_01.cpp LABELS gcc llvm NOFAST)
RUN(NAME struct_02.cpp LABELS gcc llvm NOFAST)

RUN(NAME function_01.cpp LABELS gcc llvm NOFAST)
58 changes: 58 additions & 0 deletions integration_tests/struct_02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <iostream>
#include "struct_02_m_01.h"
#include "struct_02_m_02.h"

using namespace std::complex_literals;

int main() {

struct X b;
struct Z c;

b.i = 5;
b.r = 3.5;
std::cout << b.i << " " << b.r << std::endl;
if( b.i != 5 ) {
exit(2);
}
if( b.r != 3.5 ) {
exit(2);
}

set(b);
std::cout << b.i << " " << b.r << std::endl;
if( b.i != 1 ) {
exit(2);
}
if( b.r != 1.5 ) {
exit(2);
}

c.l.d.r = 2.0;
c.l.d.i = 2;
c.k = 2.0 + 2i;
std::cout << c.l.d.r << " " << c.l.d.i << " " << c.k << std::endl;
if( c.l.d.r != 2.0 ) {
exit(2);
}
if( c.l.d.i != 2 ) {
exit(2);
}
if( c.k != 2.0 + 2i ) {
exit(2);
}

set(c.l.d);
std::cout << c.l.d.r << " " << c.l.d.i << " " << c.k << std::endl;
if( c.l.d.r != 1.5 ) {
exit(2);
}
if( c.l.d.i != 1.0 ) {
exit(2);
}
if( c.k != 2.0 + 2i ) {
exit(2);
}

return 0;
}
21 changes: 21 additions & 0 deletions integration_tests/struct_02_m_01.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef INTEGRATION_TESTS_STRUCT_02_M_01_H
#define INTEGRATION_TESTS_STRUCT_02_M_01_H

#include <complex>

struct X {
float r;
int i;
};

struct Y {
std::complex<double> c;
struct X d;
};

void set(struct X& a) {
a.i = 1;
a.r = 1.5;
}

#endif
11 changes: 11 additions & 0 deletions integration_tests/struct_02_m_02.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef INTEGRATION_TESTS_STRUCT_02_M_02_H
#define INTEGRATION_TESTS_STRUCT_02_M_02_H

#include "struct_02_m_01.h"

struct Z {
std::complex<double> k;
struct Y l;
};

#endif

0 comments on commit fdb4d3c

Please sign in to comment.