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 Update on Monday, May 27th 2025

Comapring value of same character array using Qverify fails Qtest

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 353 Views
  • 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 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") ;
    

    }

    jsulmJ 1 Reply Last reply
    0
    • S Offline
      S Offline
      saurabh162
      wrote on last edited by saurabh162
      #3
      This post is deleted!
      1 Reply Last reply
      0
      • S 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") ;
        

        }

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on 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 last edited by saurabh162
          #3
          This post is deleted!
          1 Reply Last reply
          0

          • Login

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