{"id":129,"date":"2018-02-03T17:06:33","date_gmt":"2018-02-03T08:06:33","guid":{"rendered":"http:\/\/ragtimeblues.net\/?p=129"},"modified":"2019-01-04T15:58:31","modified_gmt":"2019-01-04T06:58:31","slug":"debian-stretch%e3%81%a7googletest%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/ragtimeblues.net\/?p=129","title":{"rendered":"Debian stretch\u3067googletest\u3092\u4f7f\u3063\u3066\u307f\u308b"},"content":{"rendered":"<p>c++\u306e\u5358\u4f53\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b<a href=\"https:\/\/github.com\/google\/googletest\">googletest<\/a>\u3068\u3044\u3046\u306e\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\nDebian stretch\u3067\u4f7f\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\napt\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo apt install googletest\r\n<\/pre>\n<p>\u3068\u3057\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ dpkg -L googletest\r\n<\/pre>\n<p>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30ea\u30b9\u30c8\u3059\u308b\u3068\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\/usr\/src\/googletest\u914d\u4e0b\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u306e\u3067\u3001\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ cd \/usr\/src\/googletest\/\r\n<\/pre>\n<p>\u76f4\u4e0b\u306bCMakeLists.txt\u304c\u3042\u308b\u306e\u3067\u3001cmake\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001\u30d3\u30eb\u30c9\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo apt install cmake\r\n$ sudo cmake .\r\n$ sudo make\r\n$ sudo make install\r\n<\/pre>\n<p>\u3053\u308c\u3067\u3001googletest\u3092\u4f7f\u3046\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u30c6\u30b9\u30c8\u3092\u3057\u3066\u307f\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u69cb\u6210\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n.\r\n\u251c\u2500\u2500 src\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 example.cpp\r\n\u2514\u2500\u2500 test\r\n    \u2514\u2500\u2500 example_test.cpp\r\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u5f15\u6570\u3092\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u3066\u8fd4\u3059\u95a2\u6570\u3092\u4e00\u3064\u3060\u3051\u66f8\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: src\/example.cpp; notranslate\" title=\"src\/example.cpp\">\r\nint\tincrement(int\tx)\r\n{\r\n\treturn ++x;\r\n}\r\n<\/pre>\n<p>\u95a2\u6570increment()\u306e\u30c6\u30b9\u30c8\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: test\/example_test.cpp; notranslate\" title=\"test\/example_test.cpp\">\r\n#include &amp;lt;gtest\/gtest.h&amp;gt;\r\n\r\n#include &amp;quot;src\/example.cpp&amp;quot;\r\n\r\nTEST(example_test, func_increment)\r\n{\r\n\tASSERT_EQ(1, increment(0));\r\n}\r\n<\/pre>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb&#038;\u30ea\u30f3\u30af\u3057\u307e\u3059\u3002\u30ea\u30f3\u30af\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306fgtest, gtest_main pthread\u3067\u3059\u3002<br \/>\n\u30c6\u30b9\u30c8\u5185\u306bmain()\u304c\u306a\u3044\u305f\u3081gtest_main\u3092\u30ea\u30f3\u30af\u3057\u3001google test\u304cpthread\u3092\u4f7f\u3046\u305f\u3081pthread\u3092\u30ea\u30f3\u30af\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\ng++ test\/example_test.cpp -I. -lgtest -lgtest_main -lpthread -o example_test\r\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u3092\u8d70\u3089\u305b\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\r\n$ .\/example_test \r\nRunning main() from gtest_main.cc\r\n&#x5B;==========] Running 1 test from 1 test case.\r\n&#x5B;----------] Global test environment set-up.\r\n&#x5B;----------] 1 test from example_test\r\n&#x5B; RUN      ] example_test.func_increment\r\n&#x5B;       OK ] example_test.func_increment (0 ms)\r\n&#x5B;----------] 1 test from example_test (0 ms total)\r\n\r\n&#x5B;----------] Global test environment tear-down\r\n&#x5B;==========] 1 test from 1 test case ran. (0 ms total)\r\n&#x5B;  PASSED  ] 1 test.\r\n<\/pre>\n<p>\u3068\u306a\u308a\u3001\u7121\u4e8b\u30c6\u30b9\u30c8\u304c\u901a\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>c++\u306e\u5358\u4f53\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306bgoogletest\u3068\u3044\u3046\u306e\u304c\u3042\u308a\u307e\u3059\u3002 Debian stretch\u3067\u4f7f\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u307e\u305a\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb apt\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068 $ sudo apt install g &hellip; <a href=\"https:\/\/ragtimeblues.net\/?p=129\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Debian stretch\u3067googletest\u3092\u4f7f\u3063\u3066\u307f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,9],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-debian","category-googletest"],"_links":{"self":[{"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=129"}],"version-history":[{"count":16,"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ragtimeblues.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}