zoukankan      html  css  js  c++  java
  • linux 下gtest 安装

    cd gtest_dir  //解压后的目录
     
    mkdir mybuild       # Create a directory to hold the build output.
    cd mybuild
    cmake ${GTEST_DIR}  # Generate native build scripts.
    
    //If you want to build Google Test's samples, you should replace the last command with
    
    cmake -Dgtest_build_samples=ON ${GTEST_DIR}
    make
    make install
    


    測试程序
    #include "gtest/gtest.h"
    int max(int a, int b)
    {
    return a>b?a:b;
    }
    
    
    TEST(foo, max)
    {
    EXPECT_EQ(2, max(2,-1));
    EXPECT_EQ(3, max(2,3));
    }
    
    int main(int argc, char** argv)
    {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
    }
    


    g++ -g foo_test.cpp -o foo_test -I/home/xunw/gtest-1.6.0/include -L /home/xunw/gtest-1.6.0/mybuild -lgtest -lgtest_main -lpthread
    注意-I不能有空格 -L 须要有空格


  • 相关阅读:
    03-19总结
    JS-DOM
    难题汇总,浮动,伪元素(行级),
    bug汇总
    两栏布局
    表单 form
    a 、ul、 table 标签
    Bootstrap的基本使用(css、js文件的引入)
    6. CSS样式
    5 CSS
  • 原文地址:https://www.cnblogs.com/lytwajue/p/6801940.html
Copyright © 2011-2022 走看看