Use explicit short to fix MSVC compiler warning

warning C4244: 'initializing': conversion from 'int' to 'short', possible
loss of data

PiperOrigin-RevId: 505774670
Change-Id: I3524040334a4b265bae12cfacdd2b615cbb1cfc8
This commit is contained in:
Tom Hughes 2023-01-30 12:57:54 -08:00 committed by Copybara-Service
parent e3dbee4b35
commit f1c05d4544

View File

@ -863,7 +863,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) {
} }
TEST(ArgsTest, AcceptsTwoTemplateArgs) { TEST(ArgsTest, AcceptsTwoTemplateArgs) {
const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT const std::tuple<short, int, long> t(short{4}, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt()))); EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt()))); EXPECT_THAT(t, (Args<1, 2>(Lt())));
@ -871,13 +871,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
} }
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) { TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT const std::tuple<short, int, long> t(short{4}, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq()))); EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne()))); EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
} }
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT const std::tuple<short, int, long> t(short{4}, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt()))); EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt()))); EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
} }
@ -892,7 +892,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
} }
TEST(ArgsTest, CanBeNested) { TEST(ArgsTest, CanBeNested) {
const std::tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT const std::tuple<short, int, long, int> t(short{4}, 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq())))); EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt())))); EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
} }