/// // Copyright (C) 2003, 2004, Fredrik Arnerup & Rasmus Kaj, See COPYING /// #include "valueunit.h" #include "testbed/testbed.hh" template class TestValue : public TestCase { public: TestValue(std::string input, Value value, std::string unit) : TestCase("ValueUnit " + input), input_(input), value_(value), unit_(unit) {} void test() { ValueUnit vu = to >(input_); if(vu.value() != value_) throw std::logic_error("Unexpeted value"); if(vu.unit() != unit_) throw std::logic_error("Unexpected unit"); } private: std::string input_; Value value_; std::string unit_; }; namespace { TestValue t1("14em", 14, "em"); TestValue t2("14.0em", 14, "em"); TestValue t3("14.000em", 14, "em"); TestValue t4("14.2pt", 14.2, "pt"); TestValue t7("14.2", 14.2, ""); TestValue t5("4711pt", 4711, "pt"); TestValue t6("4711h", 4711, "h"); TestValue t8("17", 17, ""); }