Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_measurement_unittest.cpp
Go to the documentation of this file.
1// Copyright 2019 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "xfa/fxfa/parser/cxfa_measurement.h"
6
7#include "testing/gtest/include/gtest/gtest.h"
8
10 CXFA_Measurement measurement;
11
12 measurement.Set(0.1f, XFA_Unit::Percent);
13 EXPECT_STREQ(L"0.1%", measurement.ToString().c_str());
14 measurement.Set(1.0f, XFA_Unit::Em);
15 EXPECT_STREQ(L"1em", measurement.ToString().c_str());
16 measurement.Set(1.1f, XFA_Unit::Pt);
17 EXPECT_STREQ(L"1.1pt", measurement.ToString().c_str());
18 measurement.Set(1.0000001f, XFA_Unit::In);
19 EXPECT_STREQ(L"1.0000001in", measurement.ToString().c_str());
20 measurement.Set(1234.0f, XFA_Unit::Pc);
21 EXPECT_STREQ(L"1234pc", measurement.ToString().c_str());
22 measurement.Set(987654321.0123456789f, XFA_Unit::Cm);
23 EXPECT_STREQ(L"9.8765434e+08cm", measurement.ToString().c_str());
24 measurement.Set(0.0f, XFA_Unit::Mm);
25 EXPECT_STREQ(L"0mm", measurement.ToString().c_str());
26 measurement.Set(-2.0f, XFA_Unit::Mp);
27 EXPECT_STREQ(L"-2mp", measurement.ToString().c_str());
28}
29
47
49 CXFA_Measurement no_unit(L"=5");
50 EXPECT_EQ(XFA_Unit::Unknown, no_unit.GetUnit());
51 EXPECT_FLOAT_EQ(5.0f, no_unit.GetValue());
52
53 CXFA_Measurement mm_unit(L"=5mm");
54 EXPECT_EQ(XFA_Unit::Mm, mm_unit.GetUnit());
55 EXPECT_FLOAT_EQ(5.0f, mm_unit.GetValue());
56}
57
59 CXFA_Measurement no_unit(L"5");
60 EXPECT_EQ(XFA_Unit::Unknown, no_unit.GetUnit());
61 EXPECT_FLOAT_EQ(5.0f, no_unit.GetValue());
62
63 CXFA_Measurement mm_unit(L"5mm");
64 EXPECT_EQ(XFA_Unit::Mm, mm_unit.GetUnit());
65 EXPECT_FLOAT_EQ(5.0f, mm_unit.GetValue());
66}
67
69 CXFA_Measurement empty(L"");
70 EXPECT_EQ(XFA_Unit::Unknown, empty.GetUnit());
71 EXPECT_FLOAT_EQ(0.0f, empty.GetValue());
72
73 CXFA_Measurement equals(L"=");
74 EXPECT_EQ(XFA_Unit::Unknown, equals.GetUnit());
75 EXPECT_FLOAT_EQ(0.0f, equals.GetValue());
76}
void Set(float fValue, XFA_Unit eUnit)
float GetValue() const
static XFA_Unit GetUnitFromString(WideStringView wsUnit)
WideString ToString() const
XFA_Unit GetUnit() const
const wchar_t * c_str() const
Definition widestring.h:81
TEST(FXCRYPT, MD5GenerateEmtpyData)
XFA_Unit
Definition fxfa_basic.h:91