-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from czgdp1807/structs_02
Test including user defined header files
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |