Closed cancech closed 6 months ago
To me it looks like it's the same issue as the one explained here: https://github.com/eranpeer/FakeIt/issues/274
TL;DR: this occurs when Verify
ing references, it's a limitation of the current design of the library, but there are some workarounds (shown in the issue above).
Thanks for confirming, That was my impression, but didn't really know how to verify.
Greetings,
I've trying to use fakeit for unit testing of a Qt based application, and I'm running into an issue when verifying that a mocked method is called with a specific QString as a parameter.
The class I am trying to test is as follows:
The code itself works as I would expect it to (I can compile/execute it and it does exactly what I would expect it to at runtime). My unit test is as follows:
The issue I'm running into is that I get a std::bad_alloc every time I run on any of the Verify checks that attempt to verify the appropriate QString argument via Using(QString) as indicated above. By this I mean
The exact error as reported:
Stepping through
fakeit::Verify(Method(mockFileHelper, copyDir).Using(templateConfigPath, runtimeConfigPath, true)).Once();
with the debugger I'm not sure where the std::bad_alloc is actually coming from. The first step intoseems to work fine (at least it gets to the end without any issues) and once the above returns the next step enters into
where
__s = "copyDir"
. As soon as the above block ends the std::bad_alloc is thrown and the test terminates.Note: I'm using GTest for the test framework and the unified fakeit.hpp for GTest.
OS: Windows 11 FakeIt v2.4.0 GTest v1.13.0 Qt v6.5.1
Any thoughts on what could be going on, or what more to do to troubleshoot would be greatly appreciated!
Thanks.