7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the GUI GraphicalDouble class"
11 #include <QHBoxLayout>
33 QHBoxLayout * layout =
dynamic_cast<QHBoxLayout*
>(value->layout());
34 QLineEdit * lineEdit =
nullptr;
38 lineEdit =
dynamic_cast<QLineEdit*
>(layout->itemAt(0)->widget());
41 std::cerr <<
"Failed to find the line edit." << std::endl;
44 std::cerr <<
"Failed to find the layout or cast it to QHBoxLayout." << std::endl;
51 BOOST_AUTO_TEST_SUITE( uiGraphicsGraphicalBoolSuite )
79 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"0") );
87 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"3.151492") );
104 BOOST_CHECK( value->
set_value(3.14159265) );
105 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"3.14159265") );
108 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"-2.71") );
114 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"12") );
116 BOOST_CHECK( !value->
set_value(
"Hello") );
117 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"12") );
120 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"12") );
122 BOOST_CHECK( !value->
set_value(
"1.6a45") );
123 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"12") );
125 BOOST_CHECK( value->
set_value(
"1.6E-45") );
126 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"1.6E-45") );
141 theValue = value->
value();
142 BOOST_CHECK( theValue.type() == QVariant::Double );
143 BOOST_CHECK_EQUAL( theValue.toDouble(), 0.0 );
146 lineEdit->setText(
"-2.71828183");
147 theValue = value->
value();
148 BOOST_CHECK( theValue.type() == QVariant::Double );
149 BOOST_CHECK_EQUAL( theValue.toDouble(), -2.71828183 );
152 lineEdit->setText(
"1.6E45");
153 theValue = value->
value();
154 BOOST_CHECK( theValue.type() == QVariant::Double );
155 BOOST_CHECK_EQUAL( theValue.toDouble(), 1.6e+45 );
167 QSignalSpy spy(value, SIGNAL(value_changed()));
176 BOOST_CHECK_EQUAL( spy.count(), 2 );
185 QTest::keyClicks(lineEdit,
"-3.141-51a6e4512r4+5w6" );
189 BOOST_CHECK_EQUAL( spy.count(), 18 );
198 BOOST_CHECK_EQUAL( spy.count(), 1 );
210 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"-3.14159265") );
213 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"1.6e-98") );
229 lineEdit->setText(
"12.45");
233 lineEdit->setText(
"-5.879");
243 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(init)
QApplication * application()
bool is_null(T ptr)
predicate for comparison to nullptr
bool AssertionThrows
assertions throw exceptions
bool ExceptionOutputs
if exception contructor should output
static AssertionManager & instance()
Gets the instance of the manager.
bool AssertionDumps
assertions dump backtraces
virtual QVariant value() const
bool ExceptionDumps
if exception contructor should dump backtrace
QLineEdit * find_line_edit(const GraphicalDouble *value)
Top-level namespace for coolfluid.
static ExceptionManager & instance()
Gets the instance of the manager.
Basic Classes for Graphics applications used by CF.
QString value_string() const
Most basic kernel library.
bool is_not_null(T ptr)
predicate for comparison to nullptr
virtual bool set_value(const QVariant &value)