cmn-clib(CommonLibraryForC)
C言語共通ライブラリ
 全て データ構造 ファイル 関数 変数 型定義 列挙型 列挙値 マクロ定義
CmnTest.h ファイル

ユニットテストライブラリ ヘッダファイル [詳解]

#include "cmnclib/Common.h"
#include "cmnclib/CmnData.h"
#include "cmnclib/CmnTime.h"

[ソースコード]

データ構造

struct  tag_CmnTestPlan
 
struct  tag_CmnTestCase
 

マクロ定義

#define CmnTest_AddTestCaseEasy(plan, testFunction)   CmnTest_AddTestCase(plan, __FILE__, #testFunction, testFunction)
 

型定義

typedef struct tag_CmnTestPlan CmnTestPlan
 
typedef struct tag_CmnTestCase CmnTestCase
 

関数

D_EXTERN void CmnTest_InitializeTestPlan (CmnTestPlan *plan)
 テストプランを作成する [詳解]
 
D_EXTERN void CmnTest_AddTestCase (CmnTestPlan *plan, char *fileName, char *caseName, void(*testFunction)(CmnTestCase *))
 テストプランにテストケースを追加する [詳解]
 
D_EXTERN void CmnTest_Run (CmnTestPlan *plan, int realtimeReport)
 テストを実行する [詳解]
 
D_EXTERN void CmnTest_DestroyTest (CmnTestPlan *plan)
 テストプランを破棄する [詳解]
 
D_EXTERN int CmnTest_AssertNumber (CmnTestCase *testCase, long line, long long actual, long long expected)
 
D_EXTERN int CmnTest_AssertPointer (CmnTestCase *testCase, long line, void *actual, void *expected)
 
D_EXTERN int CmnTest_AssertString (CmnTestCase *testCase, long line, char *actual, char *expected)
 
D_EXTERN int CmnTest_AssertData (CmnTestCase *testCase, long line, void *actual, void *expected, size_t dataLen)
 
D_EXTERN int CmnTest_AssertOK (CmnTestCase *testCase, long line)
 
D_EXTERN int CmnTest_AssertNG (CmnTestCase *testCase, long line)
 

詳解

ユニットテストライブラリ ヘッダファイル

ユニットテストライブラリのヘッダファイル。
ユニットテストのソースコードからのみこのヘッダファイルを読み込むこと

著者
H.Kumagai
日付
2020-05-05

マクロ定義詳解

#define CmnTest_AddTestCaseEasy (   plan,
  testFunction 
)    CmnTest_AddTestCase(plan, __FILE__, #testFunction, testFunction)

テストプランにテストケースを追加する(CmnTest_AddTestCaseのラッパーマクロ)

型定義詳解

typedef struct tag_CmnTestCase CmnTestCase

テストケース

typedef struct tag_CmnTestPlan CmnTestPlan

テストプラン

関数詳解

D_EXTERN void CmnTest_AddTestCase ( CmnTestPlan plan,
char *  fileName,
char *  caseName,
void(*)(CmnTestCase *)  testFunction 
)

テストプランにテストケースを追加する

テストプランにテストケースを追加する

本関数にはラッパーマクロ「CmnTest_AddTestCaseEasy」が用意されている。 ラッパーマクロを使用すると、fileName(__FILE__)とcaseName(testFunction関数名)が補完される。

引数
testPlanテストプラン
fileNameテストケースファイル名
caseNameテストケース名
testFunctionテスト実施関数
D_EXTERN int CmnTest_AssertData ( CmnTestCase testCase,
long  line,
void *  actual,
void *  expected,
size_t  dataLen 
)

データ検証

D_EXTERN int CmnTest_AssertNG ( CmnTestCase testCase,
long  line 
)

検証NGを記録する

D_EXTERN int CmnTest_AssertNumber ( CmnTestCase testCase,
long  line,
long long  actual,
long long  expected 
)

整数値検証

D_EXTERN int CmnTest_AssertOK ( CmnTestCase testCase,
long  line 
)

検証OKを記録する

D_EXTERN int CmnTest_AssertPointer ( CmnTestCase testCase,
long  line,
void *  actual,
void *  expected 
)

ポインタ検証

D_EXTERN int CmnTest_AssertString ( CmnTestCase testCase,
long  line,
char *  actual,
char *  expected 
)

文字列検証

D_EXTERN void CmnTest_DestroyTest ( CmnTestPlan plan)

テストプランを破棄する

テストプランを破棄する

引数
planテストプラン
D_EXTERN void CmnTest_InitializeTestPlan ( CmnTestPlan plan)

テストプランを作成する

テストプランを作成する

D_EXTERN void CmnTest_Run ( CmnTestPlan plan,
int  realtimeReport 
)

テストを実行する

テストを実行する

引数
planテストプラン
realtimeReportテスト実行時にテスト結果を順次標準出力に出力するか(True:出力する、False:出力しない)