//
// This file tests some commonly used argument matchers.
+#include <array>
+#include <memory>
+#include <ostream>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
+
+#include "gtest/gtest.h"
+
// Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4244)
-#pragma warning(disable : 4100)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100)
#include "test/gmock-matchers_test.h"
EXPECT_THAT(nonnull_unique, Not(IsFalse()));
}
-#if GTEST_HAS_TYPED_TEST
+#ifdef GTEST_HAS_TYPED_TEST
// Tests ContainerEq with different container types, and
// different element types.
}
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<1, 2>(Lt())));
}
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, Not(Args<1, 1>(Ne())));
}
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, Not(Args<2, 1>(Lt())));
}
}
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<0, 1, 3>(Args<0, 2>(Lt()))));
}
}
TEST_P(AnyOfArrayTestP, ExplainsMatchResultCorrectly) {
- // AnyOfArray and AllOfArry use the same underlying template-template,
+ // AnyOfArray and AllOfArray use the same underlying template-template,
// thus it is sufficient to test one here.
const std::vector<int> v0{};
const std::vector<int> v1{1};
EXPECT_THAT(p, Not(UniquePointee(2)));
}
+MATCHER(EnsureNoUnusedButMarkedUnusedWarning, "") { return (arg % 2) == 0; }
+
+TEST(MockMethodMockFunctionTest, EnsureNoUnusedButMarkedUnusedWarning) {
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic error "-Wused-but-marked-unused"
+#endif
+ // https://github.com/google/googletest/issues/4055
+ EXPECT_THAT(0, EnsureNoUnusedButMarkedUnusedWarning());
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+}
+
#if GTEST_HAS_EXCEPTIONS
// std::function<void()> is used below for compatibility with older copies of
{
Matcher<uint64_t> inner = Eq(10);
Matcher<std::function<void()>> matcher = Throws<uint32_t>(inner);
- EXPECT_TRUE(matcher.Matches([]() { throw(uint32_t) 10; }));
- EXPECT_FALSE(matcher.Matches([]() { throw(uint32_t) 11; }));
+ EXPECT_TRUE(matcher.Matches([]() { throw (uint32_t)10; }));
+ EXPECT_FALSE(matcher.Matches([]() { throw (uint32_t)11; }));
}
}
} // namespace gmock_matchers_test
} // namespace testing
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 4100