Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting up a mock interface in C++
    text
    copied!<p>I'm currently trying to use a certain SDK that has me loading functions off a DLL that a vendor provides.. I have to pass arguments to these functions and the DLL does all the work..</p> <p>Now, the DLL is supposed to be communicating with another device, while I just wait for the results. However, I don't have this device, so how do I set up a mock interface to emulate the device?</p> <p>To be clear, here's an example:</p> <pre><code>myfuncpointer.Open(someparam,anotherparam,...); </code></pre> <p>Now, because I don't have the device, the DLL can't actually perform the above function; it fails. How do I set up testing so that the DLL talks to a class that I designed rather than the device? Is there any way to redirect the DLL's call? </p> <p>How do I make a DummyDevice class to do this?</p> <p>Thanks.. </p> <p>P.S. If anything is not clear, please don't be too quick to downvote.. Comment as to what I need to explain and I'll try to clear it up.. Thanks.</p> <hr> <p>EDIT: What I DO have, however, is a spec sheet with all of the data structures used and the expected/legal values that it has to contain. So for example, if I call a function:</p> <pre><code>myfuncpointer.getinfo(param,otherparam); </code></pre> <p>where one of the params is a data structure that the DLL fills up with info (say, if an option is enabled) after querying the device.. I can do this</p> <pre><code>param.option = true; </code></pre> <p>after it has finished the getinfo call.</p> <p>Is this a good way to test the code? It seems very very dangerous to trick this DLL into thinking all the wrong things and seems to be really really hard to scale even just a bit..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload