diff options
author | Sergio Martins <smartins@kde.org> | 2017-04-20 22:05:21 +0100 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2017-04-20 22:05:21 +0100 |
commit | 7b803e27c54011b4dec85a8c30de070cbed4a342 (patch) | |
tree | a73c27643869165dae6cbdd6ef0f2b9bcb80741d /tests/qcolor-from-literal | |
parent | 803fd7660b20e9f1a2ea45105b9c1de5353fa7fe (diff) |
Introducing qcolor-from-literal and long live ASTMatchers!
QColor(10, 20, 30) is much faster than QColor("#102030").
This is also the first check using ASTMatchers.
Diffstat (limited to 'tests/qcolor-from-literal')
-rw-r--r-- | tests/qcolor-from-literal/config.json | 7 | ||||
-rw-r--r-- | tests/qcolor-from-literal/main.cpp | 17 | ||||
-rw-r--r-- | tests/qcolor-from-literal/main.cpp.expected | 5 |
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/qcolor-from-literal/config.json b/tests/qcolor-from-literal/config.json new file mode 100644 index 00000000..e7e6e0cb --- /dev/null +++ b/tests/qcolor-from-literal/config.json @@ -0,0 +1,7 @@ +{ + "tests" : [ + { + "filename" : "main.cpp" + } + ] +} diff --git a/tests/qcolor-from-literal/main.cpp b/tests/qcolor-from-literal/main.cpp new file mode 100644 index 00000000..70f3c016 --- /dev/null +++ b/tests/qcolor-from-literal/main.cpp @@ -0,0 +1,17 @@ +#include <QtGui/QColor> + +extern void takingColor(QColor); + +void test() +{ + QColor c1; // OK + QColor c2("#001020"); // Warning + QColor c3(QString("#001020")); // Warning. TODO + QColor c4(QLatin1String("#001020")); // Warning. TODO + QColor c5("#023"); // Warning + QColor c6("#00112233"); // Warning + QColor c7("#000011112222"); // Warning + c4.setNamedColor("red"); // OK + c4.setNamedColor("#001020"); // Warning. TODO + takingColor("#001122"); // Warning +} diff --git a/tests/qcolor-from-literal/main.cpp.expected b/tests/qcolor-from-literal/main.cpp.expected new file mode 100644 index 00000000..f20a7ac5 --- /dev/null +++ b/tests/qcolor-from-literal/main.cpp.expected @@ -0,0 +1,5 @@ +qcolor-from-literal/main.cpp:8:15: warning: The QColor ctor taking ints is much cheaper than the one taking string literals [-Wclazy-qcolor-from-literal] +qcolor-from-literal/main.cpp:11:15: warning: The QColor ctor taking ints is much cheaper than the one taking string literals [-Wclazy-qcolor-from-literal] +qcolor-from-literal/main.cpp:12:15: warning: The QColor ctor taking ints is much cheaper than the one taking string literals [-Wclazy-qcolor-from-literal] +qcolor-from-literal/main.cpp:13:15: warning: The QColor ctor taking ints is much cheaper than the one taking string literals [-Wclazy-qcolor-from-literal] +qcolor-from-literal/main.cpp:16:17: warning: The QColor ctor taking ints is much cheaper than the one taking string literals [-Wclazy-qcolor-from-literal] |