Esempio n. 1
0
void NewJoinWidget::createUserItem()
{
	// TODO 数据表列表
	stuComboBox = new QComboBox();
	stuComboBox->addItem("2012级信息");
	stuComboBox->setCurrentIndex(0);
	stuComboBox->setEnabled(false);
	connect(stuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh()));
	
	stuLayout = new QVBoxLayout();
	stuLayout->addWidget(stuComboBox);
	
	// 组装数据浏览 GroupBox
	stuGroupBox = new QGroupBox(tr("当前显示"));
	stuGroupBox->setLayout(stuLayout);
	
	seniorCheckBox = new QCheckBox(tr("启用自由编辑"));
	connect(seniorCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setSeniorButtonState(int)));
	submitButton = new QPushButton(tr("提交修改"));
	submitButton->setEnabled(false);
	connect(submitButton, SIGNAL(clicked()), this, SLOT(submitDataChange()));
	restoreButton = new QPushButton(tr("撤销修改"));
	restoreButton->setEnabled(false);
	connect(restoreButton, SIGNAL(clicked()), sqlModel, SLOT(revertAll()));

	seniorLayout = new QVBoxLayout();
	seniorLayout->addWidget(seniorCheckBox);
	seniorLayout->addWidget(submitButton);
	seniorLayout->addWidget(restoreButton);
	
	// TODO 组装高级操作选项的 GroupBox
	seniorGroupBox = new QGroupBox(tr("高级操作 [请谨慎]"));
	seniorGroupBox->setLayout(seniorLayout);

	addButton = new QPushButton(tr("增加成员"));
	connect(addButton, SIGNAL(clicked()), this, SLOT(addInfo()));
	changeButton = new QPushButton(tr("修改选中"));
	connect(changeButton, SIGNAL(clicked()), this, SLOT(changeInfo()));
	delButton = new QPushButton(tr("删除选中"));
	connect(delButton, SIGNAL(clicked()), this, SLOT(delInfo()));
	refreshButton = new QPushButton(tr("刷新数据"));
	connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));

	buttonLayout = new QVBoxLayout();
	buttonLayout->addWidget(addButton);
	buttonLayout->addStretch();
	buttonLayout->addWidget(changeButton);
	buttonLayout->addStretch();
	buttonLayout->addWidget(delButton);
	buttonLayout->addStretch();
	buttonLayout->addWidget(refreshButton);
	
	// 组装数据操作 GroupBox
	buttonGroupBox = new QGroupBox(tr("数据操作"));
	buttonGroupBox->setLayout(buttonLayout);
}
void CNSmlDummyDataProvider_Test::DoCheckServerFiltersL()
    {
    RPointerArray< CSyncMLFilter >* filters = 
        new ( ELeave ) RPointerArray< CSyncMLFilter >();
    CleanupRPtrArrayPushL( filters );
    TSyncMLFilterChangeInfo changeInfo( ESyncMLDefault );

    TRAPD( err, iCNSmlDummyDataProvider->DoCheckServerFiltersL( 
        *filters, changeInfo ) );

    EUNIT_ASSERT( err == KErrNotSupported );  
    CleanupStack::PopAndDestroy( filters ); 
    }
Esempio n. 3
0
int main(void) {

	int result;

	person * person1;
	person * person2;
	person * person3 = NULL;

	/*Start createPerson Test*/
	printf("\nTesting createPerson function...\n");

	person1 = createPerson();
	printf("person1 pointer value: %p\n", &person1);

	person2 = createPerson();
	printf("person2 pointer value: %p\n", &person2);

	if(&person1 != &person2) {
		printf("Success! pointers are referencing different mem locations. EXPECTED\n\n");
	}
	else {
		printf("Fail... pointers are referencing same mem location.\n\n");
	}
	/*End createPerson Test*/


	/*Start destroyPerson Test*/
	printf("Testing destroyPerson function...\n");
	destroyPerson(person1);
	person1 = NULL;

	printf("person1 deleted... ptr value: %p\n", &person1);
	printf("trying to delete again...\n");

	destroyPerson(person1);
	printf("NOTE: must set the pointer to NULL after using destroyPerson, or program will crash due to invalid pointer\n\n");
	/*End destroyPerson Test*/


	/*Start printPerson Test*/
	printf("Testing printPerson function...\n");

	printf("printing the destroyed person1...\n");
	printPerson(person1);
	
	printf("printing the valid person2...\n");
	printPerson(person2);

	printf("\n");
	/*End printPerson Test*/


	/*Start changeInfo Test*/
	printf("Testing changeInfo function...\n")
;
	printf("Attempting to changeInfo on destroyed person1...\n");
	if(changeInfo(person1, "Justin","Fuerth",25)) {
		printf("Error! person1 is NULL\n");
	}
	else {
		printf("Successfully changed info... something went wrong...\n");
	}

	printf("Attempting to changeInfo on valid person2...\n");
	if(changeInfo(person2, "Justin","Fuerth",25)) {
		printf("Error! person2 is NULL... that's not right\n");
	}
	else {
		printf("Successfully changed info for person2!\n");
	}

	printf("Printing person2 again...\n");
	printPerson(person2);

	printf("\n");
	/*End changeInfo Test*/


	/*recreating person1 for further testing purposes*/
	printf("Creating person1 again and giving it values: Stephen, Fuerth, 62\n\n");
	person1 = createPerson();
	changeInfo(person1, "Stephen", "Fuerth", 62);


	/*Start equalTo Test*/
	printf("Testing the equalTo function...\n");

	printf("Testing equalTo with NULL pointer person3...\n");
	if((result = equalTo(person3,person3))>-1) {
		if(result == 0) {
			printf("the two people are different!\n");
		}
		else {
			printf("the two people are equal!\n");
		}
	}
	else {
		printf("There was an error with the equalTo function. EXPECTED\n");
	}

	printf("Testing equalTo with one NULL and one valid...\n");
	if((result = equalTo(person1,person3))>-1) {
		if(result == 0) {
			printf("the two people are different!\n");
		}
		else {
			printf("the two people are equal!\n");
		}
	}
	else {
		printf("There was an error with the equalTo function. EXPECTED\n");
	}
	printf("Testing equalTo function with two valid, different people...\n");
	if((result = equalTo(person1,person2))>-1) {
		if(result == 0) {
			printf("the two people are different! EXPECTED\n");
		}
		else {
			printf("the two people are equal!\n");
		}
	}
	else {
		printf("There was an error with the equalTo function.\n");
	}

	printf("Testing equalTo function with two valid, equal people...\n");
	if((result = equalTo(person1,person1))>-1) {
		if(result == 0) {
			printf("the two people are different!\n");
		}
		else {
			printf("the two people are equal! EXPECTED\n");
		}
	}
	else {
		printf("There was an error with the equalTo function.\n");
	}
	
	printf("\n");
	/*End equalTo Test*/

	
	/*Start copyInfo Test*/
	printf("Testing copyInfo function...\n");

	printf("Attempting to copy into a NULL pointer...\n");
	if(copyInfo(person1,person3)) {
		printf("there was an error with the copyInfo function... EXPECTED\n");
	}

	printf("Attempting to copy from a NULL pointer...\n");
	if(copyInfo(person3,person1)) {
		printf("there was an error with the copyInfo function... EXPECTED\n");
	}

	/*creating an empty person3 to copy info into*/
	person3 = createPerson();

	printf("Attempting to copy from valid person1 to valid person3...\n");
	if(copyInfo(person1,person3)) {
		printf("there was an error with the copyInfo function...\n");
	}
	else {
		printf("SUCCESS! EXPECTED\n");
	}

	printf("Printing person3... expected: Stephen Fuerth, 62\n");
	printPerson(person3);
	/*End copyInfo Test*/

	/*freeing all memory to check memleaks with valgrind*/
	destroyPerson(person1);
	destroyPerson(person2);
	destroyPerson(person3);
	/*Aug 26 8:53 - valgrind shows no memory leaks*/

	printf("\n");
	return 0;

}