summaryrefslogtreecommitdiffstats
path: root/src/testlib/qxmltestlogger_p.h
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-09-30 12:50:05 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-11-30 12:26:08 +0100
commitb9f7add531ceab2590e2b24dec7b495950f9870a (patch)
treebc6854cf33ec4847317b05edb5201fa4ed426605 /src/testlib/qxmltestlogger_p.h
parent78a6e730075c1262f25b2ac2df098c7aa1184ca8 (diff)
Verify returns from QXmlTestLogger's xmlQuote() and xmlCdata()
Using partially-converted text would lead to invalid XML, so don't use the buffer contents if the return is zero. As a result, QTestJUnitStreamer::formatEnd() needs to return some indication of whether *it* succeeded, so change it to forward their int returns; and, as it's in fact only used internally by the streamer, make it private. Make these functions [[nodiscard]] so that further uses of them will be discouraged from ignoring the possibility of failure. Make the public versions return bool so that they can correctly succeed on empty input. Assert various conditions we can infer to save work we don't need to do. Change-Id: I899bad23d1dfbd05fc725de269def4ce213dbc5a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/testlib/qxmltestlogger_p.h')
-rw-r--r--src/testlib/qxmltestlogger_p.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h
index 8091dada59..e72b688545 100644
--- a/src/testlib/qxmltestlogger_p.h
+++ b/src/testlib/qxmltestlogger_p.h
@@ -77,11 +77,11 @@ public:
void addMessage(MessageTypes type, const QString &message,
const char *file = nullptr, int line = 0) override;
- static int xmlCdata(QTestCharBuffer *dest, char const *src);
- static int xmlQuote(QTestCharBuffer *dest, char const *src);
+ [[nodiscard]] static bool xmlCdata(QTestCharBuffer *dest, char const *src);
+ [[nodiscard]] static bool xmlQuote(QTestCharBuffer *dest, char const *src);
private:
- static int xmlCdata(QTestCharBuffer *dest, char const *src, qsizetype n);
- static int xmlQuote(QTestCharBuffer *dest, char const *src, qsizetype n);
+ [[nodiscard]] static int xmlCdata(QTestCharBuffer *dest, char const *src, qsizetype n);
+ [[nodiscard]] static int xmlQuote(QTestCharBuffer *dest, char const *src, qsizetype n);
XmlMode xmlmode;
};