Example #1
0
void SerialTest::SetDataBits() {
	Serial *serial = NULL;
	unsigned int data_bits[] = { 5, 6, 7, 8, 0};

	// create serial object
	CPPUNIT_ASSERT_NO_THROW(serial = new Serial("/dev/ttyS1"));

	// perform data bit setting tests
	for (unsigned int i=0; data_bits[i]!=0; i++) {
		CPPUNIT_ASSERT_NO_THROW(serial->SetDataBits(data_bits[i]));
		CPPUNIT_ASSERT_EQUAL(data_bits[i], serial->DataBits());
	}

	CPPUNIT_ASSERT_THROW(serial->SetDataBits(100), std::runtime_error);

	// destroy serial object
	delete serial;
	CPPUNIT_ASSERT(signal_catcher.StringSignalsReceived(0));
}