diff options
author | Takuji Tanaka <ttk@t-lab.opal.ne.jp> | 2021-01-23 08:47:24 +0000 |
---|---|---|
committer | Takuji Tanaka <ttk@t-lab.opal.ne.jp> | 2021-01-23 08:47:24 +0000 |
commit | d6bed26b0031e2fc1c06c7524653a0c692784286 (patch) | |
tree | 6c7f961e775ca16b18a1804538db93ed0d41927d /Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp | |
parent | cefa6c9380ba792d6c1646c71c6ebf4934de8d7a (diff) |
dvisvgm 2.11.1
git-svn-id: svn://tug.org/texlive/trunk@57501 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp index af79a4c8e1c..09945222d43 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/CalculatorTest.cpp @@ -2,7 +2,7 @@ ** CalculatorTest.cpp ** ** ** ** This file is part of dvisvgm -- a fast DVI to SVG converter ** -** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de> ** +** Copyright (C) 2005-2021 Martin Gieseking <martin.gieseking@uos.de> ** ** ** ** This program is free software; you can redistribute it and/or ** ** modify it under the terms of the GNU General Public License as ** @@ -25,7 +25,10 @@ TEST(CalculatorTest, eval) { Calculator calc; + EXPECT_EQ(calc.eval("2"), 2); + EXPECT_EQ(calc.eval("-2"), -2); EXPECT_EQ(calc.eval("2+3+4"), 9); + EXPECT_EQ(calc.eval(" 2 + 3+ 4 "), 9); EXPECT_EQ(calc.eval("2*3+4"), 10); EXPECT_EQ(calc.eval("2+3*4"), 14); EXPECT_EQ(calc.eval("(2+3)*4"), 20); @@ -36,7 +39,11 @@ TEST(CalculatorTest, eval) { EXPECT_EQ(calc.eval("(1+2)-(3+4)"), -4); EXPECT_EQ(calc.eval("-2+3+4"), 5); EXPECT_EQ(calc.eval("3/2"), 1.5); + EXPECT_EQ(calc.eval("1+3/2"), 2.5); + EXPECT_EQ(calc.eval("3/2+1"), 2.5); EXPECT_EQ(calc.eval("3%2"), 1); + EXPECT_EQ(calc.eval("1+3%2"), 2); + EXPECT_EQ(calc.eval("3%2+1"), 2); EXPECT_EQ(calc.eval("-(4)"), -4); } @@ -51,6 +58,8 @@ TEST(CalculatorTest, variables) { calc.setVariable("b", 3); EXPECT_EQ(calc.eval("a+b"), 5); + EXPECT_EQ(calc.eval("a+a*b"), 8); + EXPECT_EQ(calc.eval("a*a+b"), 7); EXPECT_EQ(calc.eval("2a+2b"), 10); EXPECT_EQ(calc.eval("2a(1+2b)"), 28); } @@ -64,6 +73,8 @@ TEST(CalculatorTest, exceptions) { ASSERT_THROW(calc.eval("1%0"), CalculatorException); ASSERT_THROW(calc.eval("2*(3+4"), CalculatorException); ASSERT_THROW(calc.eval("2*(3+4))"), CalculatorException); + ASSERT_THROW(calc.eval("2*3+4)"), CalculatorException); + ASSERT_THROW(calc.eval("2(3+4"), CalculatorException); } |