// -------------------------------------------------- // include // -------------------------------------------------- #include #include // CUnit で使える様々なマクロを定義 #include // コンソール上でのユーザーインターフェースを提供する 関数を利用するために必要です。 // -------------------------------------------------- // functions // -------------------------------------------------- // 評価対象関数 int hoge( int a ); // テスト用関数 void test_hoge_001( void ); void test_hoge_002( void ); void test_hoge_003( void ); // main int main( void ) { // test suite CU_pSuite cu_suite; printf("Hello CUnit Would!!\n"); // ------------------ // CUnit 初期化 // ------------------ // テストレジストリ 初期化 CU_initialize_registry(); // テストスイート登録 cu_suite = CU_add_suite("hoge", NULL, NULL); // ------------------ // CUnit テスト登録 // ------------------ // テスト CU_add_test( cu_suite, "test_hoge_001", test_hoge_001 ); CU_add_test( cu_suite, "test_hoge_002", test_hoge_002 ); CU_add_test( cu_suite, "test_hoge_003", test_hoge_003 ); // ------------------ // CUnit 実行 // ------------------ CU_console_run_tests(); CU_cleanup_registry(); // 正常 return 0; } // 評価対象関数 int hoge( int a ) { return a; } // test 1 void test_hoge_001( void ) { CU_ASSERT( 1 == hoge( 1 ) ); } // test 2 void test_hoge_002( void ) { CU_ASSERT( 2 == hoge( 2 ) ); } // test 3 void test_hoge_003( void ) { CU_ASSERT( 3 == hoge( 3 ) ); }