зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1766377 - Fix sign-compare warnings related to constants in gtests. r=nika,mossop
obj-build/dist/include/gtest/gtest.h(1440,28): error: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Werror,-Wsign-compare] GTEST_IMPL_CMP_HELPER_(GT, >) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ obj-build/dist/include/gtest/gtest.h(1422,14): note: expanded from macro 'GTEST_IMPL_CMP_HELPER_' if (val1 op val2) { \ ~~~~ ^ ~~~~ toolkit/system/windowsPackageManager/tests/gtest/TestWindowsPackageManager.cpp(22,3): note: in instantiation of function template specialization 'testing::internal::CmpHelperGT<unsigned long long, int>' requested here ASSERT_GT(packages.Length(), 0); ^ obj-build/dist/include/gtest/gtest.h(1891,31): note: expanded from macro 'ASSERT_GT' ^ obj-build/dist/include/gtest/gtest.h(1865,44): note: expanded from macro 'GTEST_ASSERT_GT' ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1354,11): error: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ obj-build/dist/include/gtest/gtest.h(1373,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned long long, int>' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ toolkit/system/windowsPackageManager/tests/gtest/TestWindowsPackageManager.cpp(33,3): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned long long, int, nullptr>' requested here ASSERT_EQ(packages.Length(), 0); ^ obj-build/dist/include/gtest/gtest.h(1871,31): note: expanded from macro 'ASSERT_EQ' ^ obj-build/dist/include/gtest/gtest.h(1855,54): note: expanded from macro 'GTEST_ASSERT_EQ' ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1354,11): error: comparison of integers of different signs: 'const int' and 'const unsigned int' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ obj-build/dist/include/gtest/gtest.h(1373,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<int, unsigned int>' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ toolkit/system/windowsDHCPClient/tests/gtest/TestDHCPUtils.cpp(232,3): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<int, unsigned int, nullptr>' requested here ASSERT_EQ(0, size); ^ obj-build/dist/include/gtest/gtest.h(1871,31): note: expanded from macro 'ASSERT_EQ' ^ obj-build/dist/include/gtest/gtest.h(1855,54): note: expanded from macro 'GTEST_ASSERT_EQ' ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1354,11): error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ obj-build/dist/include/gtest/gtest.h(1373,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ toolkit/mozapps/defaultagent/tests/gtest/CacheTest.cpp(67,3): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here ASSERT_EQ(Cache::kDefaultCapacity, 2); ^ obj-build/dist/include/gtest/gtest.h(1871,31): note: expanded from macro 'ASSERT_EQ' ^ obj-build/dist/include/gtest/gtest.h(1855,54): note: expanded from macro 'GTEST_ASSERT_EQ' ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1440,28): error: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Werror,-Wsign-compare] GTEST_IMPL_CMP_HELPER_(GT, >) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ obj-build/dist/include/gtest/gtest.h(1422,14): note: expanded from macro 'GTEST_IMPL_CMP_HELPER_' if (val1 op val2) { \ ~~~~ ^ ~~~~ toolkit/xre/dllservices/tests/gtest/TestDLLBlocklist.cpp(123,5): note: in instantiation of function template specialization 'testing::internal::CmpHelperGT<unsigned long long, int>' requested here EXPECT_GT(strlen(pEntry->mName), 3); ^ obj-build/dist/include/gtest/gtest.h(1852,44): note: expanded from macro 'EXPECT_GT' EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) ^ In file included from Unified_cpp_xpcom_tests_gtest0.cpp:2: In file included from xpcom/tests/gtest/Helpers.cpp:12: obj-build/dist/include/gtest/gtest.h(1354,11): error: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ obj-build/dist/include/gtest/gtest.h(1373,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned long long, int>' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ xpcom/tests/gtest/TestAvailableMemoryWatcherWin.cpp(483,5): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned long long, int, nullptr>' requested here EXPECT_EQ(tokens.Length(), 3); ^ obj-build/dist/include/gtest/gtest.h(1842,54): note: expanded from macro 'EXPECT_EQ' EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1354,11): error: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ obj-build/dist/include/gtest/gtest.h(1373,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned long long, int>' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp(211,5): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned long long, int, nullptr>' requested here EXPECT_EQ(collector.Data().length(), 1); ^ obj-build/dist/include/gtest/gtest.h(1842,54): note: expanded from macro 'EXPECT_EQ' EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1354,11): error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ obj-build/dist/include/gtest/gtest.h(1373,12): note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp(310,7): note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here EXPECT_EQ(evt.mLoadStatus, 0); ^ obj-build/dist/include/gtest/gtest.h(1842,54): note: expanded from macro 'EXPECT_EQ' EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) ^ obj-build/dist/include/gtest/gtest.h(1440,28): error: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Werror,-Wsign-compare] GTEST_IMPL_CMP_HELPER_(GT, >) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ obj-build/dist/include/gtest/gtest.h(1422,14): note: expanded from macro 'GTEST_IMPL_CMP_HELPER_' if (val1 op val2) { \ ~~~~ ^ ~~~~ toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp(332,3): note: in instantiation of function template specialization 'testing::internal::CmpHelperGT<unsigned int, int>' requested here EXPECT_GT(aData.mNumEvents, 0); ^ obj-build/dist/include/gtest/gtest.h(1852,44): note: expanded from macro 'EXPECT_GT' EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) ^ Differential Revision: https://phabricator.services.mozilla.com/D144694
This commit is contained in:
Родитель
4f1f2540f6
Коммит
98d32b03bf
|
@ -64,7 +64,7 @@ TEST_F(WDBACacheTest, BasicFunctionality) {
|
|||
ASSERT_TRUE(entry.isNothing());
|
||||
|
||||
// Test that the cache stops accepting items when it is full.
|
||||
ASSERT_EQ(Cache::kDefaultCapacity, 2);
|
||||
ASSERT_EQ(Cache::kDefaultCapacity, 2U);
|
||||
Cache::Entry toWrite = Cache::Entry{
|
||||
.notificationType = "string1",
|
||||
.notificationShown = "string2",
|
||||
|
@ -96,7 +96,7 @@ TEST_F(WDBACacheTest, BasicFunctionality) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 2);
|
||||
ASSERT_EQ(entry.value().entryVersion, 2U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string1");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string2");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string3");
|
||||
|
@ -107,7 +107,7 @@ TEST_F(WDBACacheTest, BasicFunctionality) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 2);
|
||||
ASSERT_EQ(entry.value().entryVersion, 2U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string5");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string6");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string7");
|
||||
|
@ -149,7 +149,7 @@ TEST_F(WDBACacheTest, Version1Migration) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
Cache::MaybeEntry entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 1);
|
||||
ASSERT_EQ(entry.value().entryVersion, 1U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string1");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string2");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string3");
|
||||
|
@ -169,7 +169,7 @@ TEST_F(WDBACacheTest, Version1Migration) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 1);
|
||||
ASSERT_EQ(entry.value().entryVersion, 1U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string4");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string5");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string6");
|
||||
|
@ -179,7 +179,7 @@ TEST_F(WDBACacheTest, Version1Migration) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 2);
|
||||
ASSERT_EQ(entry.value().entryVersion, 2U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string7");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string8");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string9");
|
||||
|
@ -263,7 +263,7 @@ TEST_F(WDBACacheTest, ForwardsCompatibility) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
Cache::MaybeEntry entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 9999);
|
||||
ASSERT_EQ(entry.value().entryVersion, 9999U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string1");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string2");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string3");
|
||||
|
@ -274,7 +274,7 @@ TEST_F(WDBACacheTest, ForwardsCompatibility) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 2);
|
||||
ASSERT_EQ(entry.value().entryVersion, 2U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string6");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string7");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string8");
|
||||
|
@ -285,7 +285,7 @@ TEST_F(WDBACacheTest, ForwardsCompatibility) {
|
|||
ASSERT_TRUE(entryResult.isOk());
|
||||
entry = entryResult.unwrap();
|
||||
ASSERT_TRUE(entry.isSome());
|
||||
ASSERT_EQ(entry.value().entryVersion, 2);
|
||||
ASSERT_EQ(entry.value().entryVersion, 2U);
|
||||
ASSERT_EQ(entry.value().notificationType, "string10");
|
||||
ASSERT_EQ(entry.value().notificationShown, "string11");
|
||||
ASSERT_EQ(entry.value().notificationAction, "string12");
|
||||
|
|
|
@ -229,7 +229,7 @@ TEST_F(TestDHCPUtils, TestGetAbsentOption) {
|
|||
nsresult retVal = RetrieveOption(mDefaultAdapterName, 252, optionValue, &size,
|
||||
mMockWindowsFunctions);
|
||||
|
||||
ASSERT_EQ(0, size);
|
||||
ASSERT_EQ(0U, size);
|
||||
ASSERT_EQ(NS_ERROR_NOT_AVAILABLE, retVal);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ TEST(WindowsPackageManager, TestWithMatches)
|
|||
// installed when we run tests. This will _probably_ hold true.
|
||||
prefixes.AppendElement(u"Microsoft"_ns);
|
||||
nsresult retVal = wpm->FindUserInstalledPackages(prefixes, packages);
|
||||
ASSERT_GT(packages.Length(), 0);
|
||||
ASSERT_GT(packages.Length(), 0U);
|
||||
ASSERT_EQ(NS_OK, retVal);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,6 @@ TEST(WindowsPackageManager, TestWithoutMatches)
|
|||
nsTArray<nsString> prefixes, packages;
|
||||
prefixes.AppendElement(u"DoesntExist"_ns);
|
||||
nsresult retVal = wpm->FindUserInstalledPackages(prefixes, packages);
|
||||
ASSERT_EQ(packages.Length(), 0);
|
||||
ASSERT_EQ(packages.Length(), 0U);
|
||||
ASSERT_EQ(NS_OK, retVal);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ TEST(TestDllBlocklist, BlocklistIntegrity)
|
|||
|
||||
// Validate name
|
||||
EXPECT_TRUE(!!pEntry->mName);
|
||||
EXPECT_GT(strlen(pEntry->mName), 3);
|
||||
EXPECT_GT(strlen(pEntry->mName), 3U);
|
||||
|
||||
// Check the filename for valid characters.
|
||||
for (auto pch = pEntry->mName; *pch != 0; ++pch) {
|
||||
|
|
|
@ -208,7 +208,7 @@ class UntrustedModulesFixture : public TelemetryTestFixture {
|
|||
ModuleLoadCounter waitForOne({kTestModules[0]}, {1});
|
||||
EXPECT_TRUE(NS_SUCCEEDED(collector.Collect(waitForOne)));
|
||||
EXPECT_TRUE(waitForOne.Remains({kTestModules[0]}, {0}));
|
||||
EXPECT_EQ(collector.Data().length(), 1);
|
||||
EXPECT_EQ(collector.Data().length(), 1U);
|
||||
|
||||
// Cannot "return collector.Data()[0]" as copy ctor is deleted.
|
||||
return UntrustedModulesData(std::move(collector.Data()[0]));
|
||||
|
@ -307,7 +307,7 @@ void UntrustedModulesFixture::ValidateUntrustedModules(
|
|||
&match)) {
|
||||
EXPECT_EQ(loadStatus, kKnownModules[match].mStatus);
|
||||
} else {
|
||||
EXPECT_EQ(evt.mLoadStatus, 0);
|
||||
EXPECT_EQ(evt.mLoadStatus, 0U);
|
||||
}
|
||||
|
||||
if (BinarySearchIf(
|
||||
|
@ -329,19 +329,19 @@ void UntrustedModulesFixture::ValidateUntrustedModules(
|
|||
// No check for the mXULLoadDurationMS field because the field has a value
|
||||
// in CCov build GTest, but it is empty in non-CCov build (bug 1681936).
|
||||
EXPECT_EQ(aData.mNumEvents, aData.mEvents.length());
|
||||
EXPECT_GT(aData.mNumEvents, 0);
|
||||
EXPECT_GT(aData.mNumEvents, 0U);
|
||||
if (aIsTruncatedData) {
|
||||
EXPECT_EQ(aData.mStacks.GetModuleCount(), 0);
|
||||
EXPECT_EQ(aData.mStacks.GetModuleCount(), 0U);
|
||||
EXPECT_LE(aData.mNumEvents, UntrustedModulesData::kMaxEvents);
|
||||
} else if (numBlockedEvents == aData.mNumEvents) {
|
||||
// If all loading events were blocked or aData is truncated,
|
||||
// the stacks are empty.
|
||||
EXPECT_EQ(aData.mStacks.GetModuleCount(), 0);
|
||||
EXPECT_EQ(aData.mStacks.GetModuleCount(), 0U);
|
||||
} else {
|
||||
EXPECT_GT(aData.mStacks.GetModuleCount(), 0);
|
||||
EXPECT_GT(aData.mStacks.GetModuleCount(), 0U);
|
||||
}
|
||||
EXPECT_EQ(aData.mSanitizationFailures, 0);
|
||||
EXPECT_EQ(aData.mTrustTestFailures, 0);
|
||||
EXPECT_EQ(aData.mSanitizationFailures, 0U);
|
||||
EXPECT_EQ(aData.mTrustTestFailures, 0U);
|
||||
}
|
||||
|
||||
BOOL CALLBACK UntrustedModulesFixture::InitialModuleLoadOnce(PINIT_ONCE, void*,
|
||||
|
|
|
@ -480,8 +480,8 @@ class MemoryWatcherTelemetryEvent {
|
|||
for (const nsAString& token : eventValues.LastElement().Split(',')) {
|
||||
tokens.AppendElement(token);
|
||||
}
|
||||
EXPECT_EQ(tokens.Length(), 3);
|
||||
if (tokens.Length() != 3) {
|
||||
EXPECT_EQ(tokens.Length(), 3U);
|
||||
if (tokens.Length() != 3U) {
|
||||
const wchar_t* valueStr = eventValues.LastElement().get();
|
||||
fprintf(stderr, "Unexpected event value: %S\n", valueStr);
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче