<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Creating mockobject of Qfile by replacing Qbuffer possible?]]></title><description><![CDATA[<p dir="auto">Hi ya'll,</p>
<p dir="auto">For the unit testing purpose, I have a QFile writing to and reads from a file. However, I need to replace this file as a memory, such as QBuffer, since they are from the same base class QIODevice, so it won't be necessary to create the file to perform a unit test.</p>
<p dir="auto">How can I write a method with QFile so it would write to Qbuffer or QByteArray, so I could verify it's contents acting like in memory instead? Likewise, for the other way around reading a Qbuffer from QFile.</p>
<p dir="auto">What's the best way to approach this? It may require some advanced OOP with inheritance, but I'm not sure it will work.</p>
<p dir="auto">Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/132042/creating-mockobject-of-qfile-by-replacing-qbuffer-possible</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 04:26:44 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/132042.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Nov 2021 16:13:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Creating mockobject of Qfile by replacing Qbuffer possible? on Tue, 16 Nov 2021 19:46:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">One way is to use QIODevice rather than QFile for your method.</p>
<p dir="auto">That way you can pass whatever you want for your tests.</p>
]]></description><link>https://forum.qt.io/post/690335</link><guid isPermaLink="true">https://forum.qt.io/post/690335</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 16 Nov 2021 19:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to Creating mockobject of Qfile by replacing Qbuffer possible? on Wed, 17 Nov 2021 12:18:26 GMT]]></title><description><![CDATA[<p dir="auto">Thank you so much for explaining! It works to pass QFile and QBuffer like that.</p>
]]></description><link>https://forum.qt.io/post/690469</link><guid isPermaLink="true">https://forum.qt.io/post/690469</guid><dc:creator><![CDATA[ChiTor]]></dc:creator><pubDate>Wed, 17 Nov 2021 12:18:26 GMT</pubDate></item><item><title><![CDATA[Reply to Creating mockobject of Qfile by replacing Qbuffer possible? on Tue, 16 Nov 2021 19:46:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">One way is to use QIODevice rather than QFile for your method.</p>
<p dir="auto">That way you can pass whatever you want for your tests.</p>
]]></description><link>https://forum.qt.io/post/690335</link><guid isPermaLink="true">https://forum.qt.io/post/690335</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 16 Nov 2021 19:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to Creating mockobject of Qfile by replacing Qbuffer possible? on Tue, 16 Nov 2021 16:19:04 GMT]]></title><description><![CDATA[<p dir="auto">Don't use QFile but your own class which either routes to a QFile or QBuffer/QByteArray.</p>
]]></description><link>https://forum.qt.io/post/690289</link><guid isPermaLink="true">https://forum.qt.io/post/690289</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Tue, 16 Nov 2021 16:19:04 GMT</pubDate></item></channel></rss>