Skip to content

Instantly share code, notes, and snippets.

@fuwac
Created May 13, 2017 12:33
Show Gist options
  • Save fuwac/6ba26f138240aa8a77f81b495abba878 to your computer and use it in GitHub Desktop.
Save fuwac/6ba26f138240aa8a77f81b495abba878 to your computer and use it in GitHub Desktop.
cppucheck導入時のテストコード
#pragma comment(lib, "CppUTestd.lib")
#include "cpputest\CommandLineTestRunner.h"
#include "cpputest\TestHarness.h"
int main(int argc, char *argv[])
{
return CommandLineTestRunner::RunAllTests(argc, argv);
}
int MyProc(int a, int b)
{
return -1; // とりあえず実装
//return a+b; // テストケース通す実装
}
#ifdef __cplusplus
extern "C" {
#endif
 
/**
* AとBを加算した結果を返却するよ!
* @param a 左辺値
* @param b 右辺値
* @return 加算した結果
*/
int MyProc(int,int);
 
#ifdef __cplusplus
}
#endif
#pragma comment(lib, "CppUTestd.lib")
#include "cpputest\CommandLineTestRunner.h"
#include "cpputest\TestHarness.h"
#include "MyProc.h"
TEST_GROUP(MyProc)
{
void setup()
{
// ここでチェック前処理
}
void teardown()
{
// ここでチェック後処理
}
};
// 加算されてるかチェック
TEST(MyProc, SumCheck)
{
LONGS_EQUAL(3, MyProc(1, 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment