Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Comapring value of same character array using Qverify fails Qtest
Forum Updated to NodeBB v4.3 + New Features

Comapring value of same character array using Qverify fails Qtest

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 374 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saurabh162
    wrote on 29 Jul 2019, 08:06 last edited by saurabh162
    #1

    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") ;
    

    }

    J 1 Reply Last reply 29 Jul 2019, 08:09
    0
    • S Offline
      S Offline
      saurabh162
      wrote on 29 Jul 2019, 08:37 last edited by saurabh162
      #3
      This post is deleted!
      1 Reply Last reply
      0
      • S saurabh162
        29 Jul 2019, 08:06

        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") ;
        

        }

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 29 Jul 2019, 08:09 last edited by jsulm
        #2

        @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.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • S Offline
          S Offline
          saurabh162
          wrote on 29 Jul 2019, 08:37 last edited by saurabh162
          #3
          This post is deleted!
          1 Reply Last reply
          0

          3/3

          29 Jul 2019, 08:37

          • Login

          • Login or register to search.
          3 out of 3
          • First post
            3/3
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved