aboutsummaryrefslogtreecommitdiff
path: root/test cases/frameworks/3 gmock
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-03-24 17:07:34 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-03-24 17:07:34 +0200
commit867c315e563d54b417eccdbdc3b0633ee0851d6a (patch)
tree31ed12c36eccc6428f11c0a95cb891c471fbdd6a /test cases/frameworks/3 gmock
parent26b79bdefab857c59e0b887b8e4fae2a9bff2455 (diff)
downloadmeson-867c315e563d54b417eccdbdc3b0633ee0851d6a.zip
meson-867c315e563d54b417eccdbdc3b0633ee0851d6a.tar.gz
meson-867c315e563d54b417eccdbdc3b0633ee0851d6a.tar.bz2
Added detector for GMock.
Diffstat (limited to 'test cases/frameworks/3 gmock')
-rw-r--r--test cases/frameworks/3 gmock/gmocktest.cc27
-rw-r--r--test cases/frameworks/3 gmock/meson.build10
2 files changed, 37 insertions, 0 deletions
diff --git a/test cases/frameworks/3 gmock/gmocktest.cc b/test cases/frameworks/3 gmock/gmocktest.cc
new file mode 100644
index 0000000..a8bd2d3
--- /dev/null
+++ b/test cases/frameworks/3 gmock/gmocktest.cc
@@ -0,0 +1,27 @@
+#include<gtest/gtest.h>
+#include<gmock/gmock.h>
+
+using ::testing::Return;
+
+class Foo {
+public:
+ Foo() { x = 42; }
+ virtual ~Foo() {};
+
+ virtual int getValue() const { return x; }
+
+private:
+ int x;
+};
+
+class MockFoo : public Foo {
+public:
+ MOCK_CONST_METHOD0(getValue, int());
+};
+
+TEST(counttest, once) {
+ MockFoo f;
+ EXPECT_CALL(f, getValue()).Times(1).WillOnce(Return(42));
+
+ EXPECT_EQ(f.getValue(), 42) << "Got wrong value";
+}
diff --git a/test cases/frameworks/3 gmock/meson.build b/test cases/frameworks/3 gmock/meson.build
new file mode 100644
index 0000000..4e03078
--- /dev/null
+++ b/test cases/frameworks/3 gmock/meson.build
@@ -0,0 +1,10 @@
+project('gmock test', 'cxx')
+
+# Using gmock without gtest is a pain so just
+# don't support that then.
+
+gtest = find_dep('gtest', required : true)
+gmock = find_dep('gmock', required : true)
+
+e = executable('gmocktest', 'gmocktest.cc', deps : [gtest, gmock])
+add_test('gmock test', e)