GAIO CLUB
[==========] Running 3 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 3 tests from Func32
[ RUN ] Func32.TEST1
[ OK ] Func32.TEST1 (0 ms)
[ RUN ] Func32.TEST2
[ OK ] Func32.TEST2 (0 ms)
[ RUN ] Func32.TEST3
[ OK ] Func32.TEST3 (0 ms)
[----------] 3 tests from Func32 (0 ms total)
[----------] Global test environment tear-down
[==========] 3 tests from 1 test suite ran. (0 ms total)
[ PASSED ] 3 tests.
#include <gtest/gtest.h>
#include <stdio.h>
int glb3;
// Test Target : function3_2 // テストターゲット関数
int function3_2(int a){
if ( a > 0 )
{
glb3 = a*a;
return a;
}
else
return 0;
}
class UnitTest:public::testing::Test{
protected:
static void SetUpTestCase() { printf("=== SetUpTestCase ======\n"); }
static void TearDownTestCase() { printf("=== TearDownTestCase ===\n"); }
virtual void SetUp() { printf("=== SetUp ======\n"); glb3=0; }
virtual void TearDown() { printf("=== TearDown ===\n"); }
};
// TEST1
TEST_F(UnitTest, TEST1){ // テストクラス名(UnitTest):テスト名(TEST1)
EXPECT_LT(0, function3_2(5));
EXPECT_EQ(5*5, glb3);
}
// TEST2
TEST_F(UnitTest, TEST2){ // テストクラス名(UnitTest):テスト名(TEST2)
EXPECT_LT(0, function3_2(1));
EXPECT_EQ(1, glb3);
}
// TEST3
TEST_F(UnitTest, TEST3){ // テストクラス名(UnitTest):テスト名(TEST3)
EXPECT_EQ(0, function3_2(-5));
EXPECT_EQ(0, glb3);
}
Running main() from /usr/local/src/googletest-1.14.0/googletest/src/gtest_main.cc
[==========] Running 3 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 3 tests from UnitTest
=== SetUpTestCase ======
[ RUN ] UnitTest.TEST1
=== SetUp ======
=== TearDown ===
[ OK ] UnitTest.TEST1 (0 ms)
[ RUN ] UnitTest.TEST2
=== SetUp ======
=== TearDown ===
[ OK ] UnitTest.TEST2 (0 ms)
[ RUN ] UnitTest.TEST3
=== SetUp ======
=== TearDown ===
[ OK ] UnitTest.TEST3 (0 ms)
=== TearDownTestCase ===
[----------] 3 tests from UnitTest (0 ms total)
[----------] Global test environment tear-down
[==========] 3 tests from 1 test suite ran. (0 ms total)
[ PASSED ] 3 tests.
浅野 昌尚(あさの まさなお)
ガイオ・テクノロジー株式会社
開発1部 QTXグループ
1980年代から30年以上にわたり汎用構造のCコンパイラ開発に従事し、その間に8ビットマイコンからRISC・VLIW・画像処理プロセッサまで、さまざまなCPU向けのクロスCコンパイラを開発。