void TwoDArraysTest::testConstructor() { TwoDArray<int> work_data(20, 30); CPPUNIT_ASSERT_EQUAL (work_data.LengthY(), 20); CPPUNIT_ASSERT_EQUAL (work_data.LengthX(), 30); CPPUNIT_ASSERT_EQUAL (work_data.LastX() - work_data.FirstX() + 1, 30); CPPUNIT_ASSERT_EQUAL (work_data.LastY() - work_data.FirstY() + 1, 20); }
void TwoDArraysTest::testResize() { TwoDArray<int> work_data(20, 30); CPPUNIT_ASSERT_EQUAL (work_data.LengthX(), 30); CPPUNIT_ASSERT_EQUAL (work_data.LengthY(), 20); CPPUNIT_ASSERT_EQUAL (work_data.LastX() - work_data.FirstX() + 1, 30); CPPUNIT_ASSERT_EQUAL (work_data.LastY() - work_data.FirstY() + 1, 20); work_data.Resize(30, 20); CPPUNIT_ASSERT_EQUAL (work_data.LengthX(), 20); CPPUNIT_ASSERT_EQUAL (work_data.LengthY(), 30); CPPUNIT_ASSERT_EQUAL (work_data.LastX() - work_data.FirstX() + 1, 20); CPPUNIT_ASSERT_EQUAL (work_data.LastY() - work_data.FirstY() + 1, 30); }
void TwoDArraysTest::testValueConstructor() { const double val( -17.329 ); TwoDArray<double> work_data(20, 30 , val ); CPPUNIT_ASSERT_EQUAL (work_data.LengthY(), 20); CPPUNIT_ASSERT_EQUAL (work_data.LengthX(), 30); CPPUNIT_ASSERT_EQUAL (work_data.LastX() - work_data.FirstX() + 1, 30); CPPUNIT_ASSERT_EQUAL (work_data.LastY() - work_data.FirstY() + 1, 20); bool test_val (true); for (int j=work_data.FirstY() ; j<=work_data.LastY() ; ++j) { for (int i=work_data.FirstX() ; i<=work_data.LastX() ; ++i) { if ( work_data[j][i] != val ) test_val = false; }// i }// j CPPUNIT_ASSERT( test_val == true ); }
void main() { init_clk(); led_init(); Delay_ms(2000); //越过传感器不稳定状态 while(1) { led_out(0x55); Delay_ms(1000); led_out(0x00); work_data(); led_out(humdh); Delay_ms(1000);//等待下次采样 led_out(humdl); Delay_ms(1000); led_out(temph); Delay_ms(1000); led_out(templ); Delay_ms(1000); } }