Skip to content

Commit

Permalink
Merge pull request #97 from czgdp1807/enum_02
Browse files Browse the repository at this point in the history
Ported ``integration_tests/enum_02.py`` from LPython
  • Loading branch information
czgdp1807 authored Feb 29, 2024
2 parents d77844d + a881e68 commit f142447
Show file tree
Hide file tree
Showing 2 changed files with 48 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 @@ -224,3 +224,4 @@ RUN(NAME nbody_01.cpp LABELS gcc llvm NOFAST)
RUN(NAME nbody_02.cpp LABELS gcc llvm NOFAST)

RUN(NAME enum_01.cpp LABELS gcc llvm NOFAST)
RUN(NAME enum_02.cpp LABELS gcc llvm NOFAST)
47 changes: 47 additions & 0 deletions integration_tests/enum_02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <iostream>

enum MolecularMass {
water = 18,
methane = 16,
ammonia = 17,
oxygen = 16
};

enum RelativeCharge {
proton = 1,
electron = -1,
neutron = 0
};

void test_mm() {
std::cout << methane << " " << oxygen << std::endl;
if( methane != oxygen ) {
exit(2);
}

std::cout << ammonia - methane << std::endl;
if( ammonia - methane != 1 ) {
exit(2);
}

std::cout << water << " " << oxygen + 2 << std::endl;
if( water != oxygen + 2 ) {
exit(2);
}
}

void test_rc() {
std::cout << proton << " " << electron << " " << neutron << std::endl;
if( proton + electron != neutron ) {
exit(2);
}
}

int main() {

test_mm();
test_rc();

return 0;

}

0 comments on commit f142447

Please sign in to comment.