Created
May 13, 2017 12:33
-
-
Save fuwac/6ba26f138240aa8a77f81b495abba878 to your computer and use it in GitHub Desktop.
cppucheck導入時のテストコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma comment(lib, "CppUTestd.lib") | |
#include "cpputest\CommandLineTestRunner.h" | |
#include "cpputest\TestHarness.h" | |
int main(int argc, char *argv[]) | |
{ | |
return CommandLineTestRunner::RunAllTests(argc, argv); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int MyProc(int a, int b) | |
{ | |
return -1; // とりあえず実装 | |
//return a+b; // テストケース通す実装 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
/** | |
* AとBを加算した結果を返却するよ! | |
* @param a 左辺値 | |
* @param b 右辺値 | |
* @return 加算した結果 | |
*/ | |
int MyProc(int,int); | |
#ifdef __cplusplus | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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