【问题标题】:how to write a program for addition of two numbers in google test?如何在谷歌测试中编写两个数字相加的程序?
【发布时间】:2012-07-05 04:48:25
【问题描述】:

我正在使用 Visual Studio 2005... 谁能告诉我如何编写在谷歌测试中添加两个数字的最基本程序? 我已经阅读了几乎所有给出的参考资料......但不知何故不明白如何开始?

【问题讨论】:

    标签: googletest


    【解决方案1】:

    以下内容将尽可能基本:

    #include "gtest/gtest.h"
    
    int GetSum(int a, int b) { return a + b; }
    
    TEST(MathsFunctions, GetSum) {
      ASSERT_EQ(3, GetSum(1, 2));
    }
    
    int main(int argc, char **argv) {
      testing::InitGoogleTest(&argc, argv);
      return RUN_ALL_TESTS();
    }
    

    你需要提供gtest的include目录的路径和gtest.lib的链接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-27
      • 1970-01-01
      • 2022-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      相关资源
      最近更新 更多