Trying to use a library

Dependencies:   mbed-rtos mbed BlinkLib

Fork of NerfUS by NerfUS

Revision:
3:aaf84424abb1
diff -r 6e467e4978f9 -r aaf84424abb1 test/GoogleMockTest.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/GoogleMockTest.cpp	Sat Feb 04 22:48:36 2017 -0500
@@ -0,0 +1,38 @@
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+class Adder
+{
+    public:
+        virtual ~Adder() {}
+        virtual int add(int a, int b)
+        {
+            return a + b;
+        }
+};
+
+class MockAdder : public Adder
+{
+    public:
+        MOCK_METHOD2(add, int(int a, int b));
+};
+
+TEST(GoogleMockTest, ExpectCalled)
+{
+    MockAdder adder;
+
+    EXPECT_CALL(adder, add(1, 2));
+
+    adder.add(1, 2);
+}
+
+TEST(GoogleMockTest, DefineReturnedValue)
+{
+    using ::testing::Return;
+    MockAdder adder;
+
+    EXPECT_CALL(adder, add(1, 2))
+        .WillOnce(Return(42));
+
+    ASSERT_EQ(42, adder.add(1, 2));
+}