Added a util function to compare two FS_RECTF objects.

This process is currently carried out using ASSERT_EQ() function
calls for each of the fields in the struct.
Instead this will now be carried out by single function call to
CompareFS_RECTF(). It also uses ASSERT_FLOAT_EQ() instead of
ASSERT_EQ() to prevent any unwanted behavior during comparison of
floats. Comparison is carried out in the same order as the
definition of the fields.
The files where this function resides
(testing/utils/compare_coordinates.h (/.cc)) have been added to
the embedder_tests target in the BUILD.gn file.
The utility function has been used in the
FPDFTextEmbedderTest.CroppedText test to demonstrate it's working.

Bug: 42270440
Change-Id: Ied7467758817efa8f9a1ce0e5f767a462918cb22
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/124630
Reviewed-by: Tom Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/AUTHORS b/AUTHORS
index 74d839a..652f732 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -38,6 +38,7 @@
 Ralf Sippl <ralf.sippl@gmail.com>
 Robert Collyer <rcollyer99@gmail.com>
 Ryan Wiley <wileyrr@gmail.com>
+Satvic Dhawan <satvicdhawan14@gmail.com>
 Stefan Ziegler <sz5000@gmx.de>
 Stephan Hartmann <stha09@googlemail.com>
 Tibor Dusnoki <tdusnoki@inf.u-szeged.hu>
diff --git a/fpdfsdk/fpdf_text_embeddertest.cpp b/fpdfsdk/fpdf_text_embeddertest.cpp
index 7e2976c..051391a 100644
--- a/fpdfsdk/fpdf_text_embeddertest.cpp
+++ b/fpdfsdk/fpdf_text_embeddertest.cpp
@@ -19,6 +19,7 @@
 #include "testing/fx_string_testhelpers.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "testing/utils/compare_coordinates.h"
 
 using ::testing::ElementsAreArray;
 
@@ -972,8 +973,9 @@
   EXPECT_EQ(sizeof(kExpectedFontName1),
             FPDFText_GetFontInfo(textpage.get(), 0, font_name.data(),
                                  font_name.size(), nullptr));
-  for (char a : font_name)
+  for (char a : font_name) {
     EXPECT_EQ('a', a);
+  }
 
   // The text is "Hello, world!\r\nGoodbye, world!", so the next two characters
   // do not have any font information.
@@ -1396,10 +1398,7 @@
 
     FS_RECTF box;
     EXPECT_TRUE(FPDF_GetPageBoundingBox(page.get(), &box));
-    EXPECT_EQ(kBoxes[i].left, box.left);
-    EXPECT_EQ(kBoxes[i].top, box.top);
-    EXPECT_EQ(kBoxes[i].right, box.right);
-    EXPECT_EQ(kBoxes[i].bottom, box.bottom);
+    CompareFS_RECTF(kBoxes[i], box);
 
     ScopedFPDFTextPage textpage(FPDFText_LoadPage(page.get()));
     ASSERT_TRUE(textpage);
diff --git a/testing/BUILD.gn b/testing/BUILD.gn
index 9e12e38..94381f9 100644
--- a/testing/BUILD.gn
+++ b/testing/BUILD.gn
@@ -182,6 +182,8 @@
     "fake_file_access.h",
     "range_set.cpp",
     "range_set.h",
+    "utils/compare_coordinates.cc",
+    "utils/compare_coordinates.h",
   ]
   deps = [
     "../:pdfium_public_headers",
diff --git a/testing/utils/compare_coordinates.cc b/testing/utils/compare_coordinates.cc
new file mode 100644
index 0000000..096f868
--- /dev/null
+++ b/testing/utils/compare_coordinates.cc
@@ -0,0 +1,15 @@
+// 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/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.top, val2.top);
+}
diff --git a/testing/utils/compare_coordinates.h b/testing/utils/compare_coordinates.h
new file mode 100644
index 0000000..053a9b4
--- /dev/null
+++ b/testing/utils/compare_coordinates.h
@@ -0,0 +1,12 @@
+// 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.
+
+#ifndef TESTING_UTILS_COMPARE_COORDINATES_H_
+#define TESTING_UTILS_COMPARE_COORDINATES_H_
+
+#include "public/fpdfview.h"
+
+void CompareFS_RECTF(const FS_RECTF& val1, const FS_RECTF& val2);
+
+#endif  // TESTING_UTILS_COMPARE_COORDINATES_H_