diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-10-01 14:11:26 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-10-01 14:11:26 +0000 |
commit | 7031fb25c01d2f107ffc741c7b82efd87718f2c4 (patch) | |
tree | 080a3dd9385346cb36991bcce9047b9946a01351 /Build/source/texk/dvisvgm/dvisvgm-1.0.3/tests/LengthTest.cpp | |
parent | 30e4cb274ed8ce8af054f2e228270a270ee958e5 (diff) |
dvisvgm 1.0.3 (6 aug 10)
git-svn-id: svn://tug.org/texlive/trunk@19969 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-1.0.3/tests/LengthTest.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-1.0.3/tests/LengthTest.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.0.3/tests/LengthTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.0.3/tests/LengthTest.cpp new file mode 100644 index 00000000000..7add99c2d55 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-1.0.3/tests/LengthTest.cpp @@ -0,0 +1,120 @@ +/************************************************************************* +** LengthTest.cpp ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2010 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); +} |