Pointer cleanup (#242)
- Made greater use of smart pointers, eliminating many instances of manual memory management - Do not use pointers at all for many non-polymorphic classes - Assorted other code cleanup
This commit is contained in:
@@ -22,6 +22,7 @@ if (Qt6Test_FOUND)
|
||||
qt6_wrap_cpp (TestXmlLabel_moc_sources TestXmlLabel.h)
|
||||
add_executable (TestXmlLabel TestXmlLabel.cpp ${TestXmlLabel_moc_sources})
|
||||
target_link_libraries (TestXmlLabel Model Qt6::Test)
|
||||
target_compile_definitions(TestXmlLabel PRIVATE TEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
add_test (NAME XmlLabel COMMAND TestXmlLabel)
|
||||
|
||||
#=======================================
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestColorNode.h"
|
||||
|
||||
#include "model/ColorNode.h"
|
||||
@@ -53,10 +54,8 @@ void TestColorNode::colorNode()
|
||||
QCOMPARE( colorNode.color(), blackTransparent );
|
||||
QCOMPARE( colorNode.key(), QString( "" ) );
|
||||
QCOMPARE( colorNode.rgba(), rgbaBlackTransparent );
|
||||
QCOMPARE( colorNode.color( nullptr, nullptr ), blackTransparent );
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), blackTransparent );
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), blackTransparent );
|
||||
QCOMPARE( colorNode.color( &record, &vars ), blackTransparent );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), blackTransparent );
|
||||
QCOMPARE( colorNode.color( record, vars ), blackTransparent );
|
||||
|
||||
colorNode.setField( true );
|
||||
QVERIFY( colorNode.isField() );
|
||||
@@ -66,10 +65,8 @@ void TestColorNode::colorNode()
|
||||
colorNode.setColor( white );
|
||||
QCOMPARE( colorNode.color(), white );
|
||||
QCOMPARE( colorNode.rgba(), rgbaWhite );
|
||||
QCOMPARE( colorNode.color( nullptr, nullptr ), white );
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), white );
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), white );
|
||||
QCOMPARE( colorNode.color( &record, &vars ), white );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), white );
|
||||
QCOMPARE( colorNode.color( record, vars ), white );
|
||||
|
||||
colorNode.setKey( "key1" );
|
||||
QCOMPARE( colorNode.key(), QString( "key1" ) );
|
||||
@@ -109,27 +106,27 @@ void TestColorNode::colorNode()
|
||||
QVERIFY( colorNode.isField() ); // Defaults to true if given key only
|
||||
QCOMPARE( colorNode.key(), QString( "key1" ) );
|
||||
QCOMPARE( colorNode.color(), blackTransparent );
|
||||
QCOMPARE( colorNode.color( &record, &vars ), silver80 ); // Defaults to silver if given non-matching record/variables
|
||||
QCOMPARE( colorNode.color( record, vars ), silver80 ); // Defaults to silver if given non-matching record/variables
|
||||
|
||||
record["key1"] = "white";
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), white );
|
||||
QCOMPARE( colorNode.color( record, vars ), white );
|
||||
|
||||
record["key1"] = "red";
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), red );
|
||||
QCOMPARE( colorNode.color( record, vars ), red );
|
||||
|
||||
record["key1"] = "#FF0000";
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), red );
|
||||
QCOMPARE( colorNode.color( record, vars ), red );
|
||||
|
||||
record["key1"] = "#FFFF0000"; // ARGB
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), red );
|
||||
QCOMPARE( colorNode.color( record, vars ), red );
|
||||
|
||||
record["key1"] = "#8000FF00";
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), green80 );
|
||||
QCOMPARE( colorNode.color( record, vars ), green80 );
|
||||
|
||||
colorNode.setKey( "key2" );
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), silver80 );
|
||||
QCOMPARE( colorNode.color( record, vars ), silver80 );
|
||||
record["key2"] = "#8000FF00";
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), green80 );
|
||||
QCOMPARE( colorNode.color( record, vars ), green80 );
|
||||
|
||||
///
|
||||
/// Variable
|
||||
@@ -138,40 +135,40 @@ void TestColorNode::colorNode()
|
||||
QVERIFY( colorNode.isField() ); // Defaults to true if given key only
|
||||
QCOMPARE( colorNode.key(), QString( "c1" ) );
|
||||
QCOMPARE( colorNode.color(), blackTransparent );
|
||||
QCOMPARE( colorNode.color( &record, &vars ), silver80 ); // Defaults to silver if given non-matching record/variables
|
||||
QCOMPARE( colorNode.color( record, vars ), silver80 ); // Defaults to silver if given non-matching record/variables
|
||||
|
||||
{
|
||||
Variable c1( Variable::Type::COLOR, "c1", "white", Variable::Increment::PER_ITEM );
|
||||
vars.addVariable( c1 );
|
||||
}
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), white );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), white );
|
||||
vars.incrementVariablesOnItem();
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), white );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), white );
|
||||
|
||||
{
|
||||
Variable c1( Variable::Type::COLOR, "c1", "red", Variable::Increment::PER_ITEM );
|
||||
vars.addVariable( c1 );
|
||||
}
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), red );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), red );
|
||||
|
||||
{
|
||||
Variable c1( Variable::Type::COLOR, "c1", "#8000FF00", Variable::Increment::PER_ITEM );
|
||||
vars.addVariable( c1 );
|
||||
}
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), green80 );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), green80 );
|
||||
|
||||
colorNode.setKey( "c2" );
|
||||
QCOMPARE( colorNode.color( &record, nullptr ), silver80 );
|
||||
QCOMPARE( colorNode.color( record, vars ), silver80 );
|
||||
|
||||
{
|
||||
Variable c2( Variable::Type::COLOR, "c2", "#8000FF00", Variable::Increment::PER_ITEM );
|
||||
vars.addVariable( c2 );
|
||||
}
|
||||
QCOMPARE( colorNode.color( nullptr, &vars ), green80 );
|
||||
QCOMPARE( colorNode.color( NullRecord(), vars ), green80 );
|
||||
|
||||
///
|
||||
/// Record beats variable
|
||||
///
|
||||
record["c2"] = "red";
|
||||
QCOMPARE( colorNode.color( &record, &vars ), red );
|
||||
QCOMPARE( colorNode.color( record, vars ), red );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestMerge.h"
|
||||
|
||||
#include "merge/Factory.h"
|
||||
@@ -184,7 +185,7 @@ void TestMerge::text()
|
||||
merge->setSource( file.fileName() );
|
||||
QCOMPARE( merge->source(), file.fileName() );
|
||||
|
||||
const QList<Record*>& recordList = merge->recordList();
|
||||
const QList<Record>& recordList = merge->recordList();
|
||||
QCOMPARE( recordList.size(), 6 );
|
||||
|
||||
//
|
||||
@@ -193,54 +194,54 @@ void TestMerge::text()
|
||||
const char* h1 = keyed ? "header1" : "1";
|
||||
const char* h2 = keyed ? "header 2" : "2";
|
||||
const char* h3 = keyed ? "header3" : "3";
|
||||
const Record* record;
|
||||
Record record;
|
||||
|
||||
record = recordList[0];
|
||||
QVERIFY( record->contains( h1 ) );
|
||||
QCOMPARE( record->value( h1 ), QString( " val11" ) );
|
||||
QVERIFY( record->contains( h2 ) );
|
||||
QCOMPARE( record->value( h2 ), QString( "\"val 12\"" ) );
|
||||
QVERIFY( record->contains( h3 ) );
|
||||
QCOMPARE( record->value( h3 ), QString( " \"val 13\"" ) ); // NOTE: Treats as unquoted due to leading spaces
|
||||
QVERIFY( record.contains( h1 ) );
|
||||
QCOMPARE( record.value( h1 ), QString( " val11" ) );
|
||||
QVERIFY( record.contains( h2 ) );
|
||||
QCOMPARE( record.value( h2 ), QString( "\"val 12\"" ) );
|
||||
QVERIFY( record.contains( h3 ) );
|
||||
QCOMPARE( record.value( h3 ), QString( " \"val 13\"" ) ); // NOTE: Treats as unquoted due to leading spaces
|
||||
|
||||
record = recordList[1];
|
||||
QVERIFY( record->contains( h1 ) );
|
||||
QCOMPARE( record->value( h1 ), QString( " val21\"" ) );
|
||||
QVERIFY( record->contains( h2 ) );
|
||||
QCOMPARE( record->value( h2 ), QString( "\"val 22" ) );
|
||||
QVERIFY( record->contains( h3 ) );
|
||||
QCOMPARE( record->value( h3 ), QString( "" ) );
|
||||
QVERIFY( record.contains( h1 ) );
|
||||
QCOMPARE( record.value( h1 ), QString( " val21\"" ) );
|
||||
QVERIFY( record.contains( h2 ) );
|
||||
QCOMPARE( record.value( h2 ), QString( "\"val 22" ) );
|
||||
QVERIFY( record.contains( h3 ) );
|
||||
QCOMPARE( record.value( h3 ), QString( "" ) );
|
||||
|
||||
record = recordList[2];
|
||||
QVERIFY( record->contains( h1 ) );
|
||||
QCOMPARE( record->value( h1 ), QString( "\"\"" ) );
|
||||
QVERIFY( record->contains( h2 ) );
|
||||
QCOMPARE( record->value( h2 ), QString( "val \"32" ) );
|
||||
QVERIFY( record->contains( h3 ) );
|
||||
QCOMPARE( record->value( h3 ), QString( "val \"\"33" ) );
|
||||
QVERIFY( record.contains( h1 ) );
|
||||
QCOMPARE( record.value( h1 ), QString( "\"\"" ) );
|
||||
QVERIFY( record.contains( h2 ) );
|
||||
QCOMPARE( record.value( h2 ), QString( "val \"32" ) );
|
||||
QVERIFY( record.contains( h3 ) );
|
||||
QCOMPARE( record.value( h3 ), QString( "val \"\"33" ) );
|
||||
|
||||
record = recordList[3];
|
||||
QVERIFY( record->contains( h1 ) );
|
||||
QCOMPARE( record->value( h1 ), QString( "" ) );
|
||||
QVERIFY( record->contains( h2 ) );
|
||||
QCOMPARE( record->value( h2 ), QString( "" ) );
|
||||
QVERIFY( record->contains( h3 ) );
|
||||
QCOMPARE( record->value( h3 ), QString( "" ) );
|
||||
QVERIFY( record.contains( h1 ) );
|
||||
QCOMPARE( record.value( h1 ), QString( "" ) );
|
||||
QVERIFY( record.contains( h2 ) );
|
||||
QCOMPARE( record.value( h2 ), QString( "" ) );
|
||||
QVERIFY( record.contains( h3 ) );
|
||||
QCOMPARE( record.value( h3 ), QString( "" ) );
|
||||
|
||||
record = recordList[4];
|
||||
QVERIFY( record->contains( h1 ) );
|
||||
QCOMPARE( record->value( h1 ), QString( "val\n \t r \\ x51" ) );
|
||||
QVERIFY( record->contains( h2 ) );
|
||||
QCOMPARE( record->value( h2 ), QString( "val\n \t r \\ x52" ) );
|
||||
QVERIFY( !record->contains( h3 ) );
|
||||
QVERIFY( record.contains( h1 ) );
|
||||
QCOMPARE( record.value( h1 ), QString( "val\n \t r \\ x51" ) );
|
||||
QVERIFY( record.contains( h2 ) );
|
||||
QCOMPARE( record.value( h2 ), QString( "val\n \t r \\ x52" ) );
|
||||
QVERIFY( !record.contains( h3 ) );
|
||||
|
||||
record = recordList[5];
|
||||
QVERIFY( record->contains( h1 ) );
|
||||
QCOMPARE( record->value( h1 ), QString( "val \"61" ) );
|
||||
QVERIFY( record->contains( h2 ) );
|
||||
QCOMPARE( record->value( h2 ), QString( "val\"" ).append( delim ).append( "\n\"\u2019\\52" ) ); // NOTE: CR missing (QIODevice::Text strips all CRs from stream)
|
||||
QVERIFY( record->contains( h3 ) );
|
||||
QCOMPARE( record->value( h3 ), QString( "val63" ) );
|
||||
QVERIFY( record.contains( h1 ) );
|
||||
QCOMPARE( record.value( h1 ), QString( "val \"61" ) );
|
||||
QVERIFY( record.contains( h2 ) );
|
||||
QCOMPARE( record.value( h2 ), QString( "val\"" ).append( delim ).append( "\n\"\u2019\\52" ) ); // NOTE: CR missing (QIODevice::Text strips all CRs from stream)
|
||||
QVERIFY( record.contains( h3 ) );
|
||||
QCOMPARE( record.value( h3 ), QString( "val63" ) );
|
||||
|
||||
//
|
||||
// Selection
|
||||
@@ -249,13 +250,11 @@ void TestMerge::text()
|
||||
merge->unselectAll();
|
||||
QCOMPARE( merge->nSelectedRecords(), 0 );
|
||||
|
||||
record = recordList[1];
|
||||
merge->select( (Record*)record );
|
||||
merge->setSelected( 1 );
|
||||
QCOMPARE( merge->nSelectedRecords(), 1 );
|
||||
QCOMPARE( merge->selectedRecords().size(), 1 );
|
||||
QCOMPARE( merge->selectedRecords().first(), record ); // Pointers same
|
||||
|
||||
merge->unselect( (Record*)record );
|
||||
merge->setSelected( 1, false );
|
||||
QCOMPARE( merge->nSelectedRecords(), 0 );
|
||||
QCOMPARE( merge->selectedRecords().size(), 0 );
|
||||
|
||||
@@ -291,15 +290,15 @@ void TestMerge::text()
|
||||
QCOMPARE( cloneMerge->id(), merge->id() );
|
||||
QCOMPARE( cloneMerge->source(), merge->source() );
|
||||
QCOMPARE( cloneMerge->recordList().size(), merge->recordList().size() );
|
||||
QCOMPARE( *(cloneMerge->recordList()[0]), *(merge->recordList()[0]) ); // Pointers different
|
||||
QCOMPARE( *(cloneMerge->recordList()[1]), *(merge->recordList()[1]) );
|
||||
QCOMPARE( *(cloneMerge->recordList()[2]), *(merge->recordList()[2]) );
|
||||
QCOMPARE( *(cloneMerge->recordList()[3]), *(merge->recordList()[3]) );
|
||||
QCOMPARE( *(cloneMerge->recordList()[4]), *(merge->recordList()[4]) );
|
||||
QCOMPARE( *(cloneMerge->recordList()[5]), *(merge->recordList()[5]) );
|
||||
QCOMPARE( cloneMerge->recordList()[0], merge->recordList()[0] );
|
||||
QCOMPARE( cloneMerge->recordList()[1], merge->recordList()[1] );
|
||||
QCOMPARE( cloneMerge->recordList()[2], merge->recordList()[2] );
|
||||
QCOMPARE( cloneMerge->recordList()[3], merge->recordList()[3] );
|
||||
QCOMPARE( cloneMerge->recordList()[4], merge->recordList()[4] );
|
||||
QCOMPARE( cloneMerge->recordList()[5], merge->recordList()[5] );
|
||||
QCOMPARE( cloneMerge->nSelectedRecords(), merge->nSelectedRecords() );
|
||||
QCOMPARE( cloneMerge->selectedRecords().size(), merge->selectedRecords().size() );
|
||||
QCOMPARE( *(cloneMerge->selectedRecords()[0]), *(merge->selectedRecords()[0]) );
|
||||
QCOMPARE( cloneMerge->selectedRecords()[0], merge->selectedRecords()[0] );
|
||||
QCOMPARE( cloneMerge->keys(), merge->keys() );
|
||||
QCOMPARE( cloneMerge->primaryKey(), merge->primaryKey() );
|
||||
delete cloneMerge;
|
||||
@@ -333,14 +332,13 @@ void TestMerge::record()
|
||||
QVERIFY( record.contains( "key" ) );
|
||||
QCOMPARE( record["key"], QString( "val" ) );
|
||||
|
||||
Record* cloneRecord = record.clone();
|
||||
QCOMPARE( cloneRecord->isSelected(), true );
|
||||
QVERIFY( cloneRecord->contains( "key" ) );
|
||||
QCOMPARE( cloneRecord->value( "key" ), QString( "val" ) );
|
||||
delete cloneRecord;
|
||||
Record cloneRecord = record;
|
||||
QCOMPARE( cloneRecord.isSelected(), true );
|
||||
QVERIFY( cloneRecord.contains( "key" ) );
|
||||
QCOMPARE( cloneRecord.value( "key" ), QString( "val" ) );
|
||||
|
||||
record.setSelected( false );
|
||||
Record record2( &record );
|
||||
Record record2( record );
|
||||
QCOMPARE( record2.isSelected(), false );
|
||||
QVERIFY( record2.contains( "key" ) );
|
||||
QCOMPARE( record2["key"], QString( "val" ) );
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestModel.h"
|
||||
|
||||
#include "model/Model.h"
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "model/FrameContinuous.h"
|
||||
#include "model/Region.h"
|
||||
#include "model/Settings.h"
|
||||
#include "model/Version.h"
|
||||
|
||||
#include "merge/Factory.h"
|
||||
#include "merge/Merge.h"
|
||||
@@ -36,6 +38,7 @@
|
||||
#include "merge/TextCsv.h"
|
||||
#include "merge/TextCsvKeys.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
|
||||
@@ -48,8 +51,10 @@ using namespace glabels::merge;
|
||||
|
||||
void TestModel::initTestCase()
|
||||
{
|
||||
Factory::init();
|
||||
QCoreApplication::setOrganizationName( glabels::model::Version::ORGANIZATION_NAME );
|
||||
|
||||
Settings::init();
|
||||
Factory::init();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,23 +75,23 @@ void TestModel::model()
|
||||
QCOMPARE( model.h(), Distance( 0 ) );
|
||||
|
||||
Template tmplate( "Test Brand", "part", "desc", "testPaperId", 100, 400 );
|
||||
FrameRect* frame = new FrameRect( 100, 200, 5, 0, 0, "rect1" );
|
||||
QVERIFY( frame->w() != frame->h() );
|
||||
FrameRect frame( 100, 200, 5, 0, 0, "rect1" );
|
||||
QVERIFY( frame.w() != frame.h() );
|
||||
tmplate.addFrame( frame );
|
||||
model.setTmplate( &tmplate ); // Copies
|
||||
QCOMPARE( model.tmplate()->brand(), QString( "Test Brand" ) );
|
||||
QCOMPARE( model.tmplate()->part(), QString( "part" ) );
|
||||
QCOMPARE( model.tmplate()->description(), QString( "desc" ) );
|
||||
QCOMPARE( model.tmplate()->paperId(), QString( "testPaperId" ) );
|
||||
QCOMPARE( model.tmplate()->pageWidth(), Distance( 100 ) );
|
||||
QCOMPARE( model.tmplate()->pageHeight(), Distance( 400 ) );
|
||||
model.setTmplate( tmplate ); // Copies
|
||||
QCOMPARE( model.tmplate().brand(), QString( "Test Brand" ) );
|
||||
QCOMPARE( model.tmplate().part(), QString( "part" ) );
|
||||
QCOMPARE( model.tmplate().description(), QString( "desc" ) );
|
||||
QCOMPARE( model.tmplate().paperId(), QString( "testPaperId" ) );
|
||||
QCOMPARE( model.tmplate().pageWidth(), Distance( 100 ) );
|
||||
QCOMPARE( model.tmplate().pageHeight(), Distance( 400 ) );
|
||||
QVERIFY( model.isModified() );
|
||||
|
||||
QVERIFY( model.frame()->id() == frame->id() );
|
||||
QVERIFY( model.frame()->id() == frame.id() );
|
||||
QCOMPARE( model.w(), Distance( 100 ) );
|
||||
QCOMPARE( model.h(), Distance( 200 ) );
|
||||
QCOMPARE( model.w(), frame->w() );
|
||||
QCOMPARE( model.h(), frame->h() );
|
||||
QCOMPARE( model.w(), frame.w() );
|
||||
QCOMPARE( model.h(), frame.h() );
|
||||
|
||||
model.clearModified();
|
||||
QVERIFY( !model.isModified() );
|
||||
@@ -99,8 +104,8 @@ void TestModel::model()
|
||||
QVERIFY( model.rotate() );
|
||||
QVERIFY( model.isModified() );
|
||||
|
||||
QCOMPARE( model.w(), frame->h() );
|
||||
QCOMPARE( model.h(), frame->w() );
|
||||
QCOMPARE( model.w(), frame.h() );
|
||||
QCOMPARE( model.h(), frame.w() );
|
||||
|
||||
model.setRotate( false );
|
||||
QVERIFY( !model.rotate() );
|
||||
@@ -109,20 +114,20 @@ void TestModel::model()
|
||||
QVERIFY( !model.isModified() );
|
||||
|
||||
model.setH( 300 ); // Default does nothing
|
||||
QCOMPARE( model.h(), Distance( 200 ) );
|
||||
QVERIFY( model.isModified() ); // Set anyway
|
||||
QCOMPARE( model.h(), Distance( 200 ) ); // Should still bee 200
|
||||
QVERIFY( !model.isModified() ); // Should not be modified
|
||||
|
||||
// Continuous frame implements setH()
|
||||
Template tmplate2( "Test Brand2", "part2", "desc2", "testPaperId2", 100, 400 );
|
||||
FrameContinuous* frame2 = new FrameContinuous( 100, 0, 500, 200, "continuous1" );
|
||||
QCOMPARE( frame2->h(), Distance( 200 ) );
|
||||
FrameContinuous frame2( 100, 0, 500, 200, "continuous1" );
|
||||
QCOMPARE( frame2.h(), Distance( 200 ) );
|
||||
tmplate2.addFrame( frame2 );
|
||||
model.setTmplate( &tmplate2 );
|
||||
QVERIFY( model.frame()->id() == frame2->id() );
|
||||
model.setTmplate( tmplate2 );
|
||||
QVERIFY( model.frame()->id() == frame2.id() );
|
||||
QCOMPARE( model.w(), Distance( 100 ) );
|
||||
QCOMPARE( model.h(), Distance( 200 ) );
|
||||
QCOMPARE( model.w(), frame2->w() );
|
||||
QCOMPARE( model.h(), frame2->h() );
|
||||
QCOMPARE( model.w(), frame2.w() );
|
||||
QCOMPARE( model.h(), frame2.h() );
|
||||
|
||||
model.clearModified();
|
||||
QVERIFY( !model.isModified() );
|
||||
@@ -300,10 +305,10 @@ void TestModel::saveRestore()
|
||||
// Set template/frame
|
||||
//
|
||||
Template tmplate( "Test Brand", "part", "desc", "testPaperId", 110, 410 );
|
||||
FrameRect* frame = new FrameRect( 120, 220, 5, 0, 0, "rect1" );
|
||||
FrameRect frame( 120, 220, 5, 0, 0, "rect1" );
|
||||
tmplate.addFrame( frame );
|
||||
model->setTmplate( &tmplate ); // Copies
|
||||
QCOMPARE( model->tmplate()->brand(), QString( "Test Brand" ) );
|
||||
model->setTmplate( tmplate ); // Copies
|
||||
QCOMPARE( model->tmplate().brand(), QString( "Test Brand" ) );
|
||||
QVERIFY( model->isModified() );
|
||||
|
||||
model->clearModified();
|
||||
@@ -327,9 +332,9 @@ void TestModel::saveRestore()
|
||||
|
||||
Variable i( Variable::Type::INTEGER, "i", "2", Variable::Increment::PER_ITEM, "2" );
|
||||
Variable f( Variable::Type::FLOATING_POINT, "f", "6.54", Variable::Increment::PER_COPY, "0.12" );
|
||||
model->variables()->addVariable( i );
|
||||
model->variables().addVariable( i );
|
||||
QVERIFY( model->isModified() );
|
||||
model->variables()->addVariable( f );
|
||||
model->variables().addVariable( f );
|
||||
QVERIFY( model->isModified() );
|
||||
|
||||
model->clearModified();
|
||||
@@ -375,7 +380,6 @@ void TestModel::saveRestore()
|
||||
Model* saved = model->save();
|
||||
QVERIFY( saved->isModified() );
|
||||
QCOMPARE( saved->merge(), model->merge() ); // Shared
|
||||
QCOMPARE( saved->variables(), model->variables() ); // Shared
|
||||
QCOMPARE( saved->isModified(), model->isModified() );
|
||||
QCOMPARE( saved->shortName(), modelShortName );
|
||||
QCOMPARE( saved->shortName(), model->shortName() );
|
||||
@@ -391,10 +395,10 @@ void TestModel::saveRestore()
|
||||
|
||||
// Modify original
|
||||
Template tmplate2( "Test Brand2", "part2", "desc2", "testPaperId2", 230, 630 );
|
||||
FrameRect* frame2 = new FrameRect( 240, 340, 5, 0, 0, "rect2" );
|
||||
FrameRect frame2( 240, 340, 5, 0, 0, "rect2" );
|
||||
tmplate2.addFrame( frame2 );
|
||||
model->setTmplate( &tmplate2 );
|
||||
QCOMPARE( model->tmplate()->brand(), QString( "Test Brand2" ) );
|
||||
model->setTmplate( tmplate2 );
|
||||
QCOMPARE( model->tmplate().brand(), QString( "Test Brand2" ) );
|
||||
QCOMPARE( model->w(), Distance( 240 ) );
|
||||
QCOMPARE( model->h(), Distance( 340 ) );
|
||||
|
||||
@@ -419,21 +423,20 @@ void TestModel::saveRestore()
|
||||
QCOMPARE( merge2->source(), csv2.fileName() );
|
||||
QCOMPARE( merge2->recordList().size(), 4 );
|
||||
|
||||
model->setMerge( merge2 ); // Deletes original so saved->merge() now invalid
|
||||
model->setMerge( merge2 );
|
||||
QCOMPARE( model->merge(), merge2 );
|
||||
|
||||
Model* modified = model->save();
|
||||
QCOMPARE( modified->merge(), merge2 ); // Shared
|
||||
|
||||
Variable c( Variable::Type::COLOR, "c", "blue", Variable::Increment::PER_PAGE );
|
||||
model->variables()->addVariable( c );
|
||||
QCOMPARE( model->variables(), saved->variables() ); // Shared.
|
||||
model->variables().addVariable( c );
|
||||
|
||||
// Verify differences
|
||||
QVERIFY( model->shortName() != modelShortName );
|
||||
QVERIFY( model->shortName() != saved->shortName() );
|
||||
QVERIFY( model->fileName() != saved->fileName() );
|
||||
QVERIFY( model->tmplate()->brand() != saved->tmplate()->brand() );
|
||||
QVERIFY( model->tmplate().brand() != saved->tmplate().brand() );
|
||||
QVERIFY( model->rotate() != saved->rotate() );
|
||||
QVERIFY( model->w() != saved->w() );
|
||||
QVERIFY( model->h() != saved->h() );
|
||||
@@ -448,7 +451,7 @@ void TestModel::saveRestore()
|
||||
QCOMPARE( model->shortName(), modelShortName );
|
||||
QCOMPARE( model->shortName(), saved->shortName() );
|
||||
QCOMPARE( model->fileName(), saved->fileName() );
|
||||
QCOMPARE( model->tmplate()->brand(), saved->tmplate()->brand() );
|
||||
QCOMPARE( model->tmplate().brand(), saved->tmplate().brand() );
|
||||
QCOMPARE( model->rotate(), saved->rotate() );
|
||||
QCOMPARE( model->w(), saved->w() );
|
||||
QCOMPARE( model->h(), saved->h() );
|
||||
@@ -459,16 +462,12 @@ void TestModel::saveRestore()
|
||||
QCOMPARE( model->objectList().at(1)->x0(), saved->objectList().at(1)->x0() );
|
||||
QCOMPARE( model->objectList().at(1)->y0(), saved->objectList().at(1)->y0() );
|
||||
|
||||
QCOMPARE( model->merge(), merge2 ); // Unchanged
|
||||
QVERIFY( model->merge() != saved->merge() ); // NOTE saved->merge() now points to deleted object
|
||||
QCOMPARE( model->variables(), saved->variables() ); // Unchanged
|
||||
|
||||
// Unrestore
|
||||
model->restore( modified );
|
||||
QVERIFY( model->shortName() != modelShortName );
|
||||
QVERIFY( model->shortName() != saved->shortName() );
|
||||
QVERIFY( model->fileName() != saved->fileName() );
|
||||
QVERIFY( model->tmplate()->brand() != saved->tmplate()->brand() );
|
||||
QVERIFY( model->tmplate().brand() != saved->tmplate().brand() );
|
||||
QVERIFY( model->rotate() != saved->rotate() );
|
||||
QVERIFY( model->w() != saved->w() );
|
||||
QVERIFY( model->h() != saved->h() );
|
||||
@@ -477,11 +476,10 @@ void TestModel::saveRestore()
|
||||
QVERIFY( model->objectList().at(0)->x0() != saved->objectList().at(0)->x0() );
|
||||
QVERIFY( model->objectList().at(0)->y0() != saved->objectList().at(0)->y0() );
|
||||
QCOMPARE( model->merge(), merge2 ); // Same
|
||||
QCOMPARE( model->variables(), saved->variables() ); // Same
|
||||
|
||||
QCOMPARE( model->shortName(), modified->shortName() );
|
||||
QCOMPARE( model->fileName(), modified->fileName() );
|
||||
QCOMPARE( model->tmplate()->brand(), modified->tmplate()->brand() );
|
||||
QCOMPARE( model->tmplate().brand(), modified->tmplate().brand() );
|
||||
QCOMPARE( model->rotate(), modified->rotate() );
|
||||
QCOMPARE( model->w(), modified->w() );
|
||||
QCOMPARE( model->h(), modified->h() );
|
||||
@@ -489,8 +487,6 @@ void TestModel::saveRestore()
|
||||
QCOMPARE( model->objectList().at(0)->x0(), modified->objectList().at(0)->x0() );
|
||||
QCOMPARE( model->objectList().at(0)->y0(), modified->objectList().at(0)->y0() );
|
||||
|
||||
delete model->merge(); // Final instance owned by us
|
||||
delete model->variables(); // Instance owned by us
|
||||
delete model;
|
||||
delete saved;
|
||||
delete modified;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestModelImageObject.h"
|
||||
#include "Test_Constants.h"
|
||||
|
||||
@@ -85,7 +86,7 @@ void TestModelImageObject::readImageFile()
|
||||
QFileInfo pngGreenFileInfo( pngGreen.fileName() );
|
||||
|
||||
Variable var( Variable::Type::STRING, "var", pngGreenFileInfo.fileName(), Variable::Increment::PER_ITEM ); // Relative path
|
||||
model.variables()->addVariable( var );
|
||||
model.variables().addVariable( var );
|
||||
|
||||
model.addObject( object.clone() );
|
||||
|
||||
@@ -103,7 +104,7 @@ void TestModelImageObject::readImageFile()
|
||||
QFileInfo svgMagentaFileInfo( svgMagenta.fileName() );
|
||||
|
||||
Variable var2( Variable::Type::STRING, "var2", svgMagentaFileInfo.fileName(), Variable::Increment::PER_ITEM ); // Absolute path
|
||||
model.variables()->addVariable( var2 );
|
||||
model.variables().addVariable( var2 );
|
||||
|
||||
model.addObject( object.clone() );
|
||||
|
||||
@@ -187,7 +188,7 @@ void TestModelImageObject::readImageFile()
|
||||
///
|
||||
/// Draw
|
||||
///
|
||||
const QList<Record*> records = merge->selectedRecords();
|
||||
const QList<Record> records = merge->selectedRecords();
|
||||
QCOMPARE( records.size(), 8 );
|
||||
|
||||
QImage paintDevice( 10, 10 * model.objectList().size() * records.size(), QImage::Format_RGB32 );
|
||||
@@ -207,7 +208,7 @@ void TestModelImageObject::readImageFile()
|
||||
{
|
||||
// Merge
|
||||
qDebug() << "record" << i;
|
||||
color = records[i]->value( "type" ) == "png" ? Qt::blue : Qt::red;
|
||||
color = records[i].value( "type" ) == "png" ? Qt::blue : Qt::red;
|
||||
QCOMPARE( paintDevice.pixelColor( 1, 0 + i * yTranslate ), white );
|
||||
QCOMPARE( paintDevice.pixelColor( 1, 1 + i * yTranslate ), color );
|
||||
QCOMPARE( paintDevice.pixelColor( 1, 8 + i * yTranslate ), color );
|
||||
@@ -246,7 +247,4 @@ void TestModelImageObject::readImageFile()
|
||||
QCOMPARE( paintDevice.pixelColor( 1, 49 + i * yTranslate ), white );
|
||||
QCOMPARE( paintDevice.pixelColor( 9, 49 + i * yTranslate ), magentaShadow );
|
||||
}
|
||||
|
||||
delete model.merge();
|
||||
delete model.variables();
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestRawText.h"
|
||||
|
||||
#include "model/RawText.h"
|
||||
|
||||
#include "merge/Record.h"
|
||||
|
||||
#include <QtDebug>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
QTEST_MAIN(TestRawText)
|
||||
@@ -38,18 +39,20 @@ void TestRawText::rawText()
|
||||
RawText rawText;
|
||||
Record record;
|
||||
|
||||
Variables variables;
|
||||
|
||||
QVERIFY( rawText.isEmpty() );
|
||||
QVERIFY( !rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.toString(), QString( "" ) );
|
||||
QCOMPARE( rawText.toStdString(), std::string( "" ) );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "" ) );
|
||||
|
||||
rawText = "text";
|
||||
QVERIFY( !rawText.isEmpty() );
|
||||
QVERIFY( !rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.toString(), QString( "text" ) );
|
||||
QCOMPARE( rawText.toStdString(), std::string( "text" ) );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "text" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "text" ) );
|
||||
|
||||
RawText rawText2( "text" );
|
||||
QVERIFY( !rawText2.isEmpty() );
|
||||
@@ -61,34 +64,34 @@ void TestRawText::rawText()
|
||||
QVERIFY( rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.toString(), QString( "${key1}" ) );
|
||||
QCOMPARE( rawText.toStdString(), std::string( "${key1}" ) );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "" ) );
|
||||
|
||||
///
|
||||
/// Record
|
||||
///
|
||||
record["key1"] = "val1";
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "val1" ) );
|
||||
|
||||
rawText = "${key1}${key2}";
|
||||
QVERIFY( rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "val1" ) );
|
||||
|
||||
record["key2"] = "val2";
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1val2" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "val1val2" ) );
|
||||
|
||||
rawText = "${key1}text${key2}";
|
||||
QVERIFY( rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1textval2" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "val1textval2" ) );
|
||||
|
||||
rawText = "text1${key1}text2${key2}text3";
|
||||
QVERIFY( rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "text1val1text2val2text3" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "text1val1text2val2text3" ) );
|
||||
|
||||
rawText = "${key1}text${key2}${key3}";
|
||||
QVERIFY( rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1textval2" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "val1textval2" ) );
|
||||
|
||||
rawText = "${key2}${key3}${key1}";
|
||||
QVERIFY( rawText.hasPlaceHolders() );
|
||||
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val2val1" ) );
|
||||
QCOMPARE( rawText.expand( record, variables ), QString( "val2val1" ) );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestSubstitutionField.h"
|
||||
|
||||
#include "model/SubstitutionField.h"
|
||||
@@ -174,10 +175,10 @@ void TestSubstitutionField::simpleEvaluation()
|
||||
record1[ "3" ] = "Opqrstu";
|
||||
record1[ "4" ] = "Vwxyz!@";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "Abcdefg" ) );
|
||||
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "Hijklmn" ) );
|
||||
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "Opqrstu" ) );
|
||||
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "Vwxyz!@" ) );
|
||||
QCOMPARE( f1.evaluate( record1, variables ), QString( "Abcdefg" ) );
|
||||
QCOMPARE( f2.evaluate( record1, variables ), QString( "Hijklmn" ) );
|
||||
QCOMPARE( f3.evaluate( record1, variables ), QString( "Opqrstu" ) );
|
||||
QCOMPARE( f4.evaluate( record1, variables ), QString( "Vwxyz!@" ) );
|
||||
|
||||
merge::Record record2;
|
||||
record2[ "1" ] = "1234567";
|
||||
@@ -185,10 +186,10 @@ void TestSubstitutionField::simpleEvaluation()
|
||||
record2[ "3" ] = "8901234";
|
||||
record2[ "4" ] = "#$%^&*";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record2, &variables ), QString( "1234567" ) );
|
||||
QCOMPARE( f2.evaluate( &record2, &variables ), QString( "FooBar" ) );
|
||||
QCOMPARE( f3.evaluate( &record2, &variables ), QString( "8901234" ) );
|
||||
QCOMPARE( f4.evaluate( &record2, &variables ), QString( "#$%^&*" ) );
|
||||
QCOMPARE( f1.evaluate( record2, variables ), QString( "1234567" ) );
|
||||
QCOMPARE( f2.evaluate( record2, variables ), QString( "FooBar" ) );
|
||||
QCOMPARE( f3.evaluate( record2, variables ), QString( "8901234" ) );
|
||||
QCOMPARE( f4.evaluate( record2, variables ), QString( "#$%^&*" ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -209,17 +210,17 @@ void TestSubstitutionField::defaultValueEvaluation()
|
||||
record1[ "3" ] = "Opqrstu";
|
||||
record1[ "4" ] = "Vwxyz!@";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "Abcdefg" ) );
|
||||
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "Hijklmn" ) );
|
||||
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "Opqrstu" ) );
|
||||
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "Vwxyz!@" ) );
|
||||
QCOMPARE( f1.evaluate( record1, variables ), QString( "Abcdefg" ) );
|
||||
QCOMPARE( f2.evaluate( record1, variables ), QString( "Hijklmn" ) );
|
||||
QCOMPARE( f3.evaluate( record1, variables ), QString( "Opqrstu" ) );
|
||||
QCOMPARE( f4.evaluate( record1, variables ), QString( "Vwxyz!@" ) );
|
||||
|
||||
merge::Record record2; // All fields empty
|
||||
|
||||
QCOMPARE( f1.evaluate( &record2, &variables ), QString( "foo1" ) );
|
||||
QCOMPARE( f2.evaluate( &record2, &variables ), QString( "foo2" ) );
|
||||
QCOMPARE( f3.evaluate( &record2, &variables ), QString( "foo3" ) );
|
||||
QCOMPARE( f4.evaluate( &record2, &variables ), QString( "foo4" ) );
|
||||
QCOMPARE( f1.evaluate( record2, variables ), QString( "foo1" ) );
|
||||
QCOMPARE( f2.evaluate( record2, variables ), QString( "foo2" ) );
|
||||
QCOMPARE( f3.evaluate( record2, variables ), QString( "foo3" ) );
|
||||
QCOMPARE( f4.evaluate( record2, variables ), QString( "foo4" ) );
|
||||
|
||||
merge::Record record3;
|
||||
record3[ "1" ] = "xyzzy";
|
||||
@@ -227,10 +228,10 @@ void TestSubstitutionField::defaultValueEvaluation()
|
||||
// Field "3" empty
|
||||
record3[ "4" ] = "plugh";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record3, &variables ), QString( "xyzzy" ) );
|
||||
QCOMPARE( f2.evaluate( &record3, &variables ), QString( "foo2" ) );
|
||||
QCOMPARE( f3.evaluate( &record3, &variables ), QString( "foo3" ) );
|
||||
QCOMPARE( f4.evaluate( &record3, &variables ), QString( "plugh" ) );
|
||||
QCOMPARE( f1.evaluate( record3, variables ), QString( "xyzzy" ) );
|
||||
QCOMPARE( f2.evaluate( record3, variables ), QString( "foo2" ) );
|
||||
QCOMPARE( f3.evaluate( record3, variables ), QString( "foo3" ) );
|
||||
QCOMPARE( f4.evaluate( record3, variables ), QString( "plugh" ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -261,15 +262,15 @@ void TestSubstitutionField::formattedStringEvaluation()
|
||||
record1[ "7" ] = "-100";
|
||||
record1[ "8" ] = "3.14";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record1, &variables ), QString( " 0" ) );
|
||||
QCOMPARE( f2.evaluate( &record1, &variables ), QString( " 1" ) );
|
||||
QCOMPARE( f3.evaluate( &record1, &variables ), QString( " -1" ) );
|
||||
QCOMPARE( f4.evaluate( &record1, &variables ), QString( " 3.14" ) );
|
||||
QCOMPARE( f1.evaluate( record1, variables ), QString( " 0" ) );
|
||||
QCOMPARE( f2.evaluate( record1, variables ), QString( " 1" ) );
|
||||
QCOMPARE( f3.evaluate( record1, variables ), QString( " -1" ) );
|
||||
QCOMPARE( f4.evaluate( record1, variables ), QString( " 3.14" ) );
|
||||
|
||||
QCOMPARE( f5.evaluate( &record1, &variables ), QString( "0 " ) );
|
||||
QCOMPARE( f6.evaluate( &record1, &variables ), QString( "100 " ) );
|
||||
QCOMPARE( f7.evaluate( &record1, &variables ), QString( "-100 " ) );
|
||||
QCOMPARE( f8.evaluate( &record1, &variables ), QString( "3.14 " ) );
|
||||
QCOMPARE( f5.evaluate( record1, variables ), QString( "0 " ) );
|
||||
QCOMPARE( f6.evaluate( record1, variables ), QString( "100 " ) );
|
||||
QCOMPARE( f7.evaluate( record1, variables ), QString( "-100 " ) );
|
||||
QCOMPARE( f8.evaluate( record1, variables ), QString( "3.14 " ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -300,15 +301,15 @@ void TestSubstitutionField::formattedFloatEvaluation()
|
||||
record1[ "7" ] = "-100";
|
||||
record1[ "8" ] = "3.14";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "+0.00" ) );
|
||||
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "+1.00" ) );
|
||||
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "-1.00" ) );
|
||||
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "+3.14" ) );
|
||||
QCOMPARE( f1.evaluate( record1, variables ), QString( "+0.00" ) );
|
||||
QCOMPARE( f2.evaluate( record1, variables ), QString( "+1.00" ) );
|
||||
QCOMPARE( f3.evaluate( record1, variables ), QString( "-1.00" ) );
|
||||
QCOMPARE( f4.evaluate( record1, variables ), QString( "+3.14" ) );
|
||||
|
||||
QCOMPARE( f5.evaluate( &record1, &variables ), QString( "+0.00e+00" ) );
|
||||
QCOMPARE( f6.evaluate( &record1, &variables ), QString( "+1.00e+02" ) );
|
||||
QCOMPARE( f7.evaluate( &record1, &variables ), QString( "-1.00e+02" ) );
|
||||
QCOMPARE( f8.evaluate( &record1, &variables ), QString( "+3.14e+00" ) );
|
||||
QCOMPARE( f5.evaluate( record1, variables ), QString( "+0.00e+00" ) );
|
||||
QCOMPARE( f6.evaluate( record1, variables ), QString( "+1.00e+02" ) );
|
||||
QCOMPARE( f7.evaluate( record1, variables ), QString( "-1.00e+02" ) );
|
||||
QCOMPARE( f8.evaluate( record1, variables ), QString( "+3.14e+00" ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -339,15 +340,15 @@ void TestSubstitutionField::formattedIntEvaluation()
|
||||
record1[ "7" ] = "-1";
|
||||
record1[ "8" ] = "314";
|
||||
|
||||
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "00000000" ) );
|
||||
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "00000001" ) );
|
||||
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "-0000001" ) );
|
||||
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "00000000" ) ); // Invalid integer value
|
||||
QCOMPARE( f1.evaluate( record1, variables ), QString( "00000000" ) );
|
||||
QCOMPARE( f2.evaluate( record1, variables ), QString( "00000001" ) );
|
||||
QCOMPARE( f3.evaluate( record1, variables ), QString( "-0000001" ) );
|
||||
QCOMPARE( f4.evaluate( record1, variables ), QString( "00000000" ) ); // Invalid integer value
|
||||
|
||||
QCOMPARE( f5.evaluate( &record1, &variables ), QString( "00000064" ) ); // 100(decimal) == 64(hex)
|
||||
QCOMPARE( f6.evaluate( &record1, &variables ), QString( "00000100" ) );
|
||||
QCOMPARE( f7.evaluate( &record1, &variables ), QString( "00000000" ) ); // Invalid unsigned integer
|
||||
QCOMPARE( f8.evaluate( &record1, &variables ), QString( "0000013a" ) ); // 314(decimal) == 13a(hex)
|
||||
QCOMPARE( f5.evaluate( record1, variables ), QString( "00000064" ) ); // 100(decimal) == 64(hex)
|
||||
QCOMPARE( f6.evaluate( record1, variables ), QString( "00000100" ) );
|
||||
QCOMPARE( f7.evaluate( record1, variables ), QString( "00000000" ) ); // Invalid unsigned integer
|
||||
QCOMPARE( f8.evaluate( record1, variables ), QString( "0000013a" ) ); // 314(decimal) == 13a(hex)
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +371,7 @@ void TestSubstitutionField::newLineEvaluation()
|
||||
merge::Record record3;
|
||||
// ADDR2 not defined
|
||||
|
||||
QCOMPARE( addr2.evaluate( &record1, &variables ), QString( "\nApt. 5B" ) ); // Prepends a newline
|
||||
QCOMPARE( addr2.evaluate( &record2, &variables ), QString( "" ) ); // Evaluates empty
|
||||
QCOMPARE( addr2.evaluate( &record3, &variables ), QString( "" ) ); // Evaluates empty
|
||||
QCOMPARE( addr2.evaluate( record1, variables ), QString( "\nApt. 5B" ) ); // Prepends a newline
|
||||
QCOMPARE( addr2.evaluate( record2, variables ), QString( "" ) ); // Evaluates empty
|
||||
QCOMPARE( addr2.evaluate( record3, variables ), QString( "" ) ); // Evaluates empty
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestTextNode.h"
|
||||
|
||||
#include "model/TextNode.h"
|
||||
@@ -41,30 +42,24 @@ void TestTextNode::textNode()
|
||||
QCOMPARE( textNode.data(), QString( "" ) );
|
||||
QVERIFY( textNode == TextNode() );
|
||||
QVERIFY( !(textNode != TextNode()) );
|
||||
QCOMPARE( textNode.text( nullptr, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( &record, &vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "" ) );
|
||||
|
||||
textNode.setField( true );
|
||||
QVERIFY( textNode.isField() );
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "" ) );
|
||||
|
||||
textNode.setField( false );
|
||||
QVERIFY( !textNode.isField() );
|
||||
|
||||
textNode.setData( QString( "data1" ) );
|
||||
QCOMPARE( textNode.data(), QString( "data1" ) );
|
||||
QCOMPARE( textNode.text( nullptr, nullptr ), QString( "data1" ) );
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "data1" ) );
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "data1" ) );
|
||||
QCOMPARE( textNode.text( &record, &vars ), QString( "data1" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "data1" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "data1" ) );
|
||||
|
||||
textNode.setField( true );
|
||||
QCOMPARE( textNode.text( nullptr, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( &record, &vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "" ) );
|
||||
|
||||
///
|
||||
/// Constructors
|
||||
@@ -86,13 +81,13 @@ void TestTextNode::textNode()
|
||||
/// Record
|
||||
///
|
||||
record["key1"] = "";
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "" ) );
|
||||
|
||||
textNode.setData( QString( "key1" ) );
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "" ) );
|
||||
|
||||
record["key1"] = "val1";
|
||||
QCOMPARE( textNode.text( &record, nullptr ), QString( "val1" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "val1" ) );
|
||||
|
||||
///
|
||||
/// Variable
|
||||
@@ -101,24 +96,24 @@ void TestTextNode::textNode()
|
||||
Variable key1( Variable::Type::STRING, "key1", "", Variable::Increment::PER_ITEM );
|
||||
vars.addVariable( key1 );
|
||||
}
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "" ) );
|
||||
|
||||
{
|
||||
Variable key1( Variable::Type::STRING, "key1", "val1", Variable::Increment::PER_ITEM );
|
||||
vars.addVariable( key1 );
|
||||
}
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "val1" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "val1" ) );
|
||||
|
||||
{
|
||||
Variable key1( Variable::Type::INTEGER, "key1", "1", Variable::Increment::PER_ITEM, "1" );
|
||||
vars.addVariable( key1 );
|
||||
}
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "1" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "1" ) );
|
||||
vars.incrementVariablesOnItem();
|
||||
QCOMPARE( textNode.text( nullptr, &vars ), QString( "2" ) );
|
||||
QCOMPARE( textNode.text( NullRecord(), vars ), QString( "2" ) );
|
||||
|
||||
///
|
||||
/// Record beats variable
|
||||
///
|
||||
QCOMPARE( textNode.text( &record, &vars ), QString( "val1" ) );
|
||||
QCOMPARE( textNode.text( record, vars ), QString( "val1" ) );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "TestXmlLabel.h"
|
||||
#include "Test_Constants.h"
|
||||
|
||||
@@ -25,12 +26,16 @@
|
||||
#include "model/XmlLabelParser.h"
|
||||
|
||||
#include "barcode/Backends.h"
|
||||
|
||||
#include "model/Db.h"
|
||||
#include "model/ColorNode.h"
|
||||
#include "model/FrameRect.h"
|
||||
#include "model/Markup.h"
|
||||
#include "model/Model.h"
|
||||
#include "model/PageRenderer.h"
|
||||
#include "model/Settings.h"
|
||||
#include "model/Size.h"
|
||||
#include "model/Version.h"
|
||||
|
||||
#include "model/ModelBarcodeObject.h"
|
||||
#include "model/ModelBoxObject.h"
|
||||
@@ -39,12 +44,13 @@
|
||||
#include "model/ModelImageObject.h"
|
||||
#include "model/ModelTextObject.h"
|
||||
|
||||
#include "model/Db.h"
|
||||
#include "merge/Factory.h"
|
||||
#include "merge/Merge.h"
|
||||
#include "merge/TextCsvKeys.h"
|
||||
|
||||
#include <QtDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
QTEST_MAIN(TestXmlLabel)
|
||||
@@ -62,6 +68,8 @@ namespace
|
||||
|
||||
void TestXmlLabel::initTestCase()
|
||||
{
|
||||
QCoreApplication::setOrganizationName( glabels::model::Version::ORGANIZATION_NAME );
|
||||
|
||||
Settings::init();
|
||||
Db::init();
|
||||
Factory::init();
|
||||
@@ -80,11 +88,11 @@ void TestXmlLabel::serializeDeserialize()
|
||||
// Empty object list
|
||||
//
|
||||
QCOMPARE( objects.count(), 0 );
|
||||
XmlLabelCreator::serializeObjects( objects, model, buffer );
|
||||
buffer = XmlLabelCreator::serializeObjects( objects, model );
|
||||
outObjects = XmlLabelParser::deserializeObjects( buffer, model );
|
||||
QCOMPARE( objects.count(), outObjects.count() );
|
||||
QCOMPARE( objects, outObjects );
|
||||
XmlLabelCreator::serializeObjects( outObjects, model, outBuffer );
|
||||
outBuffer = XmlLabelCreator::serializeObjects( outObjects, model );
|
||||
QCOMPARE( buffer, outBuffer );
|
||||
|
||||
//
|
||||
@@ -117,7 +125,7 @@ void TestXmlLabel::serializeDeserialize()
|
||||
QCOMPARE( objects.count(), 11 );
|
||||
|
||||
buffer.clear();
|
||||
XmlLabelCreator::serializeObjects( objects, model, buffer );
|
||||
buffer = XmlLabelCreator::serializeObjects( objects, model );
|
||||
|
||||
QVERIFY( svgRelative.remove() ); // Delete to make sure it's not read from file on parse
|
||||
|
||||
@@ -172,14 +180,7 @@ void TestXmlLabel::serializeDeserialize()
|
||||
QCOMPARE( objects.at(i)->filenameNode().data(), outObjects.at(i)->filenameNode().data() );
|
||||
}
|
||||
|
||||
if ( objects.at(i)->image() )
|
||||
{
|
||||
QCOMPARE( *(objects.at(i)->image()), *(outObjects.at(i)->image()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QCOMPARE( objects.at(i)->image(), outObjects.at(i)->image() );
|
||||
}
|
||||
QCOMPARE( objects.at(i)->image(), outObjects.at(i)->image() );
|
||||
QCOMPARE( objects.at(i)->svg(), outObjects.at(i)->svg() );
|
||||
|
||||
QCOMPARE( objects.at(i)->lineWidth(), outObjects.at(i)->lineWidth() );
|
||||
@@ -200,12 +201,12 @@ void TestXmlLabel::serializeDeserialize()
|
||||
}
|
||||
|
||||
outBuffer.clear();
|
||||
XmlLabelCreator::serializeObjects( outObjects, model, outBuffer );
|
||||
outBuffer = XmlLabelCreator::serializeObjects( outObjects, model );
|
||||
|
||||
QCOMPARE( buffer, outBuffer );
|
||||
|
||||
delete model->merge();
|
||||
delete model->variables();
|
||||
qDeleteAll( objects );
|
||||
qDeleteAll( outObjects );
|
||||
delete model;
|
||||
}
|
||||
|
||||
@@ -279,23 +280,22 @@ void TestXmlLabel::writeReadFile()
|
||||
/// Add template
|
||||
///
|
||||
Template tmplate( "Test Brand", "part", "desc", "testPaperId", 110, 410 );
|
||||
FrameRect* frame = new FrameRect( 120, 220, 5, 0, 0, "rect1" );
|
||||
FrameRect frame( 120, 220, 5, 0, 0, "rect1" );
|
||||
tmplate.addFrame( frame );
|
||||
model->setTmplate( &tmplate ); // Copies
|
||||
model->setTmplate( tmplate ); // Copies
|
||||
|
||||
///
|
||||
/// Add variables
|
||||
///
|
||||
Variables vars;
|
||||
Variable s( Variable::Type::STRING, "s", "initial", Variable::Increment::NEVER );
|
||||
Variable c( Variable::Type::COLOR, "c", "red", Variable::Increment::PER_COPY );
|
||||
Variable i( Variable::Type::INTEGER, "i", "123", Variable::Increment::PER_ITEM, "1" );
|
||||
Variable f( Variable::Type::FLOATING_POINT, "f", "12.3", Variable::Increment::PER_PAGE, "0.2" );
|
||||
model->variables()->addVariable( s );
|
||||
model->variables()->addVariable( c );
|
||||
model->variables()->addVariable( i );
|
||||
model->variables()->addVariable( f );
|
||||
QCOMPARE( model->variables()->size(), 4 );
|
||||
model->variables().addVariable( s );
|
||||
model->variables().addVariable( c );
|
||||
model->variables().addVariable( i );
|
||||
model->variables().addVariable( f );
|
||||
QCOMPARE( model->variables().size(), 4 );
|
||||
|
||||
//
|
||||
// Add merge
|
||||
@@ -350,12 +350,12 @@ void TestXmlLabel::writeReadFile()
|
||||
QCOMPARE( readModel->dir(), model->dir() );
|
||||
QCOMPARE( readModel->fileName(), model->fileName() );
|
||||
|
||||
QCOMPARE( readModel->tmplate()->brand(), model->tmplate()->brand() );
|
||||
QCOMPARE( readModel->tmplate()->part(), model->tmplate()->part() );
|
||||
QCOMPARE( readModel->tmplate()->description(), model->tmplate()->description() );
|
||||
QCOMPARE( readModel->tmplate()->paperId(), model->tmplate()->paperId() );
|
||||
QCOMPARE( readModel->tmplate()->pageWidth().pt(), model->tmplate()->pageWidth().pt() );
|
||||
QCOMPARE( readModel->tmplate()->pageHeight().pt(), model->tmplate()->pageHeight().pt() );
|
||||
QCOMPARE( readModel->tmplate().brand(), model->tmplate().brand() );
|
||||
QCOMPARE( readModel->tmplate().part(), model->tmplate().part() );
|
||||
QCOMPARE( readModel->tmplate().description(), model->tmplate().description() );
|
||||
QCOMPARE( readModel->tmplate().paperId(), model->tmplate().paperId() );
|
||||
QCOMPARE( readModel->tmplate().pageWidth().pt(), model->tmplate().pageWidth().pt() );
|
||||
QCOMPARE( readModel->tmplate().pageHeight().pt(), model->tmplate().pageHeight().pt() );
|
||||
|
||||
QCOMPARE( readModel->frame()->id(), model->frame()->id() );
|
||||
QCOMPARE( readModel->frame()->w().pt(), model->frame()->w().pt() );
|
||||
@@ -421,14 +421,7 @@ void TestXmlLabel::writeReadFile()
|
||||
QCOMPARE( readObjects.at(i)->filenameNode().data(), modelObjects.at(i)->filenameNode().data() );
|
||||
}
|
||||
|
||||
if ( readObjects.at(i)->image() )
|
||||
{
|
||||
QCOMPARE( *(readObjects.at(i)->image()), *(modelObjects.at(i)->image()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QCOMPARE( readObjects.at(i)->image(), modelObjects.at(i)->image() );
|
||||
}
|
||||
QCOMPARE( readObjects.at(i)->image(), modelObjects.at(i)->image() );
|
||||
QCOMPARE( readObjects.at(i)->svg(), modelObjects.at(i)->svg() );
|
||||
|
||||
QCOMPARE( readObjects.at(i)->lineWidth(), modelObjects.at(i)->lineWidth() );
|
||||
@@ -452,11 +445,11 @@ void TestXmlLabel::writeReadFile()
|
||||
QCOMPARE( readObjects[11]->filenameNode().data(), pngRelativeFileName );
|
||||
QCOMPARE( readObjects[12]->filenameNode().data(), svgRelativeFileName );
|
||||
|
||||
QCOMPARE( readModel->variables()->size(), model->variables()->size() );
|
||||
for ( const auto& modelV : *model->variables() )
|
||||
QCOMPARE( readModel->variables().size(), model->variables().size() );
|
||||
for ( const auto& modelV : model->variables() )
|
||||
{
|
||||
QVERIFY( readModel->variables()->hasVariable( modelV.name() ) );
|
||||
const auto& readV = readModel->variables()->value( modelV.name() );
|
||||
QVERIFY( readModel->variables().hasVariable( modelV.name() ) );
|
||||
const auto& readV = readModel->variables().value( modelV.name() );
|
||||
QCOMPARE( readV.type(), modelV.type() );
|
||||
QCOMPARE( readV.initialValue(), modelV.initialValue() );
|
||||
if ( readV.type() == Variable::Type::INTEGER || readV.type() == Variable::Type::FLOATING_POINT )
|
||||
@@ -472,37 +465,47 @@ void TestXmlLabel::writeReadFile()
|
||||
QCOMPARE( readModel->merge()->recordList().size(), model->merge()->recordList().size() );
|
||||
for ( int i = 0; i < readModel->merge()->recordList().size(); i++ )
|
||||
{
|
||||
QCOMPARE( readModel->merge()->recordList().at(i)->keys(), model->merge()->recordList().at(i)->keys() );
|
||||
QCOMPARE( readModel->merge()->recordList().at(i)->values(), model->merge()->recordList().at(i)->values() );
|
||||
QCOMPARE( readModel->merge()->recordList().at(i).keys(), model->merge()->recordList().at(i).keys() );
|
||||
QCOMPARE( readModel->merge()->recordList().at(i).values(), model->merge()->recordList().at(i).values() );
|
||||
}
|
||||
|
||||
delete readModel->merge();
|
||||
delete readModel->variables();
|
||||
delete readModel;
|
||||
|
||||
delete model->merge();
|
||||
delete model->variables();
|
||||
delete model;
|
||||
}
|
||||
|
||||
|
||||
void TestXmlLabel::parser_3ReadFile()
|
||||
{
|
||||
// Current path is "build/model/unit_tests" so go up 3 levels
|
||||
QFileInfo glabelsFileInfo( "../../../model/unit_tests/data/glabels-3/crew-orientation-name-tags-7.glabels" );
|
||||
// FIX ME: Currently the test glabels-3 file hardcodes a relative path to its CSV file.
|
||||
// With this relative path, it is assumed that
|
||||
//
|
||||
// 1) The test is being run from CTEST, which runs it in <build-dir>/model/unit_tests
|
||||
// 2) The build directory is a subdirectory of the top-level glabels-qt source
|
||||
// directory.
|
||||
//
|
||||
// This test is verifying backwards compatability with glabels-3 files. Data files need
|
||||
// to be treated as relocatable. This is not only an issue with unit tests, but affects
|
||||
// normal use cases where files are moved around. Normally, the data file path within
|
||||
// the glabels file is absolute. Perhaps, if the data file cannot be found at the
|
||||
// absolute path, an attempt should be made guess at the relative path (maybe sitting
|
||||
// in the same directory as the glabels file. For glabels-4 files, the relative path
|
||||
// should be encoded in the file.
|
||||
|
||||
QFileInfo glabelsFileInfo( QString( "%1/data/glabels-3/crew-orientation-name-tags-7.glabels" ).arg( QString(TEST_DIR) ) );
|
||||
QVERIFY( glabelsFileInfo.isReadable() );
|
||||
|
||||
Model* model = XmlLabelParser::readFile( glabelsFileInfo.filePath() );
|
||||
Model* model = XmlLabelParser::readFile( glabelsFileInfo.absoluteFilePath() );
|
||||
QVERIFY( model );
|
||||
|
||||
|
||||
QCOMPARE( model->fileName(), glabelsFileInfo.filePath() );
|
||||
|
||||
QCOMPARE( model->tmplate()->brand(), QString( "Avery" ) );
|
||||
QCOMPARE( model->tmplate()->part(), QString( "5395" ) );
|
||||
QCOMPARE( model->tmplate()->description(), QString( "Name Badge Labels" ) );
|
||||
QCOMPARE( model->tmplate()->paperId(), QString( "US-Letter" ) );
|
||||
QCOMPARE( model->tmplate()->pageWidth().in(), 8.5 );
|
||||
QCOMPARE( model->tmplate()->pageHeight().in(), 11.0 );
|
||||
QCOMPARE( model->tmplate().brand(), QString( "Avery" ) );
|
||||
QCOMPARE( model->tmplate().part(), QString( "5395" ) );
|
||||
QCOMPARE( model->tmplate().description(), QString( "Name Badge Labels" ) );
|
||||
QCOMPARE( model->tmplate().paperId(), QString( "US-Letter" ) );
|
||||
QCOMPARE( model->tmplate().pageWidth().in(), 8.5 );
|
||||
QCOMPARE( model->tmplate().pageHeight().in(), 11.0 );
|
||||
|
||||
QCOMPARE( model->frame()->id(), QString( "0" ) );
|
||||
const FrameRect* frameRect = dynamic_cast<const FrameRect*>( model->frame() );
|
||||
@@ -514,18 +517,18 @@ void TestXmlLabel::parser_3ReadFile()
|
||||
QCOMPARE( frameRect->yWaste().in(), 0.0625 );
|
||||
|
||||
QCOMPARE( model->frame()->markups().size(), 1 );
|
||||
MarkupMargin* markupMargin = dynamic_cast<MarkupMargin*>( model->frame()->markups()[0] );
|
||||
MarkupMargin* markupMargin = dynamic_cast<MarkupMargin*>( model->frame()->markups().front().get() );
|
||||
QVERIFY( markupMargin );
|
||||
QCOMPARE( markupMargin->xSize().in(), 0.0625 );
|
||||
QCOMPARE( markupMargin->ySize().in(), 0.0625 );
|
||||
|
||||
QCOMPARE( model->frame()->layouts().size(), 1 );
|
||||
QCOMPARE( model->frame()->layouts()[0].nx(), 2 );
|
||||
QCOMPARE( model->frame()->layouts()[0].ny(), 4 );
|
||||
QCOMPARE( model->frame()->layouts()[0].x0().in(), 0.6875 );
|
||||
QCOMPARE( model->frame()->layouts()[0].y0().in(), 0.583333 );
|
||||
QCOMPARE( model->frame()->layouts()[0].dx().in(), 3.75 );
|
||||
QCOMPARE( model->frame()->layouts()[0].dy().in(), 2.5 );
|
||||
QCOMPARE( model->frame()->layouts().front().nx(), 2 );
|
||||
QCOMPARE( model->frame()->layouts().front().ny(), 4 );
|
||||
QCOMPARE( model->frame()->layouts().front().x0().in(), 0.6875 );
|
||||
QCOMPARE( model->frame()->layouts().front().y0().in(), 0.583333 );
|
||||
QCOMPARE( model->frame()->layouts().front().dx().in(), 3.75 );
|
||||
QCOMPARE( model->frame()->layouts().front().dy().in(), 2.5 );
|
||||
|
||||
QCOMPARE( model->rotate(), false );
|
||||
|
||||
@@ -606,7 +609,7 @@ void TestXmlLabel::parser_3ReadFile()
|
||||
QVERIFY( !model->merge()->source().isEmpty() ); // Merge source hacked to work relatively so not realistic
|
||||
QCOMPARE( model->merge()->recordList().size(), 4 );
|
||||
|
||||
QCOMPARE( model->merge()->recordList()[0]->keys().size(), 3 );
|
||||
QCOMPARE( model->merge()->recordList()[0].keys().size(), 3 );
|
||||
QList<QString> keys, values0, values1, values2, values3;
|
||||
keys << "Department" << "Name" << "SN";
|
||||
values0 << "Management" << "Jim Kirk" << "SC937-0176 CEC";
|
||||
@@ -614,17 +617,15 @@ void TestXmlLabel::parser_3ReadFile()
|
||||
values2 << "Medicine" << "Leonard McCoy" << "unknown";
|
||||
values3 << "Engineering" << "Montgomery Scott" << "SE-197-54T";
|
||||
|
||||
QCOMPARE( model->merge()->recordList()[0]->keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[0]->values(), values0 );
|
||||
QCOMPARE( model->merge()->recordList()[1]->keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[1]->values(), values1 );
|
||||
QCOMPARE( model->merge()->recordList()[2]->keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[2]->values(), values2 );
|
||||
QCOMPARE( model->merge()->recordList()[3]->keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[3]->values(), values3 );
|
||||
QCOMPARE( model->merge()->recordList()[0].keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[0].values(), values0 );
|
||||
QCOMPARE( model->merge()->recordList()[1].keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[1].values(), values1 );
|
||||
QCOMPARE( model->merge()->recordList()[2].keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[2].values(), values2 );
|
||||
QCOMPARE( model->merge()->recordList()[3].keys(), keys );
|
||||
QCOMPARE( model->merge()->recordList()[3].values(), values3 );
|
||||
|
||||
delete model->merge();
|
||||
delete model->variables();
|
||||
delete model;
|
||||
}
|
||||
|
||||
@@ -697,7 +698,5 @@ void TestXmlLabel::parser_3Barcode()
|
||||
QCOMPARE( modelBarcodeObject->bcStyle().fullId(), QString( "code39" ) );
|
||||
}
|
||||
|
||||
delete model->merge();
|
||||
delete model->variables();
|
||||
delete model;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user