Mark function scope constexpr constants as static in tests
As discussed in [1], and for consistency.
[1] https://groups.google.com/a/chromium.org/g/chromium-dev/c/OXxJy5L96jI
Change-Id: I64918542e9b1320707f957782924739dd1fb7367
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/126410
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/core/fdrm/fx_crypt_unittest.cpp b/core/fdrm/fx_crypt_unittest.cpp
index 64f3efa..91fe60e 100644
--- a/core/fdrm/fx_crypt_unittest.cpp
+++ b/core/fdrm/fx_crypt_unittest.cpp
@@ -100,7 +100,7 @@
pdfium::span<const uint8_t> data_span = pdfium::make_span(data);
uint32_t total = 0;
while (total < length) {
- constexpr uint32_t kChunkLen = 4097; // intentionally not 2^k.
+ static constexpr uint32_t kChunkLen = 4097; // intentionally not 2^k.
uint32_t len = std::min(kChunkLen, length - total);
CRYPT_MD5Update(&ctx, data_span.subspan(total, len));
total += len;
diff --git a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
index 23edf31..da69d50 100644
--- a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
+++ b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp
@@ -55,7 +55,7 @@
"36/ID[<D889EB6B9ADF88E5EDA7DC08FE85978B><";
ASSERT_THAT(saved_data, testing::HasSubstr(kTrailerBeforeSecondID));
size_t trailer_start = saved_data.find(kTrailerBeforeSecondID);
- constexpr size_t kIdLen = 32;
+ static constexpr size_t kIdLen = 32;
size_t trailer_continuation =
trailer_start + strlen(kTrailerBeforeSecondID) + kIdLen;
std::string data_after_second_id = saved_data.substr(trailer_continuation);
diff --git a/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp b/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
index f1dc837..03fbdc5 100644
--- a/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
+++ b/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
@@ -54,8 +54,8 @@
ASSERT_TRUE(range.has_value());
ASSERT_EQ(4u, range.value().m_CharSize);
{
- constexpr uint8_t kLower[4] = {18, 52, 86, 120};
- constexpr uint8_t kUpper[4] = {135, 101, 67, 33};
+ static constexpr uint8_t kLower[4] = {18, 52, 86, 120};
+ static constexpr uint8_t kUpper[4] = {135, 101, 67, 33};
EXPECT_TRUE(uint_ranges_equal(kLower, range.value().m_Lower));
EXPECT_TRUE(uint_ranges_equal(kUpper, range.value().m_Upper));
}
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp
index 0403fd0..1c3cf95 100644
--- a/core/fpdfapi/parser/cpdf_array_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp
@@ -42,14 +42,14 @@
}
for (size_t i = 0; i < 3; ++i)
arr->RemoveAt(3);
- constexpr std::array<int, 7> expected = {{1, 2, 3, 7, 8, 9, 10}};
+ static constexpr std::array<int, 7> expected = {{1, 2, 3, 7, 8, 9, 10}};
ASSERT_EQ(expected.size(), arr->size());
for (size_t i = 0; i < expected.size(); ++i) {
EXPECT_EQ(expected[i], arr->GetIntegerAt(i));
}
arr->RemoveAt(4);
arr->RemoveAt(4);
- constexpr std::array<int, 5> expected2 = {{1, 2, 3, 7, 10}};
+ static constexpr std::array<int, 5> expected2 = {{1, 2, 3, 7, 10}};
ASSERT_EQ(std::size(expected2), arr->size());
for (size_t i = 0; i < std::size(expected2); ++i)
EXPECT_EQ(expected2[i], arr->GetIntegerAt(i));
@@ -84,7 +84,8 @@
}
TEST(ArrayTest, InsertAt) {
- constexpr std::array<int, 10> elems = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
+ static constexpr std::array<int, 10> elems = {
+ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < std::size(elems); ++i) {
arr->InsertNewAt<CPDF_Number>(i, elems[i]);
@@ -96,7 +97,7 @@
arr->InsertNewAt<CPDF_Number>(3, 33);
arr->InsertNewAt<CPDF_Number>(6, 55);
arr->InsertNewAt<CPDF_Number>(12, 12);
- constexpr std::array<int, 13> expected = {
+ static constexpr std::array<int, 13> expected = {
{1, 2, 3, 33, 4, 5, 55, 6, 7, 8, 9, 10, 12}};
ASSERT_EQ(expected.size(), arr->size());
for (size_t i = 0; i < expected.size(); ++i) {
@@ -114,7 +115,8 @@
TEST(ArrayTest, Clone) {
{
// Basic case.
- constexpr std::array<int, 10> elems = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
+ static constexpr std::array<int, 10> elems = {
+ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < std::size(elems); ++i) {
arr->InsertNewAt<CPDF_Number>(i, elems[i]);
@@ -132,7 +134,7 @@
static const size_t kNumOfRows = 3;
static const size_t kNumOfColumns = 5;
using ElemRow = std::array<int, kNumOfColumns>;
- constexpr std::array<ElemRow, kNumOfRows> elems = {{
+ static constexpr std::array<ElemRow, kNumOfRows> elems = {{
{{1, 2, 3, 4, 5}},
{{10, 9, 8, 7, 6}},
{{11, 12, 13, 14, 15}},
@@ -235,7 +237,7 @@
}
TEST(ArrayTest, Iterator) {
- constexpr std::array<int, 10> elems = {
+ static constexpr std::array<int, 10> elems = {
{-23, -11, 3, 455, 2345877, 0, 7895330, -12564334, 10000, -100000}};
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < std::size(elems); ++i) {
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index 99a7978..c476d14 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -246,8 +246,8 @@
// ObjNum can be added in CPDF_DataAvail::IsPageAvail(), and PagesDict may not
// exist in this case, e.g. when hint table is used to page check in
// CPDF_DataAvail.
- constexpr int kPageCount = 100;
- constexpr int kTestPageNum = 33;
+ static constexpr int kPageCount = 100;
+ static constexpr int kTestPageNum = 33;
auto linearization_dict = pdfium::MakeRetain<CPDF_Dictionary>();
CPDF_TestDocumentAllowSetParser document;
diff --git a/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp b/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp
index 9b978b3..5360ddf 100644
--- a/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp
@@ -209,7 +209,7 @@
auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
dict->SetNewFor<CPDF_Name>("Type", "ObjStm");
dict->SetNewFor<CPDF_Number>("N", 3);
- constexpr int kTooBigOffset = std::size(kNormalStreamContent);
+ static constexpr int kTooBigOffset = std::size(kNormalStreamContent);
dict->SetNewFor<CPDF_Number>("First", kTooBigOffset);
ByteStringView contents_view(kNormalStreamContent);
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp
index c9bb93a..5cd3b46 100644
--- a/core/fpdfapi/parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -199,7 +199,7 @@
};
TEST_F(PDFObjectsTest, GetString) {
- constexpr auto direct_obj_results = fxcrt::ToArray<const char*>(
+ static constexpr auto direct_obj_results = fxcrt::ToArray<const char*>(
{"false", "true", "1245", "9.0034504", "A simple test", "\t\n", "space",
"", "", "", ""});
// Check for direct objects.
@@ -208,7 +208,7 @@
}
// Check indirect references.
- constexpr auto indirect_obj_results = fxcrt::ToArray<const char*>(
+ static constexpr auto indirect_obj_results = fxcrt::ToArray<const char*>(
{"true", "1245", "\t\n", "space", "", "", ""});
for (size_t i = 0; i < m_RefObjs.size(); ++i) {
EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetString());
@@ -216,7 +216,7 @@
}
TEST_F(PDFObjectsTest, GetUnicodeText) {
- constexpr auto direct_obj_results = fxcrt::ToArray<const wchar_t*>(
+ static constexpr auto direct_obj_results = fxcrt::ToArray<const wchar_t*>(
{L"", L"", L"", L"", L"A simple test", L"\t\n", L"space", L"", L"",
L"abcdefghijklmnopqrstuvwxyz", L""});
// Check for direct objects.
@@ -231,7 +231,7 @@
}
TEST_F(PDFObjectsTest, GetNumber) {
- constexpr auto direct_obj_results =
+ static constexpr auto direct_obj_results =
fxcrt::ToArray<const float>({0, 0, 1245, 9.00345f, 0, 0, 0, 0, 0, 0, 0});
// Check for direct objects.
for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
@@ -239,14 +239,14 @@
}
// Check indirect references.
- constexpr auto indirect_obj_results =
+ static constexpr auto indirect_obj_results =
fxcrt::ToArray<const float>({0, 1245, 0, 0, 0, 0, 0});
for (size_t i = 0; i < m_RefObjs.size(); ++i)
EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetNumber());
}
TEST_F(PDFObjectsTest, GetInteger) {
- constexpr auto direct_obj_results =
+ static constexpr auto direct_obj_results =
fxcrt::ToArray<const int>({0, 1, 1245, 9, 0, 0, 0, 0, 0, 0, 0});
// Check for direct objects.
for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
@@ -254,7 +254,7 @@
}
// Check indirect references.
- constexpr auto indirect_obj_results =
+ static constexpr auto indirect_obj_results =
fxcrt::ToArray<const int>({1, 1245, 0, 0, 0, 0, 0});
for (size_t i = 0; i < m_RefObjs.size(); ++i) {
EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetInteger());
@@ -347,9 +347,9 @@
TEST_F(PDFObjectsTest, SetString) {
// Check for direct objects.
- constexpr auto set_values = fxcrt::ToArray<const char*>(
+ static constexpr auto set_values = fxcrt::ToArray<const char*>(
{"true", "fake", "3.125f", "097", "changed", "", "NewName"});
- constexpr auto expected = fxcrt::ToArray<const char*>(
+ static constexpr auto expected = fxcrt::ToArray<const char*>(
{"true", "false", "3.125", "97", "changed", "", "NewName"});
for (size_t i = 0; i < std::size(set_values); ++i) {
m_DirectObjs[i]->SetString(set_values[i]);
@@ -456,7 +456,7 @@
TEST(PDFArrayTest, GetMatrix) {
using Row = std::array<float, 6>;
- constexpr auto elems = fxcrt::ToArray<const Row>({
+ static constexpr auto elems = fxcrt::ToArray<const Row>({
{{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}},
{{1, 2, 3, 4, 5, 6}},
{{2.3f, 4.05f, 3, -2, -3, 0.0f}},
@@ -475,7 +475,7 @@
TEST(PDFArrayTest, GetRect) {
using Row = std::array<float, 4>;
- constexpr auto elems = fxcrt::ToArray<const Row>({
+ static constexpr auto elems = fxcrt::ToArray<const Row>({
{{0.0f, 0.0f, 0.0f, 0.0f}},
{{1, 2, 5, 6}},
{{2.3f, 4.05f, -3, 0.0f}},
@@ -495,7 +495,7 @@
TEST(PDFArrayTest, GetTypeAt) {
{
// Boolean array.
- constexpr auto vals =
+ static constexpr auto vals =
fxcrt::ToArray<const bool>({true, false, false, true, true});
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < vals.size(); ++i) {
@@ -514,7 +514,7 @@
}
{
// Integer array.
- constexpr auto vals = fxcrt::ToArray<const int>(
+ static constexpr auto vals = fxcrt::ToArray<const int>(
{10, 0, -345, 2089345456, -1000000000, 567, 93658767});
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < vals.size(); ++i) {
@@ -534,13 +534,13 @@
}
{
// Float array.
- constexpr auto vals = fxcrt::ToArray<const float>(
+ static constexpr auto vals = fxcrt::ToArray<const float>(
{0.0f, 0, 10, 10.0f, 0.0345f, 897.34f, -2.5f, -1.0f, -345.0f, -0.0f});
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < vals.size(); ++i) {
arr->InsertNewAt<CPDF_Number>(i, vals[i]);
}
- constexpr auto expected_str =
+ static constexpr auto expected_str =
fxcrt::ToArray<const char*>({"0", "0", "10", "10", ".034499999",
"897.34003", "-2.5", "-1", "-345", "0"});
for (size_t i = 0; i < vals.size(); ++i) {
@@ -556,7 +556,7 @@
}
{
// String and name array
- constexpr auto vals = fxcrt::ToArray<const char*>(
+ static constexpr auto vals = fxcrt::ToArray<const char*>(
{"this", "adsde$%^", "\r\t", "\"012", ".", "EYREW", "It is a joke :)"});
auto string_array = pdfium::MakeRetain<CPDF_Array>();
auto name_array = pdfium::MakeRetain<CPDF_Array>();
@@ -715,12 +715,12 @@
DataVector<uint8_t>(std::begin(kData), std::end(kData)), stream_dict);
arr->InsertNewAt<CPDF_Reference>(13, &object_holder,
stream_val->GetObjNum());
- constexpr auto expected_str = fxcrt::ToArray<const char*>(
+ static constexpr auto expected_str = fxcrt::ToArray<const char*>(
{"true", "false", "0", "-1234", "2345", ".050000001", "",
"It is a test!", "NAME", "test", "", "", "", ""});
- constexpr auto expected_int = fxcrt::ToArray<const int>(
+ static constexpr auto expected_int = fxcrt::ToArray<const int>(
{1, 0, 0, -1234, 2345, 0, 0, 0, 0, 0, 0, 0, 0, 0});
- constexpr auto expected_float = fxcrt::ToArray<const float>(
+ static constexpr auto expected_float = fxcrt::ToArray<const float>(
{0, 0, 0, -1234, 2345, 0.05f, 0, 0, 0, 0, 0, 0, 0, 0});
for (size_t i = 0; i < arr->size(); ++i) {
EXPECT_EQ(expected_str[i], arr->GetByteStringAt(i));
@@ -746,7 +746,7 @@
}
TEST(PDFArrayTest, AddNumber) {
- constexpr auto vals = fxcrt::ToArray<const float>(
+ static constexpr auto vals = fxcrt::ToArray<const float>(
{1.0f, -1.0f, 0, 0.456734f, 12345.54321f, 0.5f, 1000, 0.000045f});
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < vals.size(); ++i) {
@@ -759,7 +759,7 @@
}
TEST(PDFArrayTest, AddInteger) {
- constexpr auto vals = fxcrt::ToArray<const int>(
+ static constexpr auto vals = fxcrt::ToArray<const int>(
{0, 1, 934435456, 876, 10000, -1, -24354656, -100});
auto arr = pdfium::MakeRetain<CPDF_Array>();
for (size_t i = 0; i < vals.size(); ++i) {
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
index 5af3e9f..f6008c4 100644
--- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
@@ -151,9 +151,9 @@
ASSERT_TRUE(parser.InitTestFromFile(test_file.c_str())) << test_file;
ASSERT_TRUE(parser.RebuildCrossRef());
- constexpr std::array<FX_FILESIZE, 7> offsets = {
+ static constexpr std::array<FX_FILESIZE, 7> offsets = {
{0, 15, 61, 154, 296, 374, 450}};
- constexpr std::array<uint16_t, 7> versions = {{0, 0, 2, 4, 6, 8, 0}};
+ static constexpr std::array<uint16_t, 7> versions = {{0, 0, 2, 4, 6, 8, 0}};
for (size_t i = 0; i < std::size(offsets); ++i) {
EXPECT_EQ(offsets[i], GetObjInfo(parser, i).pos);
}
diff --git a/core/fpdfapi/parser/cpdf_stream_acc_unittest.cpp b/core/fpdfapi/parser/cpdf_stream_acc_unittest.cpp
index caf7c95..942f388 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc_unittest.cpp
@@ -25,7 +25,7 @@
// Regression test for crbug.com/1361849. Should not trigger dangling pointer
// failure with UnownedPtr.
TEST(StreamAccTest, DataStreamLifeTime) {
- constexpr uint8_t kData[] = {'a', 'b', 'c'};
+ static constexpr uint8_t kData[] = {'a', 'b', 'c'};
auto stream = pdfium::MakeRetain<CPDF_Stream>(kData);
auto stream_acc = pdfium::MakeRetain<CPDF_StreamAcc>(stream);
stream_acc->LoadAllDataRaw();
diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp
index 5e010a6..81ce06a 100644
--- a/core/fpdfdoc/cpdf_filespec_unittest.cpp
+++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -102,7 +102,7 @@
#endif
}};
// Keyword fields in reverse order of precedence to retrieve the file name.
- constexpr std::array<const char*, 5> keywords = {
+ static constexpr std::array<const char*, 5> keywords = {
{"Unix", "Mac", "DOS", "F", "UF"}};
auto dict_obj = pdfium::MakeRetain<CPDF_Dictionary>();
CPDF_FileSpec file_spec(dict_obj);
@@ -163,10 +163,10 @@
dict_obj->SetNewFor<CPDF_Dictionary>("EF");
CPDF_FileSpec file_spec(dict_obj);
- const wchar_t file_name[] = L"test.pdf";
- constexpr std::array<const char*, 5> keys = {
+ static constexpr wchar_t file_name[] = L"test.pdf";
+ static constexpr std::array<const char*, 5> keys = {
{"Unix", "Mac", "DOS", "F", "UF"}};
- constexpr std::array<const char*, 5> streams = {
+ static constexpr std::array<const char*, 5> streams = {
{"test1", "test2", "test3", "test4", "test5"}};
static_assert(std::size(keys) == std::size(streams), "size mismatch");
RetainPtr<CPDF_Dictionary> file_dict = dict_obj->GetMutableDictFor("EF");
diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp
index f5189e9..766a428 100644
--- a/core/fpdfdoc/cpdf_formfield_unittest.cpp
+++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp
@@ -46,7 +46,7 @@
form_dict->SetNewFor<CPDF_Name>("Subtype", "Widget");
form_dict->SetNewFor<CPDF_Name>(pdfium::form_fields::kFT,
pdfium::form_fields::kCh);
- constexpr int kMuliSelectFlag = pdfium::form_flags::kChoiceMultiSelect;
+ static constexpr int kMuliSelectFlag = pdfium::form_flags::kChoiceMultiSelect;
form_dict->SetNewFor<CPDF_Number>(pdfium::form_fields::kFf, kMuliSelectFlag);
form_dict->SetFor("Opt", opt_array);
form_dict->SetFor(pdfium::form_fields::kV, values);
diff --git a/core/fpdfdoc/cpdf_nametree_unittest.cpp b/core/fpdfdoc/cpdf_nametree_unittest.cpp
index 752b691..939dd9a 100644
--- a/core/fpdfdoc/cpdf_nametree_unittest.cpp
+++ b/core/fpdfdoc/cpdf_nametree_unittest.cpp
@@ -107,7 +107,7 @@
auto pNames = pRootDict->SetNewFor<CPDF_Array>("Names");
// Add the key "1" (with BOM) and value 100 into the array.
- constexpr uint8_t kData[] = {0xFE, 0xFF, 0x00, 0x31};
+ static constexpr uint8_t kData[] = {0xFE, 0xFF, 0x00, 0x31};
pNames->AppendNew<CPDF_String>(kData, CPDF_String::DataType::kIsHex);
pNames->AppendNew<CPDF_Number>(100);
diff --git a/core/fpdfdoc/cpdf_pagelabel_unittest.cpp b/core/fpdfdoc/cpdf_pagelabel_unittest.cpp
index 14aa513..a31414a 100644
--- a/core/fpdfdoc/cpdf_pagelabel_unittest.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel_unittest.cpp
@@ -84,8 +84,8 @@
// {900: |"D",,999|}
//
void FillPageLabelsTreeDict(CPDF_Dictionary* page_labels_root) {
- constexpr char kKids[] = "Kids";
- constexpr char kNums[] = "Nums";
+ static constexpr char kKids[] = "Kids";
+ static constexpr char kNums[] = "Nums";
auto page_labels_root_kids = page_labels_root->SetNewFor<CPDF_Array>(kKids);
auto kid1 = page_labels_root_kids->AppendNew<CPDF_Dictionary>();
diff --git a/core/fpdftext/cpdf_linkextract_unittest.cpp b/core/fpdftext/cpdf_linkextract_unittest.cpp
index c329943..c99b43f 100644
--- a/core/fpdftext/cpdf_linkextract_unittest.cpp
+++ b/core/fpdftext/cpdf_linkextract_unittest.cpp
@@ -43,7 +43,7 @@
const wchar_t* expected_output;
};
// Check cases that can extract valid mail link.
- constexpr IOPair kValidStrings[] = {
+ static constexpr IOPair kValidStrings[] = {
{L"peter@abc.d", L"peter@abc.d"},
{L"red.teddy.b@abc.com", L"red.teddy.b@abc.com"},
{L"abc_@gmail.com", L"abc_@gmail.com"}, // '_' is ok before '@'.
diff --git a/core/fxcrt/cfx_bitstream_unittest.cpp b/core/fxcrt/cfx_bitstream_unittest.cpp
index 64cc928..0c1618d 100644
--- a/core/fxcrt/cfx_bitstream_unittest.cpp
+++ b/core/fxcrt/cfx_bitstream_unittest.cpp
@@ -164,8 +164,9 @@
// the bitstream arithmetic, but as long as we don't try to extract
// any bits, the calculations should be unaffected.
const uint8_t kNotReallyBigEnough[32] = {};
- constexpr size_t kAllocationBytes = std::numeric_limits<size_t>::max() / 8;
- constexpr size_t kAllocationBits = kAllocationBytes * 8;
+ static constexpr size_t kAllocationBytes =
+ std::numeric_limits<size_t>::max() / 8;
+ static constexpr size_t kAllocationBits = kAllocationBytes * 8;
// SAFETY: intentionally not safe, see above.
CFX_BitStream bitstream(
diff --git a/core/fxcrt/fixed_size_data_vector_unittest.cpp b/core/fxcrt/fixed_size_data_vector_unittest.cpp
index c7cb129..2b0a5c7 100644
--- a/core/fxcrt/fixed_size_data_vector_unittest.cpp
+++ b/core/fxcrt/fixed_size_data_vector_unittest.cpp
@@ -26,7 +26,7 @@
ASSERT_EQ(4u, vec.size());
ASSERT_EQ(4u, vec.span().size());
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
fxcrt::Copy(kData, vec.span());
EXPECT_THAT(vec.span(), testing::ElementsAre(1, 2, 3, 4));
}
@@ -37,7 +37,7 @@
ASSERT_EQ(4u, vec.size());
ASSERT_EQ(4u, vec.span().size());
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
fxcrt::Copy(kData, vec.span());
EXPECT_THAT(vec.span(), testing::ElementsAre(1, 2, 3, 4));
}
@@ -49,7 +49,7 @@
EXPECT_EQ(4u, vec.span().size());
EXPECT_THAT(vec.span(), testing::ElementsAre(0, 0, 0, 0));
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
fxcrt::Copy(kData, vec.span());
EXPECT_THAT(vec.span(), testing::ElementsAre(1, 2, 3, 4));
}
@@ -61,13 +61,13 @@
ASSERT_EQ(4u, vec.span().size());
EXPECT_THAT(vec.span(), testing::ElementsAre(0, 0, 0, 0));
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
fxcrt::Copy(kData, vec.span());
EXPECT_THAT(vec.span(), testing::ElementsAre(1, 2, 3, 4));
}
TEST(FixedSizeDataVector, TryAllocFailures) {
- constexpr size_t kCloseToMaxByteAlloc =
+ static constexpr size_t kCloseToMaxByteAlloc =
std::numeric_limits<size_t>::max() - 100;
auto vec = FixedSizeDataVector<int>::TryZeroed(kCloseToMaxByteAlloc);
EXPECT_TRUE(vec.empty());
@@ -81,7 +81,7 @@
}
TEST(FixedSizeDataVector, MoveConstruct) {
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
auto vec = FixedSizeDataVector<int>::Uninit(4);
ASSERT_EQ(4u, vec.span().size());
fxcrt::Copy(kData, vec.span());
@@ -113,7 +113,7 @@
TEST(FixedSizeDataVector, MoveAssign) {
auto vec = FixedSizeDataVector<int>();
auto vec2 = FixedSizeDataVector<int>::Zeroed(4);
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
ASSERT_EQ(4u, vec2.span().size());
fxcrt::Copy(kData, vec2.span());
@@ -124,7 +124,7 @@
}
TEST(FixedSizeDataVector, TruncatedFrom) {
- constexpr int kData[] = {1, 2, 3, 4};
+ static constexpr int kData[] = {1, 2, 3, 4};
auto vec1 = FixedSizeDataVector<int>::Uninit(4);
fxcrt::Copy(kData, vec1.span());
diff --git a/core/fxcrt/fx_coordinates_unittest.cpp b/core/fxcrt/fx_coordinates_unittest.cpp
index 01945c0..67c5be8 100644
--- a/core/fxcrt/fx_coordinates_unittest.cpp
+++ b/core/fxcrt/fx_coordinates_unittest.cpp
@@ -394,7 +394,7 @@
}
TEST(CFXMatrixTest, GetInverse) {
- constexpr CFX_Matrix m(3, 0, 2, 3, 1, 4);
+ static constexpr CFX_Matrix m(3, 0, 2, 3, 1, 4);
CFX_Matrix rev = m.GetInverse();
EXPECT_FLOAT_EQ(0.33333334f, rev.a);
@@ -413,8 +413,8 @@
// Note, I think these are a bug and the matrix should be the identity.
TEST(CFXMatrixTest, GetInverseCR702041) {
// The determinate is < std::numeric_limits<float>::epsilon()
- constexpr CFX_Matrix m(0.947368443f, -0.108947366f, -0.923076928f,
- 0.106153846f, 18.0f, 787.929993f);
+ static constexpr CFX_Matrix m(0.947368443f, -0.108947366f, -0.923076928f,
+ 0.106153846f, 18.0f, 787.929993f);
CFX_Matrix rev = m.GetInverse();
EXPECT_FLOAT_EQ(14247728.0f, rev.a);
@@ -433,8 +433,8 @@
TEST(CFXMatrixTest, GetInverseCR714187) {
// The determinate is < std::numeric_limits<float>::epsilon()
- constexpr CFX_Matrix m(0.000037f, 0.0f, 0.0f, -0.000037f, 182.413101f,
- 136.977646f);
+ static constexpr CFX_Matrix m(0.000037f, 0.0f, 0.0f, -0.000037f, 182.413101f,
+ 136.977646f);
CFX_Matrix rev = m.GetInverse();
EXPECT_FLOAT_EQ(27027.025f, rev.a);
diff --git a/core/fxcrt/mask_unittest.cpp b/core/fxcrt/mask_unittest.cpp
index be4e492..a6c4873 100644
--- a/core/fxcrt/mask_unittest.cpp
+++ b/core/fxcrt/mask_unittest.cpp
@@ -32,7 +32,7 @@
"Mask size must be the same as enum");
TEST(Mask, Empty) {
- constexpr Mask<Privilege> privs;
+ static constexpr Mask<Privilege> privs;
EXPECT_EQ(0u, privs.UncheckedValue());
EXPECT_FALSE(privs & Privilege::kPriv1);
EXPECT_FALSE(privs & Privilege::kPriv4);
diff --git a/core/fxge/cfx_fontmapper_unittest.cpp b/core/fxge/cfx_fontmapper_unittest.cpp
index cdb1589..2c50c0f 100644
--- a/core/fxge/cfx_fontmapper_unittest.cpp
+++ b/core/fxge/cfx_fontmapper_unittest.cpp
@@ -200,8 +200,8 @@
// Regression test for crbug.com/1372234 - should not crash.
TEST_F(CFXFontMapperSystemFontInfoTest, GetCachedTTCFaceFailToGetData) {
void* const kFontHandle = reinterpret_cast<void*>(12345);
- constexpr size_t kTtcSize = 1024;
- constexpr size_t kDataSize = 2;
+ static constexpr size_t kTtcSize = 1024;
+ static constexpr size_t kDataSize = 2;
{
InSequence s;
@@ -222,10 +222,10 @@
// Regression test for crbug.com/1372234 - should not crash.
TEST_F(CFXFontMapperSystemFontInfoTest, GetCachedFaceFailToGetData) {
void* const kFontHandle = reinterpret_cast<void*>(12345);
- constexpr char kSubstName[] = "dummy_font";
- constexpr int kWeight = 400;
- constexpr bool kItalic = false;
- constexpr size_t kDataSize = 2;
+ static constexpr char kSubstName[] = "dummy_font";
+ static constexpr int kWeight = 400;
+ static constexpr bool kItalic = false;
+ static constexpr size_t kDataSize = 2;
EXPECT_CALL(system_font_info(), GetFontData(kFontHandle, 0, _))
.WillOnce(Return(0));
diff --git a/core/fxge/dib/cfx_cmyk_to_srgb_unittest.cpp b/core/fxge/dib/cfx_cmyk_to_srgb_unittest.cpp
index 583bf5a..1e50a7a 100644
--- a/core/fxge/dib/cfx_cmyk_to_srgb_unittest.cpp
+++ b/core/fxge/dib/cfx_cmyk_to_srgb_unittest.cpp
@@ -17,8 +17,8 @@
// Testing all floats from 0.0 to 1.0 takes about 35 seconds in release
// builds and much longer in debug builds, so just test the known-dangerous
// range.
- constexpr float kStartValue = 0.001f;
- constexpr float kEndValue = 0.003f;
+ static constexpr float kStartValue = 0.001f;
+ static constexpr float kEndValue = 0.003f;
FX_RGB_STRUCT<float> rgb;
// Iterate through floats by incrementing the representation, as discussed in
// https://randomascii.wordpress.com/2012/01/23/stupid-float-tricks-2/
diff --git a/core/fxge/dib/cfx_scanlinecompositor_unittest.cpp b/core/fxge/dib/cfx_scanlinecompositor_unittest.cpp
index 6181e55..7fb996e 100644
--- a/core/fxge/dib/cfx_scanlinecompositor_unittest.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor_unittest.cpp
@@ -118,7 +118,7 @@
/*blend_type=*/BlendMode::kNormal,
/*bRgbByteOrder=*/false));
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
{.blue = 255, .green = 100, .red = 0, .alpha = 0},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -129,7 +129,7 @@
{.blue = 255, .green = 100, .red = 0, .alpha = 244},
};
RunTest(compositor, kSrcScan1, kExpectations1);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
{.blue = 100, .green = 0, .red = 255, .alpha = 0},
{.blue = 100, .green = 0, .red = 255, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -140,7 +140,7 @@
{.blue = 127, .green = 18, .red = 209, .alpha = 244},
};
RunTest(compositor, kSrcScan2, kExpectations2);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
{.blue = 0, .green = 255, .red = 100, .alpha = 0},
{.blue = 0, .green = 255, .red = 100, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -162,7 +162,7 @@
/*blend_type=*/BlendMode::kDarken,
/*bRgbByteOrder=*/false));
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
{.blue = 255, .green = 100, .red = 0, .alpha = 0},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -173,7 +173,7 @@
{.blue = 255, .green = 100, .red = 0, .alpha = 244},
};
RunTest(compositor, kSrcScan1, kExpectations1);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
{.blue = 100, .green = 0, .red = 255, .alpha = 0},
{.blue = 100, .green = 0, .red = 255, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -184,7 +184,7 @@
{.blue = 127, .green = 18, .red = 45, .alpha = 244},
};
RunTest(compositor, kSrcScan2, kExpectations2);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
{.blue = 0, .green = 255, .red = 100, .alpha = 0},
{.blue = 0, .green = 255, .red = 100, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -206,7 +206,7 @@
/*blend_type=*/BlendMode::kHue,
/*bRgbByteOrder=*/false));
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
{.blue = 255, .green = 100, .red = 0, .alpha = 0},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -217,7 +217,7 @@
{.blue = 255, .green = 100, .red = 0, .alpha = 244},
};
RunTest(compositor, kSrcScan1, kExpectations1);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
{.blue = 100, .green = 0, .red = 255, .alpha = 0},
{.blue = 100, .green = 0, .red = 255, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -228,7 +228,7 @@
{.blue = 127, .green = 18, .red = 209, .alpha = 244},
};
RunTest(compositor, kSrcScan2, kExpectations2);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
{.blue = 0, .green = 255, .red = 100, .alpha = 0},
{.blue = 0, .green = 255, .red = 100, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -251,7 +251,7 @@
/*blend_type=*/BlendMode::kNormal,
/*bRgbByteOrder=*/false));
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -262,7 +262,7 @@
{.blue = 253, .green = 98, .red = 0, .alpha = 244},
};
RunPreMultiplyTest(compositor, kSrcScan1, kExpectations1);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 100, .green = 0, .red = 255, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -273,7 +273,7 @@
{.blue = 126, .green = 16, .red = 209, .alpha = 244},
};
RunPreMultiplyTest(compositor, kSrcScan2, kExpectations2);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 0, .green = 255, .red = 100, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -295,7 +295,7 @@
/*blend_type=*/BlendMode::kDarken,
/*bRgbByteOrder=*/false));
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -306,7 +306,7 @@
{.blue = 252, .green = 98, .red = 0, .alpha = 244},
};
RunPreMultiplyTest(compositor, kSrcScan1, kExpectations1);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 100, .green = 0, .red = 255, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -317,7 +317,7 @@
{.blue = 125, .green = 16, .red = 44, .alpha = 244},
};
RunPreMultiplyTest(compositor, kSrcScan2, kExpectations2);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 0, .green = 255, .red = 100, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -339,7 +339,7 @@
/*blend_type=*/BlendMode::kHue,
/*bRgbByteOrder=*/false));
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations1[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -350,7 +350,7 @@
{.blue = 252, .green = 98, .red = 0, .alpha = 244},
};
RunPreMultiplyTest(compositor, kSrcScan1, kExpectations1);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations2[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 100, .green = 0, .red = 255, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
@@ -361,7 +361,7 @@
{.blue = 125, .green = 16, .red = 207, .alpha = 244},
};
RunPreMultiplyTest(compositor, kSrcScan2, kExpectations2);
- constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
+ static constexpr FX_BGRA_STRUCT<uint8_t> kExpectations3[] = {
{.blue = 0, .green = 0, .red = 0, .alpha = 0},
{.blue = 0, .green = 255, .red = 100, .alpha = 255},
{.blue = 255, .green = 100, .red = 0, .alpha = 255},
diff --git a/core/fxge/dib/cstretchengine_unittest.cpp b/core/fxge/dib/cstretchengine_unittest.cpp
index d11ac9d..d85a577 100644
--- a/core/fxge/dib/cstretchengine_unittest.cpp
+++ b/core/fxge/dib/cstretchengine_unittest.cpp
@@ -30,7 +30,7 @@
void ExecuteOneStretchTest(int32_t dest_width,
int32_t src_width,
const FXDIB_ResampleOptions& options) {
- constexpr uint32_t kExpectedSum = CStretchEngine::kFixedPointOne;
+ static constexpr uint32_t kExpectedSum = CStretchEngine::kFixedPointOne;
CStretchEngine::WeightTable table;
ASSERT_TRUE(table.CalculateWeights(dest_width, 0, dest_width, src_width, 0,
src_width, options));
@@ -43,7 +43,7 @@
void ExecuteOneReversedStretchTest(int32_t dest_width,
int32_t src_width,
const FXDIB_ResampleOptions& options) {
- constexpr uint32_t kExpectedSum = CStretchEngine::kFixedPointOne;
+ static constexpr uint32_t kExpectedSum = CStretchEngine::kFixedPointOne;
CStretchEngine::WeightTable table;
ASSERT_TRUE(table.CalculateWeights(-dest_width, 0, dest_width, src_width, 0,
src_width, options));
@@ -56,8 +56,8 @@
void ExecuteStretchTests(const FXDIB_ResampleOptions& options) {
// Can't test everything, few random values chosen.
- constexpr int32_t kDestWidths[] = {1, 2, 337, 512, 808, 2550};
- constexpr int32_t kSrcWidths[] = {1, 2, 187, 256, 809, 1110};
+ static constexpr int32_t kDestWidths[] = {1, 2, 337, 512, 808, 2550};
+ static constexpr int32_t kSrcWidths[] = {1, 2, 187, 256, 809, 1110};
for (int32_t src_width : kSrcWidths) {
for (int32_t dest_width : kDestWidths) {
ExecuteOneStretchTest(dest_width, src_width, options);
diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp
index 76e3190..38ecec0 100644
--- a/core/fxge/skia/fx_skia_device_embeddertest.cpp
+++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp
@@ -149,8 +149,8 @@
void Harness(void (*Test)(CFX_SkiaDeviceDriver*, const State&),
const State& state) {
- constexpr int kWidth = 4;
- constexpr int kHeight = 1;
+ static constexpr int kWidth = 4;
+ static constexpr int kHeight = 1;
ScopedFPDFBitmap bitmap(FPDFBitmap_Create(kWidth, kHeight, 1));
ASSERT_TRUE(bitmap);
ASSERT_TRUE(
diff --git a/core/fxge/win32/cfx_psrenderer_unittest.cpp b/core/fxge/win32/cfx_psrenderer_unittest.cpp
index 50b027e..4add9a3 100644
--- a/core/fxge/win32/cfx_psrenderer_unittest.cpp
+++ b/core/fxge/win32/cfx_psrenderer_unittest.cpp
@@ -48,7 +48,7 @@
result = CFX_PSRenderer::GenerateType42SfntDataForTesting("empty", {});
EXPECT_FALSE(result.has_value());
- constexpr uint8_t kOddByteCountTestData[] = {0, 32, 55};
+ static constexpr uint8_t kOddByteCountTestData[] = {0, 32, 55};
static constexpr char kExpectedOddByteCountResult[] = R"(/odd_sfnts [
<
002037
@@ -61,7 +61,7 @@
EXPECT_EQ(kExpectedOddByteCountResult, result.value());
// Requires padding.
- constexpr uint8_t kEvenByteCountTestData[] = {0, 32, 66, 77};
+ static constexpr uint8_t kEvenByteCountTestData[] = {0, 32, 66, 77};
static constexpr char kExpectedEvenByteCountResult[] = R"(/even_sfnts [
<
0020424D00
@@ -194,8 +194,8 @@
auto output_stream = pdfium::MakeRetain<TestWriteStream>();
{
- constexpr int kWidth = 10;
- constexpr int kHeight = 2;
+ static constexpr int kWidth = 10;
+ static constexpr int kHeight = 2;
CFX_PSFontTracker font_tracker;
const EncoderIface encoder_interface{&FakeA85Encode, nullptr, nullptr,
nullptr, nullptr};
diff --git a/fpdfsdk/cpdfsdk_helpers_unittest.cpp b/fpdfsdk/cpdfsdk_helpers_unittest.cpp
index ba1b4ff..0118ed5 100644
--- a/fpdfsdk/cpdfsdk_helpers_unittest.cpp
+++ b/fpdfsdk/cpdfsdk_helpers_unittest.cpp
@@ -16,7 +16,7 @@
TEST(CPDFSDKHelpersTest, NulTerminateMaybeCopyAndReturnLength) {
{
const ByteString to_be_copied("toBeCopied");
- constexpr size_t kExpectedToBeCopiedLen = 10;
+ static constexpr size_t kExpectedToBeCopiedLen = 10;
ASSERT_EQ(kExpectedToBeCopiedLen, to_be_copied.GetLength());
EXPECT_EQ(kExpectedToBeCopiedLen + 1,
NulTerminateMaybeCopyAndReturnLength(to_be_copied,
diff --git a/fpdfsdk/fpdf_annot_embeddertest.cpp b/fpdfsdk/fpdf_annot_embeddertest.cpp
index 9244a04..60889e0 100644
--- a/fpdfsdk/fpdf_annot_embeddertest.cpp
+++ b/fpdfsdk/fpdf_annot_embeddertest.cpp
@@ -666,7 +666,7 @@
}
EXPECT_EQ(0, FPDFPage_GetAnnotCount(page.get()));
- constexpr char kUri[] = "https://pdfium.org/";
+ static constexpr char kUri[] = "https://pdfium.org/";
{
// Add a link annotation to the page and set its URI.
@@ -1415,7 +1415,7 @@
CompareBitmap(bitmap.get(), 595, 842, AnnotationStampWithApChecksum());
}
- constexpr int kBitmapSize = 200;
+ static constexpr int kBitmapSize = 200;
FPDF_BITMAP image_bitmap;
{
@@ -3127,7 +3127,7 @@
// Make links and highlights focusable.
static constexpr FPDF_ANNOTATION_SUBTYPE kSubTypes[] = {FPDF_ANNOT_LINK,
FPDF_ANNOT_HIGHLIGHT};
- constexpr int kSubTypesCount = std::size(kSubTypes);
+ static constexpr int kSubTypesCount = std::size(kSubTypes);
ASSERT_TRUE(
FPDFAnnot_SetFocusableSubtypes(form_handle(), kSubTypes, kSubTypesCount));
ASSERT_EQ(kSubTypesCount, FPDFAnnot_GetFocusableSubtypesCount(form_handle()));
@@ -3195,7 +3195,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
{
- constexpr char kExpectedResult[] =
+ static constexpr char kExpectedResult[] =
"https://cs.chromium.org/chromium/src/third_party/pdfium/public/"
"fpdf_text.h";
diff --git a/fpdfsdk/fpdf_attachment_embeddertest.cpp b/fpdfsdk/fpdf_attachment_embeddertest.cpp
index e87461f..66799ef 100644
--- a/fpdfsdk/fpdf_attachment_embeddertest.cpp
+++ b/fpdfsdk/fpdf_attachment_embeddertest.cpp
@@ -148,7 +148,7 @@
EXPECT_FALSE(FPDFAttachment_SetFile(attachment, document(), nullptr, 10));
// Set the new attachment's file.
- constexpr char kContents1[] = "Hello!";
+ static constexpr char kContents1[] = "Hello!";
EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents1,
strlen(kContents1)));
EXPECT_EQ(3, FPDFDoc_GetAttachmentCount(document()));
@@ -175,7 +175,7 @@
file_name = GetFPDFWideString(L"z.txt");
attachment = FPDFDoc_AddAttachment(document(), file_name.get());
ASSERT_TRUE(attachment);
- constexpr char kContents2[] = "World!";
+ static constexpr char kContents2[] = "World!";
EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents2,
strlen(kContents2)));
EXPECT_EQ(4, FPDFDoc_GetAttachmentCount(document()));
@@ -209,18 +209,18 @@
FPDF_ATTACHMENT attachment =
FPDFDoc_AddAttachment(document(), file_name.get());
ASSERT_TRUE(attachment);
- constexpr char kContents[] = "Hello World!";
+ static constexpr char kContents[] = "Hello World!";
EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents,
strlen(kContents)));
// Set the date to be an arbitrary value.
- constexpr wchar_t kDateW[] = L"D:20170720161527-04'00'";
+ static constexpr wchar_t kDateW[] = L"D:20170720161527-04'00'";
ScopedFPDFWideString ws_date = GetFPDFWideString(kDateW);
EXPECT_TRUE(
FPDFAttachment_SetStringValue(attachment, kDateKey, ws_date.get()));
// Set the checksum to be an arbitrary value.
- constexpr wchar_t kCheckSumW[] = L"<ABCDEF01234567899876543210FEDCBA>";
+ static constexpr wchar_t kCheckSumW[] = L"<ABCDEF01234567899876543210FEDCBA>";
ScopedFPDFWideString ws_checksum = GetFPDFWideString(kCheckSumW);
EXPECT_TRUE(FPDFAttachment_SetStringValue(attachment, kChecksumKey,
ws_checksum.get()));
@@ -288,7 +288,7 @@
ASSERT_TRUE(attachment);
// Set the new attachment's file.
- constexpr char kContents1[] = "Hello!";
+ static constexpr char kContents1[] = "Hello!";
EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents1,
strlen(kContents1)));
EXPECT_EQ(1, FPDFDoc_GetAttachmentCount(document()));
@@ -315,7 +315,7 @@
file_name = GetFPDFWideString(L"z.txt");
attachment = FPDFDoc_AddAttachment(document(), file_name.get());
ASSERT_TRUE(attachment);
- constexpr char kContents2[] = "World!";
+ static constexpr char kContents2[] = "World!";
EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents2,
strlen(kContents2)));
EXPECT_EQ(2, FPDFDoc_GetAttachmentCount(document()));
@@ -376,7 +376,7 @@
// The checksum key is a name, which violates the spec. This will still return
// the value, but should not crash.
- constexpr unsigned long kExpectedLength = 8u;
+ static constexpr unsigned long kExpectedLength = 8u;
ASSERT_EQ(kExpectedLength, FPDFAttachment_GetStringValue(
attachment, kChecksumKey, nullptr, 0));
std::vector<FPDF_WCHAR> buf = GetFPDFWideStringBuffer(kExpectedLength);
@@ -394,7 +394,7 @@
ASSERT_TRUE(attachment);
// The checksum key is a stream, while the API requires a string or name.
- constexpr unsigned long kExpectedLength = 2u;
+ static constexpr unsigned long kExpectedLength = 2u;
ASSERT_EQ(kExpectedLength, FPDFAttachment_GetStringValue(
attachment, kChecksumKey, nullptr, 0));
std::vector<FPDF_WCHAR> buf = GetFPDFWideStringBuffer(kExpectedLength);
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp
index 49c8cd8..e6547a5 100644
--- a/fpdfsdk/fpdf_doc_embeddertest.cpp
+++ b/fpdfsdk/fpdf_doc_embeddertest.cpp
@@ -798,7 +798,7 @@
TEST_F(FPDFDocEmbedderTest, GetFileIdentifier) {
ASSERT_TRUE(OpenDocument("split_streams.pdf"));
- constexpr size_t kMd5Length = 17;
+ static constexpr size_t kMd5Length = 17;
char buf[kMd5Length];
EXPECT_EQ(0u,
FPDF_GetFileIdentifier(document(), static_cast<FPDF_FILEIDTYPE>(-1),
@@ -811,13 +811,13 @@
EXPECT_EQ(kMd5Length, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT,
nullptr, 0));
- constexpr char kExpectedPermanent[] =
+ static constexpr char kExpectedPermanent[] =
"\xF3\x41\xAE\x65\x4A\x77\xAC\xD5\x06\x5A\x76\x45\xE5\x96\xE6\xE6";
ASSERT_EQ(kMd5Length, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT,
buf, sizeof(buf)));
EXPECT_EQ(kExpectedPermanent, ByteString(buf));
- constexpr char kExpectedChanging[] =
+ static constexpr char kExpectedChanging[] =
"\xBC\x37\x29\x8A\x3F\x87\xF4\x79\x22\x9B\xCE\x99\x7C\xA7\x91\xF7";
ASSERT_EQ(kMd5Length, FPDF_GetFileIdentifier(document(), FILEIDTYPE_CHANGING,
buf, sizeof(buf)));
@@ -828,12 +828,12 @@
ASSERT_TRUE(OpenDocument("non_hex_file_id.pdf"));
char buf[18];
- constexpr char kPermanentNonHex[] = "permanent non-hex";
+ static constexpr char kPermanentNonHex[] = "permanent non-hex";
ASSERT_EQ(18u, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT, buf,
sizeof(buf)));
EXPECT_EQ(kPermanentNonHex, ByteString(buf));
- constexpr char kChangingNonHex[] = "changing non-hex";
+ static constexpr char kChangingNonHex[] = "changing non-hex";
ASSERT_EQ(17u, FPDF_GetFileIdentifier(document(), FILEIDTYPE_CHANGING, buf,
sizeof(buf)));
EXPECT_EQ(kChangingNonHex, ByteString(buf));
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 3f918fb..f57902a 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -1400,7 +1400,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjectCount = 4;
+ static constexpr int kExpectedObjectCount = 4;
ASSERT_EQ(kExpectedObjectCount, FPDFPage_CountObjects(page.get()));
for (int i = 0; i < kExpectedObjectCount; ++i) {
FPDF_PAGEOBJECT page_object = FPDFPage_GetObject(page.get(), i);
@@ -1454,7 +1454,7 @@
CompareBitmap(page_bitmap.get(), 200, 200, original_checksum);
}
- constexpr int expected_object_count = 19;
+ static constexpr int expected_object_count = 19;
CheckMarkCounts(page.get(), 1, expected_object_count, 8, 4, 9, 1);
// Get all objects marked with "Prime"
@@ -1556,7 +1556,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjectCount = 19;
+ static constexpr int kExpectedObjectCount = 19;
CheckMarkCounts(page.get(), 1, kExpectedObjectCount, 8, 4, 9, 1);
// Remove all "Prime" content marks.
@@ -1608,7 +1608,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjectCount = 19;
+ static constexpr int kExpectedObjectCount = 19;
CheckMarkCounts(page.get(), 1, kExpectedObjectCount, 8, 4, 9, 1);
// Remove all "Square" content marks parameters.
@@ -2969,7 +2969,7 @@
{
// FPDFFont_GetFontData() positive testing.
- constexpr size_t kExpectedSize = 8268;
+ static constexpr size_t kExpectedSize = 8268;
std::vector<uint8_t> buf;
size_t buf_bytes_required = 123;
ASSERT_TRUE(FPDFFont_GetFontData(font, nullptr, 0, &buf_bytes_required));
@@ -3024,7 +3024,7 @@
// Since hello_world.pdf does not embed any font data, FPDFFont_GetFontData()
// will return the substitution font data. Since pdfium_embeddertest is
// hermetic, this first object consistently maps to Tinos-Regular.ttf.
- constexpr size_t kTinosRegularSize = 469968;
+ static constexpr size_t kTinosRegularSize = 469968;
FPDF_PAGEOBJECT text = FPDFPage_GetObject(page.get(), 0);
ASSERT_TRUE(text);
FPDF_FONT font = FPDFTextObj_GetFont(text);
@@ -3039,7 +3039,7 @@
EXPECT_EQ(0, FPDFFont_GetIsEmbedded(font));
// Similarly, the second object consistently maps to Arimo-Regular.ttf.
- constexpr size_t kArimoRegularSize = 436180;
+ static constexpr size_t kArimoRegularSize = 436180;
text = FPDFPage_GetObject(page.get(), 1);
ASSERT_TRUE(text);
font = FPDFTextObj_GetFont(text);
@@ -3934,7 +3934,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjectCount = 19;
+ static constexpr int kExpectedObjectCount = 19;
CheckMarkCounts(page.get(), 1, kExpectedObjectCount, 8, 4, 9, 1);
// Check the "Bounds" mark's "Position" param is "Last".
@@ -4028,7 +4028,8 @@
// - blob "BlobKey": "\x01\x02\x03\0BlobValue1\0\0\0BlobValue2\0"
//
// Note that the trailing NUL is in `kBlobData` implicitly.
- constexpr uint8_t kBlobData[] = "\x01\x02\x03\0BlobValue1\0\0\0BlobValue2";
+ static constexpr uint8_t kBlobData[] =
+ "\x01\x02\x03\0BlobValue1\0\0\0BlobValue2";
EXPECT_EQ(0, FPDFPageObjMark_CountParams(mark));
EXPECT_TRUE(
FPDFPageObjMark_SetIntParam(document(), text_object, mark, "IntKey", 42));
@@ -4058,7 +4059,7 @@
EXPECT_EQ(FPDF_OBJECT_STRING,
FPDFPageObjMark_GetParamValueType(mark, "BlobKey"));
out_buffer_len = 0;
- constexpr size_t kBlobLen = 28;
+ static constexpr size_t kBlobLen = 28;
unsigned char blob_buffer[kBlobLen];
EXPECT_TRUE(FPDFPageObjMark_GetParamBlobValue(
mark, "BlobKey", blob_buffer, sizeof(blob_buffer), &out_buffer_len));
@@ -4427,7 +4428,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjects = 4;
+ static constexpr int kExpectedObjects = 4;
ASSERT_EQ(kExpectedObjects, FPDFPage_CountObjects(page.get()));
for (int i = 0; i < kExpectedObjects; ++i) {
@@ -4446,7 +4447,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjects = 2;
+ static constexpr int kExpectedObjects = 2;
ASSERT_EQ(kExpectedObjects, FPDFPage_CountObjects(page.get()));
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page.get(), 1);
ASSERT_EQ(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj));
@@ -4517,7 +4518,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedObjects = 4;
+ static constexpr int kExpectedObjects = 4;
ASSERT_EQ(kExpectedObjects, FPDFPage_CountObjects(page.get()));
const char* smask_checksum = []() {
@@ -5096,8 +5097,8 @@
ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100));
EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
- constexpr int kBitmapWidth = 50;
- constexpr int kBitmapHeight = 100;
+ static constexpr int kBitmapWidth = 50;
+ static constexpr int kBitmapHeight = 100;
ScopedFPDFBitmap bitmap(FPDFBitmap_Create(kBitmapWidth, kBitmapHeight, 0));
ASSERT_TRUE(FPDFBitmap_FillRect(bitmap.get(), 0, 0, kBitmapWidth,
kBitmapHeight, 0x00000000));
@@ -5106,8 +5107,8 @@
FPDFImageObj_SetBitmap(nullptr, 0, page_image.get(), bitmap.get()));
// Set bitmap matrix with scaling and 90 degrees clockwise rotation.
- constexpr int kScaleX = 2;
- constexpr int kScaleY = 3;
+ static constexpr int kScaleX = 2;
+ static constexpr int kScaleY = 3;
static constexpr FS_MATRIX kBitmapMatrix{
0, -kScaleX * kBitmapWidth, kScaleY * kBitmapHeight, 0, 0, 0};
ASSERT_TRUE(FPDFPageObj_SetMatrix(page_image.get(), &kBitmapMatrix));
@@ -5155,8 +5156,8 @@
}
TEST_F(FPDFEditEmbedderTest, GetAndSetMatrixForFormWithText) {
- constexpr int kExpectedWidth = 200;
- constexpr int kExpectedHeight = 200;
+ static constexpr int kExpectedWidth = 200;
+ static constexpr int kExpectedHeight = 200;
OpenDocument("form_object_with_text.pdf");
ScopedEmbedderTestPage page = LoadScopedPage(0);
diff --git a/fpdfsdk/fpdf_editimg_embeddertest.cpp b/fpdfsdk/fpdf_editimg_embeddertest.cpp
index 0f26b12..67574ed 100644
--- a/fpdfsdk/fpdf_editimg_embeddertest.cpp
+++ b/fpdfsdk/fpdf_editimg_embeddertest.cpp
@@ -40,7 +40,7 @@
ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100));
EXPECT_EQ(0, FPDFPage_CountObjects(page.get()));
- constexpr int kBitmapSize = 50;
+ static constexpr int kBitmapSize = 50;
ScopedFPDFBitmap bitmap(FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0));
ASSERT_TRUE(FPDFBitmap_FillRect(bitmap.get(), 0, 0, kBitmapSize, kBitmapSize,
0x00000000));
@@ -61,8 +61,8 @@
TEST_F(PDFEditImgTest, NewImageObjLoadJpeg) {
CreateEmptyDocumentWithoutFormFillEnvironment();
- constexpr int kPageWidth = 200;
- constexpr int kPageHeight = 200;
+ static constexpr int kPageWidth = 200;
+ static constexpr int kPageHeight = 200;
ScopedFPDFPage page(FPDFPage_New(document(), 0, kPageWidth, kPageHeight));
ASSERT_TRUE(page);
@@ -74,8 +74,8 @@
EXPECT_TRUE(
FPDFImageObj_LoadJpegFile(&temp_page, 1, image.get(), &file_access));
- constexpr int kImageWidth = 120;
- constexpr int kImageHeight = 120;
+ static constexpr int kImageWidth = 120;
+ static constexpr int kImageHeight = 120;
const char kImageChecksum[] = "58589c36b3b27a0058f5ca1fbed4d5e5";
const char kPageChecksum[] = "52b3a852f39c5fa9143e59d805dcb343";
{
@@ -98,8 +98,8 @@
TEST_F(PDFEditImgTest, NewImageObjLoadJpegInline) {
CreateEmptyDocumentWithoutFormFillEnvironment();
- constexpr int kPageWidth = 200;
- constexpr int kPageHeight = 200;
+ static constexpr int kPageWidth = 200;
+ static constexpr int kPageHeight = 200;
ScopedFPDFPage page(FPDFPage_New(document(), 0, kPageWidth, kPageHeight));
ASSERT_TRUE(page);
@@ -111,8 +111,8 @@
EXPECT_TRUE(FPDFImageObj_LoadJpegFileInline(&temp_page, 1, image.get(),
&file_access));
- constexpr int kImageWidth = 120;
- constexpr int kImageHeight = 120;
+ static constexpr int kImageWidth = 120;
+ static constexpr int kImageHeight = 120;
const char kImageChecksum[] = "58589c36b3b27a0058f5ca1fbed4d5e5";
const char kPageChecksum[] = "52b3a852f39c5fa9143e59d805dcb343";
{
@@ -176,9 +176,10 @@
}
TEST_F(PDFEditImgTest, Bug2132) {
- constexpr int kExpectedWidth = 200;
- constexpr int kExpectedHeight = 300;
- constexpr char kExpectedChecksum[] = "617b1d57c30c516beee86e0781ff7810";
+ static constexpr int kExpectedWidth = 200;
+ static constexpr int kExpectedHeight = 300;
+ static constexpr char kExpectedChecksum[] =
+ "617b1d57c30c516beee86e0781ff7810";
OpenDocument("bug_2132.pdf");
ScopedEmbedderTestPage page = LoadScopedPage(0);
@@ -224,9 +225,10 @@
}
TEST_F(PDFEditImgTest, GetAndSetMatrixForFormWithImage) {
- constexpr int kExpectedWidth = 200;
- constexpr int kExpectedHeight = 300;
- constexpr char kExpectedChecksum[] = "fcb9007fd901d2052e2bd1c147b82800";
+ static constexpr int kExpectedWidth = 200;
+ static constexpr int kExpectedHeight = 300;
+ static constexpr char kExpectedChecksum[] =
+ "fcb9007fd901d2052e2bd1c147b82800";
OpenDocument("form_object_with_image.pdf");
ScopedEmbedderTestPage page = LoadScopedPage(0);
diff --git a/fpdfsdk/fpdf_editpage_embeddertest.cpp b/fpdfsdk/fpdf_editpage_embeddertest.cpp
index 1741afa..54e2f59 100644
--- a/fpdfsdk/fpdf_editpage_embeddertest.cpp
+++ b/fpdfsdk/fpdf_editpage_embeddertest.cpp
@@ -83,7 +83,7 @@
}
TEST_F(FPDFEditPageEmbedderTest, HasTransparencyImage) {
- constexpr int kExpectedObjectCount = 39;
+ static constexpr int kExpectedObjectCount = 39;
ASSERT_TRUE(OpenDocument("embedded_images.pdf"));
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
@@ -103,7 +103,7 @@
}
TEST_F(FPDFEditPageEmbedderTest, HasTransparencyPath) {
- constexpr int kExpectedObjectCount = 8;
+ static constexpr int kExpectedObjectCount = 8;
ASSERT_TRUE(OpenDocument("rectangles.pdf"));
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
@@ -119,7 +119,7 @@
}
TEST_F(FPDFEditPageEmbedderTest, HasTransparencyText) {
- constexpr int kExpectedObjectCount = 2;
+ static constexpr int kExpectedObjectCount = 2;
ASSERT_TRUE(OpenDocument("text_render_mode.pdf"));
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
@@ -135,8 +135,8 @@
}
TEST_F(FPDFEditPageEmbedderTest, GetFillAndStrokeForImage) {
- constexpr int kExpectedObjectCount = 39;
- constexpr int kImageObjectsStartIndex = 33;
+ static constexpr int kExpectedObjectCount = 39;
+ static constexpr int kImageObjectsStartIndex = 33;
ASSERT_TRUE(OpenDocument("embedded_images.pdf"));
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
@@ -182,7 +182,7 @@
set_array.size(), 5.0f));
}
- constexpr int kExpectedObjectCount = 3;
+ static constexpr int kExpectedObjectCount = 3;
ASSERT_TRUE(OpenDocument("dashed_lines.pdf"));
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
@@ -317,10 +317,10 @@
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page.get(), 0);
ASSERT_EQ(FPDF_PAGEOBJ_TEXT, FPDFPageObj_GetType(obj));
- constexpr float kExpectedLeft = 20.348f;
- constexpr float kExpectedBottom = 48.164f;
- constexpr float kExpectedRight = 83.36f;
- constexpr float kExpectedTop = 58.328f;
+ static constexpr float kExpectedLeft = 20.348f;
+ static constexpr float kExpectedBottom = 48.164f;
+ static constexpr float kExpectedRight = 83.36f;
+ static constexpr float kExpectedTop = 58.328f;
float left;
float bottom;
@@ -352,10 +352,10 @@
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page.get(), 0);
ASSERT_EQ(FPDF_PAGEOBJ_TEXT, FPDFPageObj_GetType(obj));
- constexpr float kExpectedLeft = 98.9478f;
- constexpr float kExpectedBottom = 78.2607f;
- constexpr float kExpectedRight = 126.32983f;
- constexpr float kExpectedTop = 105.64272f;
+ static constexpr float kExpectedLeft = 98.9478f;
+ static constexpr float kExpectedBottom = 78.2607f;
+ static constexpr float kExpectedRight = 126.32983f;
+ static constexpr float kExpectedTop = 105.64272f;
float left;
float bottom;
@@ -387,10 +387,10 @@
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page.get(), 2);
ASSERT_EQ(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj));
- constexpr float kExpectedLeft = 0.0f;
- constexpr float kExpectedBottom = 90.0f;
- constexpr float kExpectedRight = 40.0f;
- constexpr float kExpectedTop = 150.0f;
+ static constexpr float kExpectedLeft = 0.0f;
+ static constexpr float kExpectedBottom = 90.0f;
+ static constexpr float kExpectedRight = 40.0f;
+ static constexpr float kExpectedTop = 150.0f;
float left;
float bottom;
@@ -422,10 +422,10 @@
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page.get(), 0);
ASSERT_EQ(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj));
- constexpr float kExpectedLeft = 100.0f;
- constexpr float kExpectedBottom = 70.0f;
- constexpr float kExpectedRight = 170.0f;
- constexpr float kExpectedTop = 140.0f;
+ static constexpr float kExpectedLeft = 100.0f;
+ static constexpr float kExpectedBottom = 70.0f;
+ static constexpr float kExpectedRight = 170.0f;
+ static constexpr float kExpectedTop = 140.0f;
float left;
float bottom;
@@ -450,8 +450,8 @@
}
TEST_F(FPDFEditPageEmbedderTest, VerifyDashArraySaved) {
- constexpr float kDashArray[] = {2.5, 3.6};
- constexpr float kDashPhase = 1.2;
+ static constexpr float kDashArray[] = {2.5, 3.6};
+ static constexpr float kDashPhase = 1.2;
CreateEmptyDocument();
{
@@ -653,7 +653,7 @@
ASSERT_TRUE(page);
const int page_width = static_cast<int>(FPDF_GetPageWidth(page.get()));
const int page_height = static_cast<int>(FPDF_GetPageHeight(page.get()));
- constexpr int kOriginalObjectCount = 8;
+ static constexpr int kOriginalObjectCount = 8;
{
// Sanity check rectangles.pdf before modifying it.
ScopedFPDFBitmap bitmap = RenderLoadedPage(page.get());
@@ -663,7 +663,7 @@
}
// Add a new path.
- constexpr int kObjectCountWithNewPath = kOriginalObjectCount + 1;
+ static constexpr int kObjectCountWithNewPath = kOriginalObjectCount + 1;
ScopedFPDFPageObject path_wrapper(FPDFPageObj_CreateNewPath(50, 50));
FPDF_PAGEOBJECT path = path_wrapper.get();
ASSERT_TRUE(path);
diff --git a/fpdfsdk/fpdf_editpath_embeddertest.cpp b/fpdfsdk/fpdf_editpath_embeddertest.cpp
index b412a11..f295c23 100644
--- a/fpdfsdk/fpdf_editpath_embeddertest.cpp
+++ b/fpdfsdk/fpdf_editpath_embeddertest.cpp
@@ -38,7 +38,7 @@
} // namespace
TEST_F(FPDFEditPathEmbedderTest, VerifyCorrectColoursReturned) {
- constexpr int kObjectCount = 256;
+ static constexpr int kObjectCount = 256;
CreateEmptyDocument();
FPDF_PAGE page = FPDFPage_New(document(), 0, 612, 792);
diff --git a/fpdfsdk/fpdf_formfill_embeddertest.cpp b/fpdfsdk/fpdf_formfill_embeddertest.cpp
index ca23996..538387b 100644
--- a/fpdfsdk/fpdf_formfill_embeddertest.cpp
+++ b/fpdfsdk/fpdf_formfill_embeddertest.cpp
@@ -350,7 +350,7 @@
ClickOnFormFieldAtPoint(point);
// Calculate to Y-coordinate of dropdown option to be selected.
- constexpr double kChoiceHeight = 15;
+ static constexpr double kChoiceHeight = 15;
CFX_PointF option_point = point;
option_point.y -= kChoiceHeight * (item_index + 1);
@@ -716,7 +716,7 @@
EXPECT_FALSE(FORM_GetFocusedAnnot(form_handle(), nullptr, &annot));
const CFX_PointF right_bottom_annot_point(410.0f, 210.0f);
- constexpr int kExpectedAnnotIndex = 3;
+ static constexpr int kExpectedAnnotIndex = 3;
for (size_t i = 0; i < pages.size(); ++i) {
// Invoke click on the form field to bring it to focus.
@@ -757,7 +757,7 @@
EXPECT_FALSE(FORM_SetFocusedAnnot(nullptr, annot));
EXPECT_FALSE(FORM_SetFocusedAnnot(form_handle(), nullptr));
- constexpr int kExpectedAnnotIndex = 2;
+ static constexpr int kExpectedAnnotIndex = 2;
for (size_t i = 0; i < pages.size(); ++i) {
// Setting focus on an annotation on page i.
@@ -1639,9 +1639,9 @@
FPDFPage_HasFormFieldAtPoint(form_handle(), page.get(), 612, 792));
#ifdef PDF_ENABLE_XFA
- constexpr int kExpectedFieldType = FPDF_FORMFIELD_XFA_TEXTFIELD;
+ static constexpr int kExpectedFieldType = FPDF_FORMFIELD_XFA_TEXTFIELD;
#else
- constexpr int kExpectedFieldType = -1;
+ static constexpr int kExpectedFieldType = -1;
#endif
EXPECT_EQ(kExpectedFieldType,
FPDFPage_HasFormFieldAtPoint(form_handle(), page.get(), 50, 30));
@@ -3358,9 +3358,9 @@
// Select all with the keyboard shortcut.
#if BUILDFLAG(IS_APPLE)
- constexpr int kCorrectModifier = FWL_EVENTFLAG_MetaKey;
+ static constexpr int kCorrectModifier = FWL_EVENTFLAG_MetaKey;
#else
- constexpr int kCorrectModifier = FWL_EVENTFLAG_ControlKey;
+ static constexpr int kCorrectModifier = FWL_EVENTFLAG_ControlKey;
#endif
FORM_OnChar(form_handle(), page(), pdfium::ascii::kControlA,
kCorrectModifier);
@@ -3372,9 +3372,9 @@
// Select all with the keyboard shortcut using the wrong modifier key.
#if BUILDFLAG(IS_APPLE)
- constexpr int kWrongModifier = FWL_EVENTFLAG_ControlKey;
+ static constexpr int kWrongModifier = FWL_EVENTFLAG_ControlKey;
#else
- constexpr int kWrongModifier = FWL_EVENTFLAG_MetaKey;
+ static constexpr int kWrongModifier = FWL_EVENTFLAG_MetaKey;
#endif
FORM_OnChar(form_handle(), page(), pdfium::ascii::kControlA, kWrongModifier);
CheckSelection("");
@@ -3424,9 +3424,9 @@
ASSERT_TRUE(page_);
// Set Widget and Link as supported tabbable annots.
- constexpr FPDF_ANNOTATION_SUBTYPE kFocusableSubtypes[] = {FPDF_ANNOT_WIDGET,
- FPDF_ANNOT_LINK};
- constexpr size_t kSubtypeCount = std::size(kFocusableSubtypes);
+ static constexpr FPDF_ANNOTATION_SUBTYPE kFocusableSubtypes[] = {
+ FPDF_ANNOT_WIDGET, FPDF_ANNOT_LINK};
+ static constexpr size_t kSubtypeCount = std::size(kFocusableSubtypes);
ASSERT_TRUE(FPDFAnnot_SetFocusableSubtypes(
form_handle(), kFocusableSubtypes, kSubtypeCount));
}
diff --git a/fpdfsdk/fpdf_javascript_embeddertest.cpp b/fpdfsdk/fpdf_javascript_embeddertest.cpp
index 8810754..a366bf2 100644
--- a/fpdfsdk/fpdf_javascript_embeddertest.cpp
+++ b/fpdfsdk/fpdf_javascript_embeddertest.cpp
@@ -74,7 +74,7 @@
EXPECT_EQ(0u, FPDFJavaScriptAction_GetName(nullptr, buf, sizeof(buf)));
}
- constexpr size_t kExpectedLength = 22;
+ static constexpr size_t kExpectedLength = 22;
ASSERT_EQ(kExpectedLength,
FPDFJavaScriptAction_GetName(js.get(), nullptr, 0));
@@ -104,7 +104,7 @@
EXPECT_EQ(0u, FPDFJavaScriptAction_GetScript(nullptr, buf, sizeof(buf)));
}
- constexpr size_t kExpectedLength = 218;
+ static constexpr size_t kExpectedLength = 218;
ASSERT_EQ(kExpectedLength,
FPDFJavaScriptAction_GetScript(js.get(), nullptr, 0));
diff --git a/fpdfsdk/fpdf_ppo_embeddertest.cpp b/fpdfsdk/fpdf_ppo_embeddertest.cpp
index 0ab907b..1064cef 100644
--- a/fpdfsdk/fpdf_ppo_embeddertest.cpp
+++ b/fpdfsdk/fpdf_ppo_embeddertest.cpp
@@ -56,7 +56,7 @@
}
const char* Bug750568PageHash(int page_index) {
- constexpr int kBug750568PageCount = 4;
+ static constexpr int kBug750568PageCount = 4;
if (CFX_DefaultRenderDevice::UseSkiaRenderer()) {
static constexpr std::array<const char*, kBug750568PageCount> kChecksums = {
{"eaa139e944eafb43d31e8742a0e158de", "226485e9d4fa6a67dfe0a88723f12060",
@@ -223,7 +223,7 @@
FPDF_CloseXObject(xobject);
}
- constexpr int kExpectedPageCount = 2;
+ static constexpr int kExpectedPageCount = 2;
ASSERT_TRUE(OpenSavedDocument());
std::array<FPDF_PAGE, kExpectedPageCount> saved_pages;
diff --git a/fpdfsdk/fpdf_signature_embeddertest.cpp b/fpdfsdk/fpdf_signature_embeddertest.cpp
index 02ae801..1d36fa5 100644
--- a/fpdfsdk/fpdf_signature_embeddertest.cpp
+++ b/fpdfsdk/fpdf_signature_embeddertest.cpp
@@ -138,10 +138,10 @@
EXPECT_TRUE(signature);
// FPDFSignatureObj_GetReason() positive testing.
- constexpr char kReason[] = "test reason";
+ static constexpr char kReason[] = "test reason";
// Return value includes the terminating NUL that is provided.
- constexpr unsigned long kReasonUTF16Size = std::size(kReason) * 2;
- constexpr wchar_t kReasonWide[] = L"test reason";
+ static constexpr unsigned long kReasonUTF16Size = std::size(kReason) * 2;
+ static constexpr wchar_t kReasonWide[] = L"test reason";
unsigned long size = FPDFSignatureObj_GetReason(signature, nullptr, 0);
ASSERT_EQ(kReasonUTF16Size, size);
diff --git a/fpdfsdk/fpdf_structtree_embeddertest.cpp b/fpdfsdk/fpdf_structtree_embeddertest.cpp
index b455bde..d5591b4 100644
--- a/fpdfsdk/fpdf_structtree_embeddertest.cpp
+++ b/fpdfsdk/fpdf_structtree_embeddertest.cpp
@@ -132,7 +132,7 @@
FPDF_StructTree_GetChildAtIndex(struct_tree.get(), 0);
ASSERT_TRUE(document);
- constexpr int kBufLen = 100;
+ static constexpr int kBufLen = 100;
uint16_t buffer[kBufLen] = {0};
EXPECT_EQ(18U, FPDF_StructElement_GetType(document, buffer, kBufLen));
EXPECT_EQ("Document", GetPlatformString(buffer));
@@ -193,7 +193,7 @@
FPDF_StructTree_GetChildAtIndex(struct_tree.get(), 0);
ASSERT_TRUE(document);
- constexpr int kBufLen = 100;
+ static constexpr int kBufLen = 100;
uint16_t buffer[kBufLen] = {0};
EXPECT_EQ(18U, FPDF_StructElement_GetType(document, buffer, kBufLen));
EXPECT_EQ("Document", GetPlatformString(buffer));
@@ -231,7 +231,7 @@
FPDF_StructTree_GetChildAtIndex(struct_tree.get(), 0);
ASSERT_TRUE(document);
- constexpr int kBufLen = 100;
+ static constexpr int kBufLen = 100;
uint16_t buffer[kBufLen] = {0};
EXPECT_EQ(18U, FPDF_StructElement_GetType(document, buffer, kBufLen));
EXPECT_EQ("Document", GetPlatformString(buffer));
@@ -274,7 +274,7 @@
FPDF_StructTree_GetChildAtIndex(struct_tree.get(), 0);
ASSERT_TRUE(document);
- constexpr int kBufLen = 100;
+ static constexpr int kBufLen = 100;
uint16_t buffer[kBufLen] = {0};
EXPECT_EQ(18U, FPDF_StructElement_GetType(document, buffer, kBufLen));
EXPECT_EQ("Document", GetPlatformString(buffer));
diff --git a/fpdfsdk/fpdf_text_embeddertest.cpp b/fpdfsdk/fpdf_text_embeddertest.cpp
index bfd1bfe..16f4095 100644
--- a/fpdfsdk/fpdf_text_embeddertest.cpp
+++ b/fpdfsdk/fpdf_text_embeddertest.cpp
@@ -275,7 +275,7 @@
ScopedFPDFTextPage textpage(FPDFText_LoadPage(page.get()));
ASSERT_TRUE(textpage);
- constexpr int kCharCount = 10;
+ static constexpr int kCharCount = 10;
ASSERT_EQ(kCharCount, FPDFText_CountChars(textpage.get()));
unsigned short buffer[kCharCount + 1];
@@ -599,8 +599,8 @@
ASSERT_TRUE(textpage);
// Upper/lowercase 'a' with breve.
- constexpr FPDF_WCHAR kNeedleUpper[] = {0x0102, 0x0000};
- constexpr FPDF_WCHAR kNeedleLower[] = {0x0103, 0x0000};
+ static constexpr FPDF_WCHAR kNeedleUpper[] = {0x0102, 0x0000};
+ static constexpr FPDF_WCHAR kNeedleLower[] = {0x0103, 0x0000};
for (const auto* needle : {kNeedleUpper, kNeedleLower}) {
ScopedFPDFTextFind search(FPDFText_FindStart(textpage.get(), needle, 0, 0));
@@ -927,7 +927,7 @@
ScopedFPDFTextPage textpage(FPDFText_LoadPage(page.get()));
ASSERT_TRUE(textpage);
- constexpr auto kExpectedFontsSizes = fxcrt::ToArray<const double>(
+ static constexpr auto kExpectedFontsSizes = fxcrt::ToArray<const double>(
{12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16});
@@ -1092,7 +1092,7 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kExpectedCharCount = 5;
+ static constexpr int kExpectedCharCount = 5;
ScopedFPDFTextPage textpage(FPDFText_LoadPage(page.get()));
ASSERT_TRUE(textpage);
EXPECT_EQ(kExpectedCharCount, FPDFText_CountChars(textpage.get()));
@@ -1154,11 +1154,11 @@
// Expecting 'Veritaserum', except there is a \uFFFE where the hyphen was in
// the original text. This is a weird thing that Adobe does, which we
// replicate.
- constexpr auto soft_expected = fxcrt::ToArray<unsigned short>(
+ static constexpr auto soft_expected = fxcrt::ToArray<unsigned short>(
{0x0056, 0x0065, 0x0072, 0x0069, 0x0074, 0x0061, 0xfffe, 0x0073, 0x0065,
0x0072, 0x0075, 0x006D, 0x0000});
{
- constexpr int count = std::size(soft_expected) - 1;
+ static constexpr int count = std::size(soft_expected) - 1;
std::array<unsigned short, soft_expected.size()> buffer = {};
EXPECT_EQ(count + 1,
FPDFText_GetText(textpage.get(), 0, count, buffer.data()));
@@ -1169,13 +1169,13 @@
{
// There isn't the \0 in the actual doc, but there is a \r\n, so need to
// add 1 to get aligned.
- constexpr size_t offset = std::size(soft_expected) + 1;
+ static constexpr size_t offset = std::size(soft_expected) + 1;
// Expecting 'User-\r\ngenerated', the - is a unicode character, so cannot
// store in a char[].
- constexpr auto hard_expected = fxcrt::ToArray<unsigned short>(
+ static constexpr auto hard_expected = fxcrt::ToArray<unsigned short>(
{0x0055, 0x0073, 0x0065, 0x0072, 0x2010, 0x000d, 0x000a, 0x0067, 0x0065,
0x006e, 0x0065, 0x0072, 0x0061, 0x0074, 0x0065, 0x0064, 0x0000});
- constexpr int count = std::size(hard_expected) - 1;
+ static constexpr int count = std::size(hard_expected) - 1;
std::array<unsigned short, hard_expected.size()> buffer;
EXPECT_EQ(count + 1,
FPDFText_GetText(textpage.get(), offset, count, buffer.data()));
@@ -1233,8 +1233,8 @@
ScopedFPDFTextPage textpage(FPDFText_LoadPage(page.get()));
ASSERT_TRUE(textpage);
- constexpr int page_range_offset = 171;
- constexpr int page_range_length = 56;
+ static constexpr int page_range_offset = 171;
+ static constexpr int page_range_length = 56;
// This text is:
// 'METADATA table. When the split has committed, it noti' followed
@@ -1345,10 +1345,10 @@
ASSERT_TRUE(text_object);
// Positive testing.
- constexpr char kHelloText[] = "Hello, world!";
+ static constexpr char kHelloText[] = "Hello, world!";
// Return value includes the terminating NUL that is provided.
- constexpr unsigned long kHelloUTF16Size = std::size(kHelloText) * 2;
- constexpr wchar_t kHelloWideText[] = L"Hello, world!";
+ static constexpr unsigned long kHelloUTF16Size = std::size(kHelloText) * 2;
+ static constexpr wchar_t kHelloWideText[] = L"Hello, world!";
unsigned long size =
FPDFTextObj_GetText(text_object, text_page.get(), nullptr, 0);
ASSERT_EQ(kHelloUTF16Size, size);
@@ -1453,8 +1453,8 @@
ScopedFPDFTextPage text_page(FPDFText_LoadPage(page.get()));
ASSERT_TRUE(text_page);
- constexpr char kText[] = "ABCD";
- constexpr size_t kTextSize = std::size(kText);
+ static constexpr char kText[] = "ABCD";
+ static constexpr size_t kTextSize = std::size(kText);
// -1 for CountChars not including the \0
EXPECT_EQ(static_cast<int>(kTextSize) - 1,
FPDFText_CountChars(text_page.get()));
@@ -1614,9 +1614,9 @@
}
TEST_F(FPDFTextEmbedderTest, GetMatrix) {
- constexpr char kExpectedText[] = "A1\r\nA2\r\nA3";
- constexpr size_t kExpectedTextSize = std::size(kExpectedText);
- constexpr auto kExpectedMatrices = fxcrt::ToArray<const FS_MATRIX>({
+ static constexpr char kExpectedText[] = "A1\r\nA2\r\nA3";
+ static constexpr size_t kExpectedTextSize = std::size(kExpectedText);
+ static constexpr auto kExpectedMatrices = fxcrt::ToArray<const FS_MATRIX>({
{12.0f, 0.0f, 0.0f, 10.0f, 66.0f, 90.0f},
{12.0f, 0.0f, 0.0f, 10.0f, 66.0f, 90.0f},
{1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
@@ -1628,7 +1628,7 @@
{1.0f, 0.0f, 0.0f, 0.833333, 60.0f, 130.0f},
{1.0f, 0.0f, 0.0f, 0.833333, 60.0f, 130.0f},
});
- constexpr size_t kExpectedCount = std::size(kExpectedMatrices);
+ static constexpr size_t kExpectedCount = std::size(kExpectedMatrices);
static_assert(kExpectedCount + 1 == kExpectedTextSize,
"Bad expected matrix size");
@@ -1671,10 +1671,10 @@
TEST_F(FPDFTextEmbedderTest, CharBox) {
// For a size 12 letter 'A'.
- constexpr double kExpectedCharWidth = 8.460;
- constexpr double kExpectedCharHeight = 6.600;
- constexpr float kExpectedLooseCharWidth = 8.664f;
- constexpr float kExpectedLooseCharHeight = 12.0f;
+ static constexpr double kExpectedCharWidth = 8.460;
+ static constexpr double kExpectedCharHeight = 6.600;
+ static constexpr float kExpectedLooseCharWidth = 8.664f;
+ static constexpr float kExpectedLooseCharHeight = 12.0f;
ASSERT_TRUE(OpenDocument("font_matrix.pdf"));
ScopedEmbedderTestPage page = LoadScopedPage(0);
@@ -1767,7 +1767,7 @@
}
TEST_F(FPDFTextEmbedderTest, BigtableTextExtraction) {
- constexpr char kExpectedText[] =
+ static constexpr char kExpectedText[] =
"{fay,jeff,sanjay,wilsonh,kerr,m3b,tushar,\x02k es,gruber}@google.com";
ByteStringView expected_text(kExpectedText);
@@ -1796,7 +1796,7 @@
// TODO(crbug.com/40448046): The PDF uses fonts [/F2, /F1, /F2, /F1] with a
// constant size on a single line. FPDFText_CountRects() should merge the text
// into 4 rects.
- constexpr auto kExpectedRects = fxcrt::ToArray<TextRect>({
+ static constexpr auto kExpectedRects = fxcrt::ToArray<TextRect>({
{7.0195, 657.8847, 10.3102, 648.9273},
{11.1978, 657.4722, 13.9057, 651.1599},
{14.1085, 655.3652, 22.2230, 649.2321},
@@ -1844,7 +1844,7 @@
// The first instance of "world" is visible to the human eye and should be
// extracted as is. The second instance is not, so how it should be
// extracted is debatable.
- constexpr char kNeedsImprovementResult[] = "wo d wo d";
+ static constexpr char kNeedsImprovementResult[] = "wo d wo d";
ASSERT_EQ(10, FPDFText_GetText(textpage.get(), 0, 128, buffer));
EXPECT_THAT(pdfium::make_span(buffer).first(10u),
ElementsAreArray(kNeedsImprovementResult));
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp
index 896010a..bd67326 100644
--- a/fpdfsdk/fpdf_view_embeddertest.cpp
+++ b/fpdfsdk/fpdf_view_embeddertest.cpp
@@ -572,7 +572,7 @@
EXPECT_EQ(0u, buf[0]);
CloseDocument();
- constexpr unsigned long kNoSuchPolicy = 102;
+ static constexpr unsigned long kNoSuchPolicy = 102;
FPDF_SetSandBoxPolicy(kNoSuchPolicy, true);
CreateEmptyDocument();
len = FPDF_GetMetaText(document(), "CreationDate", buf, sizeof(buf));
@@ -871,7 +871,7 @@
EXPECT_TRUE(FPDF_GetNamedDestByName(document(), kLastAlternate));
char buffer[512];
- constexpr long kBufferSize = sizeof(buffer);
+ static constexpr long kBufferSize = sizeof(buffer);
long size = kBufferSize;
// Test bad indices.
@@ -1713,8 +1713,8 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kWidth = 40000;
- constexpr int kHeight = 100;
+ static constexpr int kWidth = 40000;
+ static constexpr int kHeight = 100;
TestRenderPageBitmapWithMatrix(page.get(), kWidth, kHeight,
{1000, 0, 0, 1, 0, 0}, {0, 0, kWidth, kHeight},
kChecksum);
@@ -2127,8 +2127,8 @@
ScopedEmbedderTestPage page = LoadScopedPage(0);
ASSERT_TRUE(page);
- constexpr int kWidth = 200;
- constexpr int kHeight = 200;
+ static constexpr int kWidth = 200;
+ static constexpr int kHeight = 200;
EXPECT_EQ(kWidth, static_cast<int>(FPDF_GetPageWidthF(page.get())));
EXPECT_EQ(kHeight, static_cast<int>(FPDF_GetPageHeightF(page.get())));
EXPECT_TRUE(FPDFPage_HasTransparency(page.get()));
@@ -2143,9 +2143,9 @@
}
TEST_F(FPDFViewEmbedderTest, Bug2112) {
- constexpr int kWidth = 595;
- constexpr int kHeight = 842;
- constexpr int kStride = kWidth * 3;
+ static constexpr int kWidth = 595;
+ static constexpr int kHeight = 842;
+ static constexpr int kStride = kWidth * 3;
std::vector<uint8_t> vec(kStride * kHeight);
ScopedFPDFBitmap bitmap(FPDFBitmap_CreateEx(kWidth, kHeight, FPDFBitmap_BGR,
vec.data(), kStride));
@@ -2175,9 +2175,10 @@
}
TEST_F(FPDFViewEmbedderTest, BadFillRectInput) {
- constexpr int kWidth = 200;
- constexpr int kHeight = 200;
- constexpr char kExpectedChecksum[] = "acc736435c9f84aa82941ba561bc5dbc";
+ static constexpr int kWidth = 200;
+ static constexpr int kHeight = 200;
+ static constexpr char kExpectedChecksum[] =
+ "acc736435c9f84aa82941ba561bc5dbc";
ScopedFPDFBitmap bitmap(FPDFBitmap_Create(200, 200, /*alpha=*/true));
ASSERT_TRUE(FPDFBitmap_FillRect(bitmap.get(), /*left=*/0, /*top=*/0,
/*width=*/kWidth,
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
index b9233d5..6edbfc6 100644
--- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -72,7 +72,7 @@
}
void ExecuteExpectFloatNear(ByteStringView input, float expected) {
- constexpr float kPrecision = 0.000001f;
+ static constexpr float kPrecision = 0.000001f;
EXPECT_TRUE(Execute(input)) << "Program: " << input;
diff --git a/testing/fuzzers/pdf_nametree_fuzzer.cc b/testing/fuzzers/pdf_nametree_fuzzer.cc
index fd3a441..42664ea 100644
--- a/testing/fuzzers/pdf_nametree_fuzzer.cc
+++ b/testing/fuzzers/pdf_nametree_fuzzer.cc
@@ -25,7 +25,7 @@
names.reserve(count);
for (size_t i = 0; i < count; ++i) {
// The name is not that interesting here. Keep it short.
- constexpr size_t kMaxNameLen = 10;
+ static constexpr size_t kMaxNameLen = 10;
std::string str = data_provider->ConsumeRandomLengthString(kMaxNameLen);
names.push_back(WideString::FromUTF16LE(pdfium::as_byte_span(str)));
}
diff --git a/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc b/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
index 9238ba3..6059908 100644
--- a/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
+++ b/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
@@ -36,7 +36,7 @@
} // namespace
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- constexpr size_t kParameterSize = 33;
+ static constexpr size_t kParameterSize = 33;
if (size < kParameterSize)
return 0;
diff --git a/testing/pdfium_test.cc b/testing/pdfium_test.cc
index 95cc95f..c3b6620 100644
--- a/testing/pdfium_test.cc
+++ b/testing/pdfium_test.cc
@@ -334,7 +334,7 @@
int ExampleDocGetFilePath(IPDF_JSPLATFORM*, void* file_path, int length) {
static const char kPath[] = "myfile.pdf";
- constexpr int kRequired = static_cast<int>(sizeof(kPath));
+ static constexpr int kRequired = static_cast<int>(sizeof(kPath));
if (file_path && length >= kRequired)
memcpy(file_path, kPath, kRequired);
return kRequired;
@@ -386,7 +386,7 @@
int ExampleFieldBrowse(IPDF_JSPLATFORM*, void* file_path, int length) {
static const char kPath[] = "selected.txt";
- constexpr int kRequired = static_cast<int>(sizeof(kPath));
+ static constexpr int kRequired = static_cast<int>(sizeof(kPath));
if (file_path && length >= kRequired)
memcpy(file_path, kPath, kRequired);
return kRequired;