From b2173b54ef9ede85d88cb0fdf025b26e732ed44a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 15:43:21 +0100 Subject: Long live QTest::addRow()! This new function does the same as newRow(), except that it has a less confusing name (in line with _add_Column()), and accepts printf-style arguments to avoid the need to newRow(qPrintable(QString::asprintf())), a common pattern in client code. It uses qvsnprintf() under the hoods, avoiding the need for the QString const char* round-trip. Port all in-tree users of newRow(qPrintable(QString::asnprintf())) to the new function. Change-Id: Icd5de9b7ea4f6759d98080ec30f5aecadb8bec39 Reviewed-by: Thiago Macieira --- src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/testlib/doc') diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp index 2c57550c3d..01ee8102f4 100644 --- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp +++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp @@ -208,6 +208,17 @@ void myTestFunction_data() //! [20] +//! [addRow] +void myTestFunction_data() +{ + QTest::addColumn("input"); + QTest::addColumn("output"); + QTest::addRow("%d", 0) << 0 << QString("0"); + QTest::addRow("%d", 1) << 1 << QString("1"); +} +//! [addRow] + + //! [21] void myTestFunction_data() { QTest::addColumn("intval"); -- cgit v1.2.3