OSDN Git Service

add gcov option
[oca1/test.git] / USB_Keybord_MAX3421E / src / SPI_controler_test_case.cpp
1 #include <cppunit/extensions/HelperMacros.h> //
2 #include "SPI_controler_top.h"
3
4 // 以下はSPIControlerTestクラスの宣言-----
5 class SPIControlerTest : public CPPUNIT_NS::TestFixture { //
6         CPPUNIT_TEST_SUITE( SPIControlerTest ); //
7         CPPUNIT_TEST( test_init );         //
8         CPPUNIT_TEST( test_incr );         //
9         CPPUNIT_TEST( test_clear );        //
10         CPPUNIT_TEST_SUITE_END();          //
11
12         public:
13         SPIControlerTest();
14         ~SPIControlerTest();
15         void setUp();      //
16         void tearDown();   //
17
18         protected:
19         void test_init();  //
20         void test_incr();  //
21         void test_clear(); //
22 };
23         SPIControlerTop* c_ ;
24
25 // 以下はSPIControlerTestクラスの実装-----
26 CPPUNIT_TEST_SUITE_REGISTRATION( SPIControlerTest ); //
27
28 SPIControlerTest::SPIControlerTest( )
29 {
30         if(c_==NULL){
31                 c_ = new SPIControlerTop();
32         }
33 }
34 SPIControlerTest::~SPIControlerTest( ) 
35 {
36 }
37 // 各テスト・ケースの実行直前に呼ばれる
38 void SPIControlerTest::setUp() {
39 }
40
41 // 各テスト・ケースの実行直後に呼ばれる
42 void SPIControlerTest::tearDown() {
43 }
44
45 // これ以降はテスト・ケースの実装内容
46
47 void SPIControlerTest::test_init() {
48         c_->nextStep(); //
49         c_->reset();
50         c_->nextStep(); //
51         CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
52 }
53
54 void SPIControlerTest::test_incr() {
55         for ( int i = 1; i < 10; ++i ) {
56                 CPPUNIT_ASSERT_EQUAL(i,(int) c_->read_MOSI()); //
57         }
58 }
59
60 void SPIControlerTest::test_clear() {
61         c_->nextStep(); //
62         c_->reset();
63         c_->nextStep(); //
64         CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
65