mirror of
https://pdfium.googlesource.com/pdfium
synced 2026-07-31 04:29:37 +08:00
Introduce the RectDouble struct and associated verification functions to testing/utils/compare_coordinates.h to simplify bounding box assertions. These helpers reduce boilerplate by grouping coordinate checks into single function calls, supporting both exact double equality and three-decimal-place precision. In addition to the local test helpers, this change adds CompareFS_RECTF_Three_Places to the common testing utilities and corrects a logic error in CompareFS_RECTF where the top coordinate was being compared twice instead of checking the bottom coordinate. Existing tests are updated to use these new helpers, resulting in cleaner and more maintainable test code. Change-Id: I552c0667efdd1175fcc8ae2dbbb4fc3ed9ed316a Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/145950 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Aryan Krishnan <aryankrishnan4b@gmail.com> Reviewed-by: Andy Phan <andyphan@chromium.org>
48 lines
1.7 KiB
C++
48 lines
1.7 KiB
C++
// Copyright 2024 The PDFium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "testing/utils/compare_coordinates.h"
|
|
|
|
#include "public/fpdfview.h"
|
|
#include "testing/embedder_test.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
void CompareFS_RECTF(const FS_RECTF& val1, const FS_RECTF& val2) {
|
|
EXPECT_FLOAT_EQ(val1.left, val2.left);
|
|
EXPECT_FLOAT_EQ(val1.top, val2.top);
|
|
EXPECT_FLOAT_EQ(val1.right, val2.right);
|
|
EXPECT_FLOAT_EQ(val1.bottom, val2.bottom);
|
|
}
|
|
|
|
void CompareFS_MATRIX(const FS_MATRIX& val1, const FS_MATRIX& val2) {
|
|
EXPECT_FLOAT_EQ(val1.a, val2.a);
|
|
EXPECT_FLOAT_EQ(val1.b, val2.b);
|
|
EXPECT_FLOAT_EQ(val1.c, val2.c);
|
|
EXPECT_FLOAT_EQ(val1.d, val2.d);
|
|
EXPECT_FLOAT_EQ(val1.e, val2.e);
|
|
EXPECT_FLOAT_EQ(val1.f, val2.f);
|
|
}
|
|
|
|
void CompareFS_RECTF_Three_Places(const FS_RECTF& val1, const FS_RECTF& val2) {
|
|
EXPECT_NEAR_THREE_PLACES(val1.left, val2.left);
|
|
EXPECT_NEAR_THREE_PLACES(val1.top, val2.top);
|
|
EXPECT_NEAR_THREE_PLACES(val1.right, val2.right);
|
|
EXPECT_NEAR_THREE_PLACES(val1.bottom, val2.bottom);
|
|
}
|
|
|
|
void CompareFS_RECT_DOUBLE_Three_Places(const RectDouble& val1,
|
|
const RectDouble& val2) {
|
|
EXPECT_NEAR_THREE_PLACES(val1.left, val2.left);
|
|
EXPECT_NEAR_THREE_PLACES(val1.top, val2.top);
|
|
EXPECT_NEAR_THREE_PLACES(val1.right, val2.right);
|
|
EXPECT_NEAR_THREE_PLACES(val1.bottom, val2.bottom);
|
|
}
|
|
|
|
void CompareFS_RECT_DOUBLE(const RectDouble& val1, const RectDouble& val2) {
|
|
EXPECT_DOUBLE_EQ(val1.left, val2.left);
|
|
EXPECT_DOUBLE_EQ(val1.top, val2.top);
|
|
EXPECT_DOUBLE_EQ(val1.right, val2.right);
|
|
EXPECT_DOUBLE_EQ(val1.bottom, val2.bottom);
|
|
}
|