aboutsummaryrefslogtreecommitdiff
path: root/test.cpp
diff options
context:
space:
mode:
authorAdrian Kummerländer2013-01-05 22:30:35 +0100
committerAdrian Kummerländer2013-01-05 22:30:35 +0100
commitcde848ce1eb995170723f6f070b9fcba0dfdb880 (patch)
treeb28b436619ade0f9b3ff7603cc987d7b5a621ff3 /test.cpp
parente3081360c65eb4994e7e8042898cec72de0d560b (diff)
downloadSimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.gz
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.bz2
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.lz
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.xz
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.zst
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.zip
Moved node classes into separate compilation unit; File extension change
Diffstat (limited to 'test.cpp')
-rw-r--r--test.cpp44
1 files changed, 0 insertions, 44 deletions
diff --git a/test.cpp b/test.cpp
deleted file mode 100644
index a752ad3..0000000
--- a/test.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "src/parser.h"
-#include "gtest/gtest.h"
-
-class ParserTest : public ::testing::Test {
-
-};
-
-TEST_F(ParserTest, BasicCalc) {
- SimpleParser::Parser p;
-
- EXPECT_EQ(4, p.calculate("2+2"));
- EXPECT_EQ(0, p.calculate("2-2"));
- EXPECT_EQ(42, p.calculate("21*2"));
- EXPECT_EQ(21, p.calculate("42/2"));
-}
-
-TEST_F(ParserTest, OperatorPriority) {
- SimpleParser::Parser p;
-
- EXPECT_EQ(10, p.calculate("2+2*4"));
- EXPECT_EQ(4, p.calculate("2+4/2"));
- EXPECT_EQ(42, p.calculate("5+10*4-3"));
- EXPECT_EQ(17, p.calculate("10+20/2-3"));
- EXPECT_EQ(261, p.calculate("5+2^8"));
- EXPECT_EQ(32768, p.calculate("2*2^16/4"));
- EXPECT_EQ(32772, p.calculate("2*2^16/4+4"));
-}
-
-TEST_F(ParserTest, BracketCalc) {
- SimpleParser::Parser p;
-
- EXPECT_EQ(16, p.calculate("(2+2)*4"));
- EXPECT_EQ(10, p.calculate("2+(2*4)"));
- EXPECT_EQ(10, p.calculate("(10-5)*(5-3)"));
- EXPECT_EQ(4, p.calculate("((((2))*((2))))"));
- EXPECT_EQ(37, p.calculate("(((5))*(((((3+2*2)))))+2)"));
- EXPECT_EQ(6.25, p.calculate("2.5*(2+3-(3/2+1))"));
-}
-
-int main(int argc, char **argv) {
- testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}