-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(infinite number): implement operations function
They don’t implement infinite value, it will be implemented in the end
- Loading branch information
1 parent
3faf749
commit 69e290c
Showing
4 changed files
with
156 additions
and
24 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
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,107 @@ | ||
#include <gtest/gtest.h> | ||
#include "InfiniteNumber.h" | ||
|
||
TEST(InfiniteNumber, AdditionOne) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "9+3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "12"); | ||
} | ||
|
||
TEST(InfiniteNumber, AdditionTwo) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7+3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-4"); | ||
} | ||
|
||
TEST(InfiniteNumber, AdditionThree) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7+-3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-10"); | ||
} | ||
|
||
TEST(InfiniteNumber, SubstractionOne) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "9-3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "6"); | ||
} | ||
|
||
TEST(InfiniteNumber, SubstractionTwo) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7-3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-10"); | ||
} | ||
|
||
TEST(InfiniteNumber, SubstractionThree) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7--3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-4"); | ||
} | ||
|
||
TEST(InfiniteNumber, MultiplicationOne) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "9*3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "27"); | ||
} | ||
|
||
TEST(InfiniteNumber, MultiplicationTwo) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7*3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-21"); | ||
} | ||
|
||
TEST(InfiniteNumber, MultiplicationThree) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7*-3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "21"); | ||
} | ||
|
||
TEST(InfiniteNumber, DivisionOne) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "9/3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "3"); | ||
} | ||
|
||
TEST(InfiniteNumber, DivisionTwo) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7/3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-2"); | ||
} | ||
|
||
TEST(InfiniteNumber, DivisionThree) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7/-3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "2"); | ||
} | ||
|
||
TEST(InfiniteNumber, RestOne) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "9%3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "0"); | ||
} | ||
|
||
TEST(InfiniteNumber, RestTwo) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7%3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-1"); | ||
} | ||
|
||
TEST(InfiniteNumber, RestThree) | ||
{ | ||
std::unique_ptr<Operations::IOperations> infiniteNumber = std::make_unique<Operations::InfiniteNumber>(); | ||
std::string str = "-7%-3"; | ||
EXPECT_EQ(infiniteNumber->makeOperation(str), "-1"); | ||
} |