Skip to content

Commit

Permalink
test(unit tests): add unit test for operations priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealPad committed Mar 4, 2024
1 parent 5a6c053 commit b524d77
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/OperationsPriorities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,31 @@ TEST(ProxyOperationsPriorities, InvalidStringFive)
isValid = false;
}
EXPECT_EQ(isValid, false);
}

TEST(ProxyOperationsPriorities, OperatorPriorityOne)
{
std::unique_ptr<Operations::IOperations> operations = std::make_unique<Operations::ProxyOperationsPriorities>();
std::string str = "1+10*2";
const std::string result = operations->makeOperation(str);

EXPECT_EQ(result, "21");
}

TEST(ProxyOperationsPriorities, OperatorPriorityTwo)
{
std::unique_ptr<Operations::IOperations> operations = std::make_unique<Operations::ProxyOperationsPriorities>();
std::string str = "(1+10)*2";
const std::string result = operations->makeOperation(str);

EXPECT_EQ(result, "22");
}

TEST(ProxyOperationsPriorities, OperatorPriorityThree)
{
std::unique_ptr<Operations::IOperations> operations = std::make_unique<Operations::ProxyOperationsPriorities>();
std::string str = "((1+2)-4)*(5/(2+3))+3";
const std::string result = operations->makeOperation(str);

EXPECT_EQ(result, "2");
}

0 comments on commit b524d77

Please sign in to comment.