[code health] Replace ASSERT() with DCHECK() in fxbarcode/

Bug: pdfium:1596
Change-Id: I1d70b90d45755a09f6b7c7519b324995eaaf3744
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/77710
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/fxbarcode/BC_TwoDimWriter.cpp b/fxbarcode/BC_TwoDimWriter.cpp
index 3c4b4a4..98c4e70 100644
--- a/fxbarcode/BC_TwoDimWriter.cpp
+++ b/fxbarcode/BC_TwoDimWriter.cpp
@@ -15,6 +15,7 @@
 #include "core/fxge/cfx_renderdevice.h"
 #include "fxbarcode/BC_Writer.h"
 #include "fxbarcode/common/BC_CommonBitMatrix.h"
+#include "third_party/base/check.h"
 #include "third_party/base/numerics/safe_math.h"
 
 CBC_TwoDimWriter::CBC_TwoDimWriter(bool bFixedSize)
@@ -85,7 +86,7 @@
 
 void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
                                           const CFX_Matrix* matrix) {
-  ASSERT(m_output);
+  DCHECK(m_output);
 
   CFX_GraphStateData stateData;
   CFX_PathData path;
diff --git a/fxbarcode/common/BC_CommonBitMatrix.cpp b/fxbarcode/common/BC_CommonBitMatrix.cpp
index fcfa50c..b0180cc 100644
--- a/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -22,6 +22,7 @@
 
 #include "fxbarcode/common/BC_CommonBitMatrix.h"
 
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 CBC_CommonBitMatrix::CBC_CommonBitMatrix() = default;
@@ -44,7 +45,7 @@
 
 void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) {
   int32_t offset = y * m_rowSize + (x >> 5);
-  ASSERT(offset >= 0);
-  ASSERT(offset < m_rowSize * m_height);
+  DCHECK(offset >= 0);
+  DCHECK(offset < m_rowSize * m_height);
   m_bits[offset] |= 1 << (x & 0x1f);
 }
diff --git a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index 5f4ba3e..99fed1c 100644
--- a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -27,14 +27,15 @@
 
 #include "core/fxcrt/fx_system.h"
 #include "fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(
     CBC_ReedSolomonGF256* field,
     const std::vector<int32_t>& coefficients)
     : m_field(field) {
-  ASSERT(m_field);
-  ASSERT(!coefficients.empty());
+  DCHECK(m_field);
+  DCHECK(!coefficients.empty());
   if (coefficients.size() == 1 || coefficients.front() != 0) {
     m_coefficients = coefficients;
     return;
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp
index 4969add..8cdc2d1 100644
--- a/fxbarcode/datamatrix/BC_C40Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp
@@ -28,6 +28,7 @@
 #include "fxbarcode/datamatrix/BC_EncoderContext.h"
 #include "fxbarcode/datamatrix/BC_HighLevelEncoder.h"
 #include "fxbarcode/datamatrix/BC_SymbolInfo.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace {
@@ -191,7 +192,7 @@
 int32_t CBC_C40Encoder::BacktrackOneCharacter(CBC_EncoderContext* context,
                                               WideString* buffer,
                                               int32_t lastCharSize) {
-  ASSERT(lastCharSize >= 0);
+  DCHECK(lastCharSize >= 0);
 
   if (context->m_pos < 1)
     return -1;
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
index cccf73d..5444d41 100644
--- a/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
+++ b/fxbarcode/datamatrix/BC_DataMatrixWriter.cpp
@@ -41,6 +41,7 @@
 #include "fxbarcode/datamatrix/BC_SymbolInfo.h"
 #include "fxbarcode/datamatrix/BC_TextEncoder.h"
 #include "fxbarcode/datamatrix/BC_X12Encoder.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace {
@@ -49,13 +50,13 @@
     CBC_DefaultPlacement* placement,
     const CBC_SymbolInfo* symbolInfo) {
   int32_t symbolWidth = symbolInfo->GetSymbolDataWidth();
-  ASSERT(symbolWidth);
+  DCHECK(symbolWidth);
   int32_t symbolHeight = symbolInfo->GetSymbolDataHeight();
-  ASSERT(symbolHeight);
+  DCHECK(symbolHeight);
   int32_t width = symbolInfo->GetSymbolWidth();
-  ASSERT(width);
+  DCHECK(width);
   int32_t height = symbolInfo->GetSymbolHeight();
-  ASSERT(height);
+  DCHECK(height);
 
   auto matrix = std::make_unique<CBC_CommonByteMatrix>(width, height);
   int32_t matrixY = 0;
@@ -126,9 +127,9 @@
     return results;
 
   int32_t width = pSymbolInfo->GetSymbolDataWidth();
-  ASSERT(width);
+  DCHECK(width);
   int32_t height = pSymbolInfo->GetSymbolDataHeight();
-  ASSERT(height);
+  DCHECK(height);
 
   auto placement =
       std::make_unique<CBC_DefaultPlacement>(codewords, width, height);
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 6ecc168..7713a48 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -28,6 +28,7 @@
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "fxbarcode/datamatrix/BC_Encoder.h"
 #include "fxbarcode/datamatrix/BC_SymbolInfo.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace {
@@ -143,7 +144,7 @@
     0};
 
 WideString CreateECCBlock(const WideString& codewords, size_t numECWords) {
-  ASSERT(numECWords > 0);
+  DCHECK(numECWords > 0);
 
   const size_t len = codewords.GetLength();
   static constexpr size_t kFactorTableNum = pdfium::size(FACTOR_SETS);
@@ -177,7 +178,7 @@
   for (size_t i = 0; i < numECWords; ++i)
     strecc.InsertAtBack(static_cast<wchar_t>(ecc[numECWords - i - 1]));
 
-  ASSERT(!strecc.IsEmpty());
+  DCHECK(!strecc.IsEmpty());
   return strecc;
 }
 
@@ -228,6 +229,6 @@
       }
     }
   }
-  ASSERT(!sb.IsEmpty());
+  DCHECK(!sb.IsEmpty());
   return sb;
 }
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 8b04e91..14a43d5 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -39,6 +39,7 @@
 #include "fxbarcode/datamatrix/BC_SymbolInfo.h"
 #include "fxbarcode/datamatrix/BC_TextEncoder.h"
 #include "fxbarcode/datamatrix/BC_X12Encoder.h"
+#include "third_party/base/check.h"
 
 namespace {
 
@@ -111,7 +112,7 @@
 }
 
 size_t EncoderIndex(CBC_HighLevelEncoder::Encoding encoding) {
-  ASSERT(encoding != CBC_HighLevelEncoder::Encoding::UNKNOWN);
+  DCHECK(encoding != CBC_HighLevelEncoder::Encoding::UNKNOWN);
   return static_cast<size_t>(encoding);
 }
 
@@ -176,7 +177,7 @@
   while (codewords.GetLength() < capacity)
     codewords += Randomize253State(kPad, codewords.GetLength() + 1);
 
-  ASSERT(!codewords.IsEmpty());
+  DCHECK(!codewords.IsEmpty());
   return codewords;
 }
 
diff --git a/fxbarcode/oned/BC_OnedCode128Writer.cpp b/fxbarcode/oned/BC_OnedCode128Writer.cpp
index fa51f4a..4031e0e 100644
--- a/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -28,6 +28,7 @@
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "fxbarcode/BC_Writer.h"
 #include "fxbarcode/oned/BC_OneDimWriter.h"
+#include "third_party/base/check.h"
 
 namespace {
 
@@ -84,7 +85,7 @@
 
 CBC_OnedCode128Writer::CBC_OnedCode128Writer(BC_TYPE type)
     : m_codeFormat(type) {
-  ASSERT(m_codeFormat == BC_CODE128_B || m_codeFormat == BC_CODE128_C);
+  DCHECK(m_codeFormat == BC_CODE128_B || m_codeFormat == BC_CODE128_C);
 }
 
 CBC_OnedCode128Writer::~CBC_OnedCode128Writer() = default;
diff --git a/fxbarcode/qrcode/BC_QRCoderBitVector.cpp b/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
index b2a6f7c..def9221 100644
--- a/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderBitVector.cpp
@@ -44,7 +44,7 @@
 }
 
 void CBC_QRCoderBitVector::AppendBit(int32_t bit) {
-  ASSERT(bit == 0 || bit == 1);
+  DCHECK(bit == 0 || bit == 1);
   int32_t numBitsInLastByte = m_sizeInBits & 0x7;
   if (numBitsInLastByte == 0) {
     AppendByte(0);
@@ -55,8 +55,8 @@
 }
 
 void CBC_QRCoderBitVector::AppendBits(int32_t value, int32_t numBits) {
-  ASSERT(numBits > 0);
-  ASSERT(numBits <= 32);
+  DCHECK(numBits > 0);
+  DCHECK(numBits <= 32);
 
   int32_t numBitsLeft = numBits;
   while (numBitsLeft > 0) {
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index 5611eae..95faf0b 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -38,6 +38,7 @@
 #include "fxbarcode/qrcode/BC_QRCoderMatrixUtil.h"
 #include "fxbarcode/qrcode/BC_QRCoderMode.h"
 #include "fxbarcode/qrcode/BC_QRCoderVersion.h"
+#include "third_party/base/check.h"
 #include "third_party/base/optional.h"
 #include "third_party/base/stl_util.h"
 
@@ -229,7 +230,7 @@
     pdfium::span<const uint8_t> dataBytes,
     size_t numEcBytesInBlock) {
   // If |numEcBytesInBlock| is 0, the encoder will fail anyway.
-  ASSERT(numEcBytesInBlock > 0);
+  DCHECK(numEcBytesInBlock > 0);
   std::vector<int32_t> toEncode(dataBytes.size() + numEcBytesInBlock);
   std::copy(dataBytes.begin(), dataBytes.end(), toEncode.begin());
 
@@ -238,7 +239,7 @@
   if (encoder.Encode(&toEncode, numEcBytesInBlock)) {
     ecBytes = std::vector<uint8_t, FxAllocAllocator<uint8_t>>(
         toEncode.begin() + dataBytes.size(), toEncode.end());
-    ASSERT(ecBytes.size() == static_cast<size_t>(numEcBytesInBlock));
+    DCHECK(ecBytes.size() == static_cast<size_t>(numEcBytesInBlock));
   }
   return ecBytes;
 }
@@ -349,8 +350,8 @@
                            int32_t numDataBytes,
                            int32_t numRSBlocks,
                            CBC_QRCoderBitVector* result) {
-  ASSERT(numTotalBytes >= 0);
-  ASSERT(numDataBytes >= 0);
+  DCHECK(numTotalBytes >= 0);
+  DCHECK(numDataBytes >= 0);
   if (bits->sizeInBytes() != static_cast<size_t>(numDataBytes))
     return false;
 
diff --git a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
index 3f7c4a9..a4879e3 100644
--- a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
@@ -25,6 +25,7 @@
 #include "fxbarcode/common/BC_CommonByteMatrix.h"
 #include "fxbarcode/qrcode/BC_QRCoder.h"
 #include "fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
+#include "third_party/base/check.h"
 #include "third_party/base/notreached.h"
 
 namespace {
@@ -164,7 +165,7 @@
 bool CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern,
                                          int32_t x,
                                          int32_t y) {
-  ASSERT(CBC_QRCoder::IsValidMaskPattern(maskPattern));
+  DCHECK(CBC_QRCoder::IsValidMaskPattern(maskPattern));
 
   int32_t intermediate = 0, temp = 0;
   switch (maskPattern) {
diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
index dcc9235..4e1d2d3 100644
--- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
@@ -27,6 +27,7 @@
 #include "fxbarcode/qrcode/BC_QRCoderBitVector.h"
 #include "fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
 #include "fxbarcode/qrcode/BC_QRCoderMaskUtil.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace {
@@ -121,7 +122,7 @@
         } else {
           bit = 0;
         }
-        ASSERT(CBC_QRCoder::IsValidMaskPattern(maskPattern));
+        DCHECK(CBC_QRCoder::IsValidMaskPattern(maskPattern));
         if (CBC_QRCoderMaskUtil::GetDataMaskBit(maskPattern, xx, y))
           bit ^= 0x01;
         matrix->Set(xx, y, bit);
@@ -159,7 +160,7 @@
   if (!bits->XOR(&maskBits))
     return false;
 
-  ASSERT(bits->Size() == 15);
+  DCHECK(bits->Size() == 15);
   return true;
 }
 
@@ -167,7 +168,7 @@
   bits->AppendBits(version, 6);
   int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY);
   bits->AppendBits(bchCode, 12);
-  ASSERT(bits->Size() == 18);
+  DCHECK(bits->Size() == 18);
 }
 
 bool EmbedTypeInfo(const CBC_QRCoderErrorCorrectionLevel* ecLevel,
diff --git a/fxbarcode/qrcode/BC_QRCoderMode.cpp b/fxbarcode/qrcode/BC_QRCoderMode.cpp
index 8648f8c..9dfa506 100644
--- a/fxbarcode/qrcode/BC_QRCoderMode.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderMode.cpp
@@ -25,6 +25,7 @@
 #include <utility>
 
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 CBC_QRCoderMode* CBC_QRCoderMode::sBYTE = nullptr;
 CBC_QRCoderMode* CBC_QRCoderMode::sNUMERIC = nullptr;
@@ -96,6 +97,6 @@
     offset = 2;
 
   int32_t result = m_characterCountBitsForVersions[offset];
-  ASSERT(result != 0);
+  DCHECK(result != 0);
   return result;
 }