A test how to use QSignalSpy with GMock
[ptas] / tests / stlhelpers4qt.h
1 #ifndef STLHELPERS4QT_H
2 #define STLHELPERS4QT_H
3
4 #include <ostream>
5 #include <QList>
6 #include <QVariant>
7
8 /**
9  * Outputs the contents of a QList<QVariant> container to a std::ostream object.
10  * @param stream the stream to output to
11  * @param val the container that is put to the stream
12  * @return the same stream that was passed as the parameter @a stream
13  */
14 std::ostream& operator<<(std::ostream& stream, const QList<QVariant> &val)
15 {
16     bool first = true;
17
18     foreach (const QVariant &v, val) {
19         if (!first) {
20             stream << ", ";
21         }
22         stream << v.toString().toStdString();
23         first = false;
24     }
25     return stream;
26 }
27
28 #endif // STLHELPERS4QT_H