#include "Trial.h"
int main()
{
return 0;
}
int XPLMGetDatavi(void* inDataRef, int* outValues, int inOffset, int inCount)
{
// Ensure the function signature is correct and matches expected syntax.
outValues[0] = 1; // Mocking the return value for demonstration purposes
return 0;
}
#include "CppUnitTest.h"
#include "isolator5.h"
#include "Trial.h"
#include "Trial.cpp"
using namespace Typemock;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace PluginTests1
{
TEST_CLASS(PluginTests1)
{
public:
Isolator* a = nullptr;
TEST_METHOD_INITIALIZE(Initialize)
{
// Initialize the isolator
a = new Isolator();
}
TEST_METHOD_CLEANUP(Cleanup)
{
// Cleanup the isolator
if (a)
{
delete a;
a = nullptr;
}
}
TEST_METHOD(TestTrial2)
{
// Another test for the Trial class with mocking
int dr = 1;
void * dref = &dr;
int values[1] = { 0 };
a->CallTo(XPLMGetDatavi(A::Any(), A::Any(), A::Any(), A::Any()))
.WillDoInstead([](void * inDataRef, int* outValues, int inOffset, int inCount)
{
Assert::AreEqual(1, *(int*)inDataRef);
outValues[0] = 1; // Mocking the return value
Assert::AreEqual(1, *(int*)inDataRef);
return 1; // Mocking the count
});
int count = XPLMGetDatavi(&dr, values, 0, 1);
Assert::AreEqual(1, count);
Assert::AreEqual(1, values[0]);
}
};
}
if you debug the lambada line 1 in a quickwatch shows that the memory has been corrupted and if you run line 1 of the lambada it crashes with a stack overflow!