diff options
author | Adrian Kummerländer | 2013-01-05 17:46:21 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2013-01-05 17:46:21 +0100 |
commit | 0ab1ad8c67ac5579e10104f53040d962a7f98f17 (patch) | |
tree | 257428157cbf53b941ce19147ec59bf79cf4675b /test.cpp | |
parent | 16e2509100611447887f6050a5eb1c21ac9170c4 (diff) | |
download | SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.gz SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.bz2 SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.lz SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.xz SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.zst SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.zip |
Fixes for ugly style used in my early C++ days
Diffstat (limited to 'test.cpp')
-rw-r--r-- | test.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -6,35 +6,35 @@ class ParserTest : public ::testing::Test { }; TEST_F(ParserTest, BasicCalc) { - Parser p; + SimpleParser::Parser p; - EXPECT_EQ(4, p.calculate("2+2", false).result); - EXPECT_EQ(0, p.calculate("2-2", false).result); - EXPECT_EQ(42, p.calculate("21*2", false).result); - EXPECT_EQ(21, p.calculate("42/2", false).result); + 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) { - Parser p; - - EXPECT_EQ(10, p.calculate("2+2*4", false).result); - EXPECT_EQ(4, p.calculate("2+4/2", false).result); - EXPECT_EQ(42, p.calculate("5+10*4-3", false).result); - EXPECT_EQ(17, p.calculate("10+20/2-3", false).result); - EXPECT_EQ(261, p.calculate("5+2^8", false).result); - EXPECT_EQ(32768, p.calculate("2*2^16/4", false).result); - EXPECT_EQ(32772, p.calculate("2*2^16/4+4", false).result); + 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) { - Parser p; - - EXPECT_EQ(16, p.calculate("(2+2)*4", false).result); - EXPECT_EQ(10, p.calculate("2+(2*4)", false).result); - EXPECT_EQ(10, p.calculate("(10-5)*(5-3)", false).result); - EXPECT_EQ(4, p.calculate("((((2))*((2))))", false).result); - EXPECT_EQ(37, p.calculate("(((5))*(((((3+2*2)))))+2)", false).result); - EXPECT_EQ(6.25, p.calculate("2.5*(2+3-(3/2+1))", false).result); + 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) { |