Comapring value of same character array using Qverify fails Qtest
-
wrote on 29 Jul 2019, 08:06 last edited by saurabh162
Dear Developers,
I am comparing two same character arrays using QVERIFY as given below. But it gives me negative result. Can you please explain me reason for it. Please inform me if you need any other infromation from me.
void TestGPIO::test_Compare_String()
{
char outputString[4]="30";
if(strcmp(outputString,"30")==0)
{
qDebug() << "Strings are equal";} else { qDebug() << "Strings not equal"; } QVERIFY(outputString=="30") ;
}
-
wrote on 29 Jul 2019, 08:37 last edited by saurabh162This post is deleted!
-
Dear Developers,
I am comparing two same character arrays using QVERIFY as given below. But it gives me negative result. Can you please explain me reason for it. Please inform me if you need any other infromation from me.
void TestGPIO::test_Compare_String()
{
char outputString[4]="30";
if(strcmp(outputString,"30")==0)
{
qDebug() << "Strings are equal";} else { qDebug() << "Strings not equal"; } QVERIFY(outputString=="30") ;
}
@saurabh162 said in Comapring value of same character array using Qverify fails Qtest:
QVERIFY(outputString=="30") ;
This can't work as you're comparing pointers.
Use strcmp to compare two C style strings. -
wrote on 29 Jul 2019, 08:37 last edited by saurabh162This post is deleted!
3/3