OSDN Git Service

commit test files
[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 protected:
13   SPIControlerTop* c_;
14
15 public:
16   void setUp();      //
17   void tearDown();   //
18
19 protected:
20   void test_init();  //
21   void test_incr();  //
22   void test_clear(); //
23 };
24
25 // 以下はSPIControlerTestクラスの実装-----
26
27 CPPUNIT_TEST_SUITE_REGISTRATION( SPIControlerTest ); //
28
29 // 各テスト・ケースの実行直前に呼ばれる
30 void SPIControlerTest::setUp() {
31   c_ = new SPIControlerTop();
32 }
33
34 // 各テスト・ケースの実行直後に呼ばれる
35 void SPIControlerTest::tearDown() {
36   delete c_;
37 }
38
39 // これ以降はテスト・ケースの実装内容
40
41 void SPIControlerTest::test_init() {
42   CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
43 }
44
45 void SPIControlerTest::test_incr() {
46   for ( int i = 1; i < 10; ++i ) {
47     CPPUNIT_ASSERT_EQUAL(i,(int) c_->read_MOSI()); //
48   }
49 }
50
51 void SPIControlerTest::test_clear() {
52   CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
53