tests/auto/qbytearray/tst_qbytearray.cpp
changeset 18 2f34d5167611
parent 0 1918ee327afb
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
    74     void qCompress_data();
    74     void qCompress_data();
    75 #ifndef QT_NO_COMPRESS
    75 #ifndef QT_NO_COMPRESS
    76     void qCompress();
    76     void qCompress();
    77     void qUncompress_data();
    77     void qUncompress_data();
    78     void qUncompress();
    78     void qUncompress();
       
    79     void qCompressionZeroTermination();
    79 #endif
    80 #endif
    80     void constByteArray();
    81     void constByteArray();
    81     void leftJustified();
    82     void leftJustified();
    82     void rightJustified();
    83     void rightJustified();
    83     void startsWith_data();
    84     void startsWith_data();
   259     } QT_CATCH(const std::bad_alloc &) {
   260     } QT_CATCH(const std::bad_alloc &) {
   260         res = QByteArray();
   261         res = QByteArray();
   261     }
   262     }
   262     QCOMPARE(res, out);
   263     QCOMPARE(res, out);
   263 }
   264 }
       
   265 
       
   266 void tst_QByteArray::qCompressionZeroTermination()
       
   267 {
       
   268     QString s = "Hello, I'm a string.";
       
   269     QByteArray ba = ::qUncompress(::qCompress(s.toLocal8Bit()));
       
   270     QVERIFY((int) *(ba.data() + ba.size()) == 0);
       
   271 }
       
   272 
   264 #endif
   273 #endif
   265 
   274 
   266 void tst_QByteArray::constByteArray()
   275 void tst_QByteArray::constByteArray()
   267 {
   276 {
   268     const char *ptr = "abc";
   277     const char *ptr = "abc";