Skip to content
Snippets Groups Projects
Commit a7026369 authored by Malte Harms's avatar Malte Harms
Browse files

refactor power to pow and name test case

parent 53a08973
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ int plus( int a, int b) { return a + b; }
int minus( int a, int b) { return a - b; }
int multiply(int a, int b) { return a * b; }
int divide( int a, int b) { return a / b; }
int power( int a, int b) { return std::pow(a, b); }
int pow( int a, int b) { return std::pow(a, b); }
int pop_stack(auto &stack) {
const auto ret{stack.top()};
......@@ -31,7 +31,7 @@ int evaluate(const std::string &s) {
case '-': change_stack_state(minus, stack); break;
case '*': change_stack_state(multiply, stack); break;
case '/': change_stack_state(divide, stack); break;
case '^': change_stack_state(power, stack); break;
case '^': change_stack_state(pow, stack); break;
case '0'...'9': stack.push(c - '0'); break;
}
}
......
......@@ -7,7 +7,7 @@ TEST_CASE( "some example calculations", "[calc]") {
REQUIRE( evaluate("12+2-3*") == 3 );
}
TEST_CASE( "", "[calc]") {
TEST_CASE( "pow function works", "[calc]") {
REQUIRE( evaluate("22^") == 4 );
REQUIRE( evaluate("43^") == 64 );
REQUIRE_FALSE( evaluate("11^") == 2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment