Add more CXFAMeasurement unit tests.
Test the 1-param ctor.
Change-Id: I70ca6a0998517dcedd3b66ac0d05dd0429a345fc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/88850
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_measurement_unittest.cpp b/xfa/fxfa/parser/cxfa_measurement_unittest.cpp
index 7a84eb1..d5c17a4 100644
--- a/xfa/fxfa/parser/cxfa_measurement_unittest.cpp
+++ b/xfa/fxfa/parser/cxfa_measurement_unittest.cpp
@@ -44,3 +44,29 @@
EXPECT_EQ(XFA_Unit::Unknown, CXFA_Measurement::GetUnitFromString(L"Cm"));
EXPECT_EQ(XFA_Unit::Unknown, CXFA_Measurement::GetUnitFromString(L"cM"));
}
+
+TEST(CXFAMeasurementTest, EqualsPrefix) {
+ CXFA_Measurement no_unit(L"=5");
+ EXPECT_EQ(XFA_Unit::Unknown, no_unit.GetUnit());
+ EXPECT_FLOAT_EQ(5.0f, no_unit.GetValue());
+
+ CXFA_Measurement mm_unit(L"=5mm");
+ EXPECT_EQ(XFA_Unit::Mm, mm_unit.GetUnit());
+ EXPECT_FLOAT_EQ(5.0f, mm_unit.GetValue());
+}
+
+TEST(CXFAMeasurementTest, NoPrefix) {
+ CXFA_Measurement no_unit(L"5");
+ EXPECT_EQ(XFA_Unit::Unknown, no_unit.GetUnit());
+ EXPECT_FLOAT_EQ(5.0f, no_unit.GetValue());
+
+ CXFA_Measurement mm_unit(L"5mm");
+ EXPECT_EQ(XFA_Unit::Mm, mm_unit.GetUnit());
+ EXPECT_FLOAT_EQ(5.0f, mm_unit.GetValue());
+}
+
+TEST(CXFAMeasurementTest, InvalidValues) {
+ CXFA_Measurement empty(L"");
+ EXPECT_EQ(XFA_Unit::Unknown, empty.GetUnit());
+ EXPECT_FLOAT_EQ(0.0f, empty.GetValue());
+}