Finish replacing ASSERT() with DCHECK().

Then remove its definition from fx_system.h

Fixed: pdfium:1596
Change-Id: Ibaaf4f754744cfc54c6ef2d613569ad98a021392
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/77730
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/core/fdrm/fx_crypt_aes.cpp b/core/fdrm/fx_crypt_aes.cpp
index d4e446f..8d0caac 100644
--- a/core/fdrm/fx_crypt_aes.cpp
+++ b/core/fdrm/fx_crypt_aes.cpp
@@ -6,6 +6,8 @@
 
 #include "core/fdrm/fx_crypt.h"
 
+#include "third_party/base/check.h"
+
 #define mulby2(x) (((x & 0x7F) << 1) ^ (x & 0x80 ? 0x1B : 0))
 #define GET_32BIT_MSB_FIRST(cp)                    \
   (((unsigned long)(unsigned char)(cp)[3]) |       \
@@ -516,7 +518,7 @@
 #undef LASTWORD
 
 void aes_setup(CRYPT_aes_context* ctx, const unsigned char* key, int keylen) {
-  ASSERT(keylen == 16 || keylen == 24 || keylen == 32);
+  DCHECK(keylen == 16 || keylen == 24 || keylen == 32);
   int Nk = keylen / 4;
   ctx->Nb = 4;
   ctx->Nr = 6 + (ctx->Nb > Nk ? ctx->Nb : Nk);
@@ -581,7 +583,7 @@
                      CRYPT_aes_context* ctx) {
   unsigned int iv[4], x[4], ct[4];
   int i;
-  ASSERT((len & 15) == 0);
+  DCHECK((len & 15) == 0);
   memcpy(iv, ctx->iv, sizeof(iv));
   while (len > 0) {
     for (i = 0; i < 4; i++) {
@@ -609,7 +611,7 @@
                      CRYPT_aes_context* ctx) {
   unsigned int iv[4];
   int i;
-  ASSERT((len & 15) == 0);
+  DCHECK((len & 15) == 0);
   memcpy(iv, ctx->iv, sizeof(iv));
   while (len > 0) {
     for (i = 0; i < 4; i++) {
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index b71c88e..1f01817 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -49,14 +49,6 @@
 #define FX_FILESIZE off_t
 #endif  // defined(OS_WIN)
 
-#ifndef ASSERT
-#ifndef NDEBUG
-#define ASSERT assert
-#else
-#define ASSERT(a)
-#endif  // NDEBUG
-#endif  // ASSERT
-
 // M_PI not universally present on all platforms.
 #define FX_PI 3.1415926535897932384626433832795f
 #define FX_BEZIER 0.5522847498308f
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 7d91b04..bd69af7 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -21,6 +21,7 @@
 #include "testing/utils/file_util.h"
 #include "testing/utils/hash.h"
 #include "testing/utils/path_service.h"
+#include "third_party/base/check.h"
 #include "third_party/base/notreached.h"
 #include "third_party/base/stl_util.h"
 
@@ -70,7 +71,7 @@
 
 void EmbedderTest::TearDown() {
   // Use an EXPECT_EQ() here and continue to let TearDown() finish as cleanly as
-  // possible. This can fail when an ASSERT test fails in a test case.
+  // possible. This can fail when an DCHECK test fails in a test case.
   EXPECT_EQ(0U, page_map_.size());
   EXPECT_EQ(0U, saved_page_map_.size());
   if (document_)
@@ -245,7 +246,7 @@
 }
 
 void EmbedderTest::DoOpenActions() {
-  ASSERT(form_handle_);
+  DCHECK(form_handle_);
   FORM_DoDocumentJSAction(form_handle_);
   FORM_DoDocumentOpenAction(form_handle_);
 }
@@ -274,9 +275,9 @@
 }
 
 FPDF_PAGE EmbedderTest::LoadPageCommon(int page_number, bool do_events) {
-  ASSERT(form_handle_);
-  ASSERT(page_number >= 0);
-  ASSERT(!pdfium::Contains(page_map_, page_number));
+  DCHECK(form_handle_);
+  DCHECK(page_number >= 0);
+  DCHECK(!pdfium::Contains(page_map_, page_number));
 
   FPDF_PAGE page = FPDF_LoadPage(document_, page_number);
   if (!page)
@@ -299,7 +300,7 @@
 }
 
 void EmbedderTest::UnloadPageCommon(FPDF_PAGE page, bool do_events) {
-  ASSERT(form_handle_);
+  DCHECK(form_handle_);
   int page_number = GetPageNumberForLoadedPage(page);
   if (page_number < 0) {
     NOTREACHED();
@@ -466,7 +467,7 @@
 }
 
 void EmbedderTest::CloseSavedDocument() {
-  ASSERT(saved_document_);
+  DCHECK(saved_document_);
 
   FPDFDOC_ExitFormFillEnvironment(saved_form_handle_);
   FPDF_CloseDocument(saved_document_);
@@ -478,9 +479,9 @@
 }
 
 FPDF_PAGE EmbedderTest::LoadSavedPage(int page_number) {
-  ASSERT(saved_form_handle_);
-  ASSERT(page_number >= 0);
-  ASSERT(!pdfium::Contains(saved_page_map_, page_number));
+  DCHECK(saved_form_handle_);
+  DCHECK(page_number >= 0);
+  DCHECK(!pdfium::Contains(saved_page_map_, page_number));
 
   FPDF_PAGE page = FPDF_LoadPage(saved_document_, page_number);
   if (!page)
@@ -493,7 +494,7 @@
 }
 
 void EmbedderTest::CloseSavedPage(FPDF_PAGE page) {
-  ASSERT(saved_form_handle_);
+  DCHECK(saved_form_handle_);
 
   int page_number = GetPageNumberForSavedPage(page);
   if (page_number < 0) {
@@ -512,8 +513,8 @@
                                         int width,
                                         int height,
                                         const char* md5) {
-  ASSERT(saved_document_);
-  ASSERT(page);
+  DCHECK(saved_document_);
+  DCHECK(page);
 
   ScopedFPDFBitmap bitmap = RenderSavedPageWithFlags(page, FPDF_ANNOT);
   CompareBitmap(bitmap.get(), width, height, md5);
@@ -528,7 +529,7 @@
 }
 
 void EmbedderTest::SetWholeFileAvailable() {
-  ASSERT(fake_file_access_);
+  DCHECK(fake_file_access_);
   fake_file_access_->SetWholeFileAvailable();
 }
 
@@ -699,7 +700,7 @@
   for (const auto& it : page_map) {
     if (it.second == page) {
       int page_number = it.first;
-      ASSERT(page_number >= 0);
+      DCHECK(page_number >= 0);
       return page_number;
     }
   }
diff --git a/testing/embedder_test_environment.cpp b/testing/embedder_test_environment.cpp
index 0b10a93..d96bfcb 100644
--- a/testing/embedder_test_environment.cpp
+++ b/testing/embedder_test_environment.cpp
@@ -6,6 +6,7 @@
 
 #include "core/fxcrt/fx_system.h"
 #include "public/fpdfview.h"
+#include "third_party/base/check.h"
 
 #ifdef PDF_ENABLE_V8
 #include "testing/v8_test_environment.h"
@@ -18,12 +19,12 @@
 }  // namespace
 
 EmbedderTestEnvironment::EmbedderTestEnvironment() {
-  ASSERT(!g_environment);
+  DCHECK(!g_environment);
   g_environment = this;
 }
 
 EmbedderTestEnvironment::~EmbedderTestEnvironment() {
-  ASSERT(g_environment);
+  DCHECK(g_environment);
   g_environment = nullptr;
 }
 
diff --git a/testing/fake_file_access.cpp b/testing/fake_file_access.cpp
index 068448d..20e62a4 100644
--- a/testing/fake_file_access.cpp
+++ b/testing/fake_file_access.cpp
@@ -9,6 +9,7 @@
 #include <utility>
 
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 namespace {
 
@@ -77,7 +78,7 @@
       file_access_wrapper_(std::make_unique<FileAccessWrapper>(this)),
       file_avail_(std::make_unique<FileAvailImpl>(this)),
       download_hints_(std::make_unique<DownloadHintsImpl>(this)) {
-  ASSERT(file_access_);
+  DCHECK(file_access_);
 }
 
 FakeFileAccess::~FakeFileAccess() = default;
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index 4a7bda7..8adf382 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -8,6 +8,7 @@
 #include <ios>
 
 #include "core/fxcrt/fx_string.h"
+#include "third_party/base/check.h"
 #include "third_party/base/span.h"
 
 std::ostream& operator<<(std::ostream& os, const CFX_DateTime& dt) {
@@ -72,6 +73,6 @@
 }
 
 std::vector<FPDF_WCHAR> GetFPDFWideStringBuffer(size_t length_bytes) {
-  ASSERT(length_bytes % sizeof(FPDF_WCHAR) == 0);
+  DCHECK(length_bytes % sizeof(FPDF_WCHAR) == 0);
   return std::vector<FPDF_WCHAR>(length_bytes / sizeof(FPDF_WCHAR));
 }
diff --git a/testing/range_set.cpp b/testing/range_set.cpp
index ffd71cf..449ea9e 100644
--- a/testing/range_set.cpp
+++ b/testing/range_set.cpp
@@ -7,6 +7,7 @@
 #include <algorithm>
 
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 RangeSet::RangeSet() = default;
 
@@ -60,7 +61,7 @@
 }
 
 void RangeSet::Union(const RangeSet& range_set) {
-  ASSERT(&range_set != this);
+  DCHECK(&range_set != this);
   for (const auto& it : range_set.ranges())
     Union(it);
 }
diff --git a/testing/string_write_stream.cpp b/testing/string_write_stream.cpp
index 53141eb..2a5dbb7 100644
--- a/testing/string_write_stream.cpp
+++ b/testing/string_write_stream.cpp
@@ -3,8 +3,10 @@
 // found in the LICENSE file.
 
 #include "testing/string_write_stream.h"
+
 #include "core/fxcrt/bytestring.h"
 #include "core/fxcrt/widestring.h"
+#include "third_party/base/check.h"
 
 StringWriteStream::StringWriteStream() = default;
 
@@ -21,7 +23,7 @@
 bool StringWriteStream::WriteBlockAtOffset(const void* pData,
                                            FX_FILESIZE offset,
                                            size_t size) {
-  ASSERT(offset == 0);
+  DCHECK(offset == 0);
   stream_.write(static_cast<const char*>(pData), size);
   return true;
 }
diff --git a/testing/utils/path_service.cpp b/testing/utils/path_service.cpp
index 97158a3..cf9f61e 100644
--- a/testing/utils/path_service.cpp
+++ b/testing/utils/path_service.cpp
@@ -18,6 +18,7 @@
 #include <string>
 
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 namespace {
 
@@ -68,7 +69,7 @@
     return false;
   *path = std::string(path_buffer);
 #elif defined(__APPLE__)
-  ASSERT(path);
+  DCHECK(path);
   unsigned int path_length = 0;
   _NSGetExecutablePath(NULL, &path_length);
   if (path_length == 0)
diff --git a/testing/v8_test_environment.cpp b/testing/v8_test_environment.cpp
index 94203c2..ce8fb2d 100644
--- a/testing/v8_test_environment.cpp
+++ b/testing/v8_test_environment.cpp
@@ -9,6 +9,7 @@
 
 #include "core/fxcrt/fx_system.h"
 #include "testing/v8_initializer.h"
+#include "third_party/base/check.h"
 #include "v8/include/libplatform/libplatform.h"
 #include "v8/include/v8-platform.h"
 #include "v8/include/v8.h"
@@ -22,12 +23,12 @@
 V8TestEnvironment::V8TestEnvironment(const char* exe_name)
     : exe_path_(exe_name),
       array_buffer_allocator_(std::make_unique<CFX_V8ArrayBufferAllocator>()) {
-  ASSERT(!g_environment);
+  DCHECK(!g_environment);
   g_environment = this;
 }
 
 V8TestEnvironment::~V8TestEnvironment() {
-  ASSERT(g_environment);
+  DCHECK(g_environment);
 
 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
   if (startup_data_)
diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp
index 80defc8..190ca06 100644
--- a/testing/xfa_js_embedder_test.cpp
+++ b/testing/xfa_js_embedder_test.cpp
@@ -13,6 +13,7 @@
 #include "fxjs/xfa/cfxjse_isolatetracker.h"
 #include "fxjs/xfa/cfxjse_value.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/check.h"
 
 XFAJSEmbedderTest::XFAJSEmbedderTest() = default;
 
@@ -51,7 +52,7 @@
     LinearizeOption linearize_option,
     JavaScriptOption javascript_option) {
   // JS required for XFA.
-  ASSERT(javascript_option == JavaScriptOption::kEnableJavaScript);
+  DCHECK(javascript_option == JavaScriptOption::kEnableJavaScript);
   if (!EmbedderTest::OpenDocumentWithOptions(
           filename, password, linearize_option, javascript_option)) {
     return false;
diff --git a/testing/xfa_test_environment.cpp b/testing/xfa_test_environment.cpp
index 7799bb1..4d7747d 100644
--- a/testing/xfa_test_environment.cpp
+++ b/testing/xfa_test_environment.cpp
@@ -7,6 +7,7 @@
 #include "core/fxge/cfx_fontmgr.h"
 #include "core/fxge/cfx_gemodule.h"
 #include "core/fxge/systemfontinfo_iface.h"
+#include "third_party/base/check.h"
 #include "xfa/fgas/font/cfgas_gemodule.h"
 
 namespace {
@@ -16,12 +17,12 @@
 }  // namespace
 
 XFATestEnvironment::XFATestEnvironment() {
-  ASSERT(!g_env);
+  DCHECK(!g_env);
   g_env = this;
 }
 
 XFATestEnvironment::~XFATestEnvironment() {
-  ASSERT(g_env);
+  DCHECK(g_env);
   g_env = nullptr;
 }