45 #include <QtTest/qtest_global.h> 46 #include <QtTest/qtestcase.h> 47 #include <QtTest/qtestdata.h> 48 #include <QtTest/qtestdata.h> 49 #include <QtTest/qbenchmark.h> 51 #include <QtCore/qbytearray.h> 52 #include <QtCore/qstring.h> 53 #include <QtCore/qstringlist.h> 54 #include <QtCore/qdatetime.h> 55 #include <QtCore/qobject.h> 56 #include <QtCore/qvariant.h> 57 #include <QtCore/qurl.h> 59 #include <QtCore/qpoint.h> 60 #include <QtCore/qsize.h> 61 #include <QtCore/qrect.h> 107 :
qstrdup(
"Invalid QDateTime");
155 if (
type.isEmpty()) {
162 vstring.
append(qvariant_cast<QString>(v).toLatin1());
165 vstring.
append(
"<value not representable as string>");
174 #ifndef QTEST_NO_SPECIALIZATIONS 178 const char *expected,
const char *file,
int line)
180 return qCompare<QString>(t1,
QString(t2), actual, expected, file, line);
182 #ifndef QTEST_NO_SPECIALIZATIONS 186 const char *expected,
const char *file,
int line)
188 return qCompare<QString>(
QString(t1), t2, actual, expected, file, line);
193 const char *actual,
const char *expected,
const char *file,
int line)
199 qt_snprintf(msg, 1024,
"Compared QStringLists have different sizes.\n" 200 " Actual (%s) size : '%d'\n" 201 " Expected (%s) size: '%d'", actual, t1.
count(), expected, t2.
count());
205 for (
int i = 0; isOk && i < min; ++i) {
206 if (t1.
at(i) != t2.
at(i)) {
207 qt_snprintf(msg, 1024,
"Compared QStringLists differ at index %d.\n" 208 " Actual (%s) : '%s'\n" 217 template <
typename T>
218 inline bool qCompare(
QFlags<T> const &t1, T
const &t2,
const char *actual,
const char *expected,
219 const char *file,
int line)
221 return qCompare(
int(t1),
int(t2), actual, expected, file, line);
224 template <
typename T>
225 inline bool qCompare(
QFlags<T> const &t1,
int const &t2,
const char *actual,
const char *expected,
226 const char *file,
int line)
228 return qCompare(
int(t1), t2, actual, expected, file, line);
234 #define QTEST_APPLESS_MAIN(TestObject) \ 235 int main(int argc, char *argv[]) \ 238 return QTest::qExec(&tc, argc, argv); \ 241 #define QTEST_NOOP_MAIN \ 242 int main(int argc, char *argv[]) \ 245 return QTest::qExec(&tc, argc, argv); \ 248 #include <QtTest/qtestsystem.h> 252 #include <QtTest/qtest_gui.h> 254 #ifdef QT_KEYPAD_NAVIGATION 255 # define QTEST_DISABLE_KEYPAD_NAVIGATION QApplication::setNavigationMode(Qt::NavigationModeNone); 257 # define QTEST_DISABLE_KEYPAD_NAVIGATION 260 #define QTEST_MAIN(TestObject) \ 261 int main(int argc, char *argv[]) \ 263 QApplication app(argc, argv); \ 264 QTEST_DISABLE_KEYPAD_NAVIGATION \ 266 return QTest::qExec(&tc, argc, argv); \ 271 #define QTEST_MAIN(TestObject) \ 272 int main(int argc, char *argv[]) \ 274 QCoreApplication app(argc, argv); \ 276 return QTest::qExec(&tc, argc, argv); \ bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual, const char *expected, const char *file, int line)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVariant class acts like a union for the most common Qt data types.
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
bool isValid() const
Returns true if this date is valid; otherwise returns false.
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
QByteArray & append(char c)
Appends the character ch to this byte array.
qreal width() const
Returns the width.
The QByteArray class provides an array of bytes.
The QPointF class defines a point in the plane using floating point precision.
qreal height() const
Returns the height.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
int height() const
Returns the height of the rectangle.
The QUrl class provides a convenient interface for working with URLs.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
The QChar class provides a 16-bit Unicode character.
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
qreal x() const
Returns the x-coordinate of this point.
int width() const
Returns the width.
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
const char * latin1() const
Returns the Latin-1 string stored in this object.
The QRectF class defines a rectangle in the plane using floating point precision. ...
bool canConvert(Type t) const
Returns true if the variant's type can be cast to the requested type, t.
char * toHexRepresentation(const char *ba, int length)
Returns a pointer to a string that is the string ba represented as a space-separated sequence of hex ...
qreal height() const
Returns the height of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
char * toString(const QLatin1String &str)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
qreal width() const
Returns the width of the rectangle.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
const char * typeName() const
Returns the name of the type stored in the variant.
int length() const
Same as size().
QByteArray toEncoded(FormattingOptions options=None) const
Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returne...
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the time as a string.
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format,...)
int top() const
Returns the y-coordinate of the rectangle's top edge.
int userType() const
Returns the storage type of the value stored in the variant.
int right() const
Returns the x-coordinate of the rectangle's right edge.
The QDateTime class provides date and time functions.
Q_CORE_EXPORT char * qstrdup(const char *)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
The QPoint class defines a point in the plane using integer precision.
Qt::TimeSpec timeSpec() const
Returns the time specification of the datetime.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
int y() const
Returns the y coordinate of this point.
qreal y() const
Returns the y-coordinate of this point.
Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *msg, const char *file, int line)
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QFlags class provides a type-safe way of storing OR-combinations of enum values.
int x() const
Returns the x coordinate of this point.
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the date as a string.
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
The QTest namespace contains all the functions and declarations that are related to the QTestLib tool...
const QChar * constData() const
Returns a pointer to the data stored in the QString.
bool isValid() const
Returns true if the time is valid; otherwise returns false.