Skip to content

Commit

Permalink
TEST: Ported integration_tests/enum_02.py from LPython
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Feb 29, 2024
1 parent d77844d commit a6252c9
Showing 1 changed file with 47 additions and 0 deletions.
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 a6252c9

Please sign in to comment.