Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / geometry / FloatBoxTestHelpers.cpp
bloba40d97ee837ff757acc54f5004edbe7114b88b31
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #include "config.h"
26 #include "platform/geometry/FloatBoxTestHelpers.h"
27 #include "platform/geometry/GeometryTestHelpers.h"
29 #include "platform/geometry/FloatBox.h"
30 const static float kTestEpsilon = 1e-6;
32 namespace blink {
33 namespace FloatBoxTest {
35 bool ApproximatelyEqual(const float& a, const float& b)
37 return GeometryTest::ApproximatelyEqual(a, b, kTestEpsilon);
40 bool ApproximatelyEqual(const FloatBox& a, const FloatBox& b)
42 if (!ApproximatelyEqual(a.x(), b.x())
43 || !ApproximatelyEqual(a.y(), b.y())
44 || !ApproximatelyEqual(a.z(), b.z())
45 || !ApproximatelyEqual(a.width(), b.width())
46 || !ApproximatelyEqual(a.height(), b.height())
47 || !ApproximatelyEqual(a.depth(), b.depth())) {
48 return false;
50 return true;
53 ::testing::AssertionResult AssertAlmostEqual(const char* m_expr, const char* n_expr, const FloatBox& m, const FloatBox& n)
55 if (!ApproximatelyEqual(m, n)) {
56 return ::testing::AssertionFailure() << " Value of:" << n_expr << std::endl
57 << " Actual:" << testing::PrintToString(n) << std::endl
58 << "Expected Approx:" << m_expr << std::endl
59 << " Which is:" << ::testing::PrintToString(m);
61 return ::testing::AssertionSuccess();
64 ::testing::AssertionResult AssertContains(const char* m_expr, const char* n_expr, const FloatBox& m, const FloatBox& n)
66 FloatBox newM = m;
67 newM.expandTo(n);
68 if (!ApproximatelyEqual(m, newM)) {
69 return ::testing::AssertionFailure() << " Value of:" << n_expr << std::endl
70 << " Actual:" << testing::PrintToString(n) << std::endl
71 << "Not Contained in:" << m_expr << std::endl
72 << " Which is:" << ::testing::PrintToString(m);
74 return ::testing::AssertionSuccess();
77 } // namespace FloatBoxTest
78 } // namespace blink