diff options
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/tests/LengthTest.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/tests/LengthTest.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/LengthTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/LengthTest.cpp index efc12548cbe..cacd73576bf 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/LengthTest.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/LengthTest.cpp @@ -39,6 +39,7 @@ TEST(LengthTest, set1) { len.set(1, Length::Unit::PC); EXPECT_DOUBLE_EQ(len.pt(), 12); + EXPECT_DOUBLE_EQ(len.pc(), 1); len.set(2.54, Length::Unit::CM); EXPECT_DOUBLE_EQ(len.pt(), 72.27); @@ -55,9 +56,11 @@ TEST(LengthTest, set1) { len.set(1, Length::Unit::CC); EXPECT_DOUBLE_EQ(len.dd(), 12.0); + EXPECT_DOUBLE_EQ(len.cc(), 1); len.set(1, Length::Unit::SP); EXPECT_DOUBLE_EQ(len.pt(), 1.0/65536); + EXPECT_DOUBLE_EQ(len.sp(), 1); } @@ -149,6 +152,44 @@ TEST(LengthTest, set3) { } +TEST(LengthTest, get) { + Length len; + len.set("1pt"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PT), 1); + + len.set("72bp"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PT), 72.27); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::BP), 72); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::IN), 1); + + len.set("1in"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PT), 72.27); + + len.set("1pc"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PT), 12); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PC), 1); + + len.set("2.54cm"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PT), 72.27); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::CM), 2.54); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::MM), 25.4); + + len.set("10mm"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::CM), 1); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::MM), 10); + + len.set("10dd"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::PT), 12380.0/1157); + + len.set("10cc"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::DD), 120.0); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::CC), 10.0); + + len.set("10sp"); + EXPECT_DOUBLE_EQ(len.get(Length::Unit::SP), 10.0); +} + + TEST(LengthTest, str2unit) { EXPECT_EQ(Length::stringToUnit("pt"), Length::Unit::PT); EXPECT_EQ(Length::stringToUnit("bp"), Length::Unit::BP); @@ -180,3 +221,15 @@ TEST(LengthTest, unit2str) { EXPECT_EQ(Length::unitToString(Length::Unit(300)), string("??")); } + +TEST(LengthTest, toString) { + EXPECT_EQ(Length(10, Length::Unit::PT).toString(Length::Unit::PT), "10pt"); + EXPECT_EQ(Length(10, Length::Unit::BP).toString(Length::Unit::BP), "10bp"); + EXPECT_EQ(Length(10, Length::Unit::IN).toString(Length::Unit::IN), "10in"); + EXPECT_EQ(Length(10, Length::Unit::CM).toString(Length::Unit::CM), "10cm"); + EXPECT_EQ(Length(10, Length::Unit::MM).toString(Length::Unit::MM), "10mm"); + EXPECT_EQ(Length(10, Length::Unit::PC).toString(Length::Unit::PC), "10pc"); + EXPECT_EQ(Length(10, Length::Unit::DD).toString(Length::Unit::DD), "10dd"); + EXPECT_EQ(Length(10, Length::Unit::CC).toString(Length::Unit::CC), "10cc"); + EXPECT_EQ(Length(10, Length::Unit::SP).toString(Length::Unit::SP), "10sp"); +}
\ No newline at end of file |