Fix GCC build issue in fxcodec.DecodeDataZeroSize test
Adjust the code to avoid the following issue by changing `kStreamData`
to std::array.
../../core/fxcodec/jpx/jpx_unittest.cpp: In member function ‘virtual void fxcodec::fxcodec_DecodeDataZeroSize_Test::TestBody()’:
../../core/fxcodec/jpx/jpx_unittest.cpp:67:17: error: missing template argument list after ‘pdfium::span’; template placeholder not permitted in parameter
67 | DecodeData dd(pdfium::span(kStreamData).first(0u));
| ^~~~~~
| <>
Along the way, put constants in an anonymous namespace and make them
constexpr.
Change-Id: I5f20ab53c9efec6b19c51e00b44aab55c201596d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/131330
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/jpx/jpx_unittest.cpp b/core/fxcodec/jpx/jpx_unittest.cpp
index 11b6e1c..d84a2c2 100644
--- a/core/fxcodec/jpx/jpx_unittest.cpp
+++ b/core/fxcodec/jpx/jpx_unittest.cpp
@@ -6,6 +6,7 @@
#include <stdint.h>
#include <algorithm>
+#include <array>
#include <limits>
#include <type_traits>
@@ -18,13 +19,19 @@
namespace fxcodec {
-static const OPJ_OFF_T kSkipError = static_cast<OPJ_OFF_T>(-1);
-static const OPJ_SIZE_T kReadError = static_cast<OPJ_SIZE_T>(-1);
+namespace {
-static const uint8_t kStreamData[] = {
+constexpr OPJ_OFF_T kSkipError = static_cast<OPJ_OFF_T>(-1);
+constexpr OPJ_SIZE_T kReadError = static_cast<OPJ_SIZE_T>(-1);
+
+constexpr auto kStreamData = std::to_array<const uint8_t>({
+ // clang-format off
0x00, 0x01, 0x02, 0x03,
0x84, 0x85, 0x86, 0x87, // Include some hi-bytes, too.
-};
+ // clang-format on
+});
+
+} // namespace
TEST(fxcodec, DecodeDataNullDecodeData) {
uint8_t buffer[16];