diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-03-04 09:58:37 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-03-04 09:58:37 +0000 |
commit | 63fe1142388b3cac6f3dfeed75cf28e00e0097ad (patch) | |
tree | dd7c0d4d13288e6d8dc60e9399c8b1c6f214cac6 /Build/source/texk/dvisvgm/dvisvgm-1.0.5/tests/LengthTest.cpp | |
parent | 8bbc8c26d77a016f91f7f8d3b80cc850c05175fb (diff) |
dvisvgm 1.0.5
git-svn-id: svn://tug.org/texlive/trunk@21604 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-1.0.5/tests/LengthTest.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-1.0.5/tests/LengthTest.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.0.5/tests/LengthTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.0.5/tests/LengthTest.cpp new file mode 100644 index 00000000000..c7c38f755c4 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.0.5/tests/LengthTest.cpp @@ -0,0 +1,120 @@ +/************************************************************************* +** LengthTest.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2011 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 ** +** published by the Free Software Foundation; either version 3 of ** +** the License, or (at your option) any later version. ** +** ** +** This program is distributed in the hope that it will be useful, but ** +** WITHOUT ANY WARRANTY; without even the implied warranty of ** +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** +** GNU General Public License for more details. ** +** ** +** You should have received a copy of the GNU General Public License ** +** along with this program; if not, see <http://www.gnu.org/licenses/>. ** +*************************************************************************/ + +#include <gtest/gtest.h> +#include "Length.h" + +TEST(LengthTest, set1) { + Length len; + len.set(1, Length::PT); + EXPECT_EQ(len.pt(), 1); + + len.set(72, Length::BP); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.bp(), 72); + EXPECT_EQ(len.in(), 1); + + len.set(1, Length::IN); + EXPECT_EQ(len.pt(), 72.27); + + len.set(12, Length::PC); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.in(), 1); + + len.set(2.54, Length::CM); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.cm(), 2.54); + EXPECT_EQ(len.mm(), 25.4); + + len.set(25.4, Length::MM); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.cm(), 2.54); + EXPECT_EQ(len.mm(), 25.4); +} + + +TEST(LengthTest, set2) { + Length len; + len.set(1, "pt"); + EXPECT_EQ(len.pt(), 1); + + len.set(72, "bp"); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.bp(), 72); + EXPECT_EQ(len.in(), 1); + EXPECT_EQ(len.pc(), 12); + + len.set(1, "in"); + EXPECT_EQ(len.pt(), 72.27); + + len.set(12, "pc"); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.in(), 1); + EXPECT_EQ(len.pc(), 12); + + len.set(2.54, "cm"); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.cm(), 2.54); + EXPECT_EQ(len.mm(), 25.4); + + len.set(10, "mm"); + EXPECT_EQ(len.cm(), 1); + EXPECT_EQ(len.mm(), 10); + + len.set(1, ""); + EXPECT_EQ(len.pt(), 1); + + ASSERT_THROW(len.set(1, "xy"), UnitException); +} + +TEST(LengthTest, set3) { + Length len; + len.set("1pt"); + EXPECT_EQ(len.pt(), 1); + + len.set("72bp"); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.bp(), 72); + EXPECT_EQ(len.in(), 1); + EXPECT_EQ(len.pc(), 12); + + len.set("1in"); + EXPECT_EQ(len.pt(), 72.27); + + len.set("12pc"); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.in(), 1); + EXPECT_EQ(len.pc(), 12); + + len.set("2.54cm"); + EXPECT_EQ(len.pt(), 72.27); + EXPECT_EQ(len.cm(), 2.54); + EXPECT_EQ(len.mm(), 25.4); + + len.set("10mm"); + EXPECT_EQ(len.cm(), 1); + EXPECT_EQ(len.mm(), 10); + + len.set("1"); + EXPECT_EQ(len.pt(), 1); + + ASSERT_THROW(len.set("1xy"), UnitException); + ASSERT_THROW(len.set("pt"), UnitException); +} |