GoogleTest hello world.

./build and ./test work automatically when cwd is inside userland/libs/XXX
without --package-all.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-11-25 00:00:00 +00:00
parent 50570326d4
commit 39073519b1
11 changed files with 156 additions and 32 deletions

View File

@@ -0,0 +1,27 @@
#include <utility>
#include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using testing::ElementsAre;
using testing::Pair;
TEST(MainTest, MyTest0) {
EXPECT_EQ(1, 1);
// Array comparison.
// https://stackoverflow.com/questions/1460703/comparison-of-arrays-in-google-test
ASSERT_THAT(
(std::vector<int>{5, 10, 15}),
ElementsAre(5, 10, 15)
);
ASSERT_THAT(
(std::vector<std::pair<int, int>>{{1, -1}, {2, -2}}),
ElementsAre(Pair(1, -1), Pair(2, -2))
);
}
TEST(MainTest, MyTest1) {
EXPECT_EQ(1, 1);
}