void TreeNodeTest::test_constructor() { // 1. the node is null GUI_CHECK_THROW( TreeNode(CNode::Ptr(), nullptr, 0), FailedAssertion ); // 2. the row number is below 0 NGeneric::Ptr node(new NGeneric("MyNode", "MyType")); GUI_CHECK_THROW( TreeNode(node, nullptr, -1), FailedAssertion); // 3. everything is OK GUI_CHECK_NO_THROW( TreeNode(node, nullptr, 0) ); }
void GraphicalBoolTest::test_setValue() { GraphicalBool * value = new GraphicalBool(false); QCheckBox * checkbox = findCheckBox(value); QVERIFY( is_not_null(checkbox) ); // // 1. check with bool values // QVERIFY( value->setValue(true) ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->originalValue().toBool() ); QVERIFY( value->setValue(false) ); QVERIFY( !checkbox->isChecked() ); QVERIFY( !value->originalValue().toBool() ); // // 2. check with strings (those supported by CF::Common::from_str<bool>()) // QVERIFY( value->setValue("true") ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->setValue("false") ); QVERIFY( !checkbox->isChecked() ); QVERIFY( value->setValue("on") ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->setValue("off") ); QVERIFY( !checkbox->isChecked() ); QVERIFY( value->setValue("1") ); QVERIFY( checkbox->isChecked() ); QVERIFY( value->setValue("0") ); QVERIFY( !checkbox->isChecked() ); GUI_CHECK_THROW( value->setValue("ThisIsNotABoolValue"), ParsingFailed ); QVERIFY( !checkbox->isChecked() ); // state should not have changed // // 3. check with other types // QVERIFY( !value->setValue(12) ); QVERIFY( !checkbox->isChecked() ); QVERIFY( !value->setValue(3.141592) ); QVERIFY( !checkbox->isChecked() ); QVERIFY( !value->setValue(-456) ); QVERIFY( !checkbox->isChecked() ); delete value; }