A simple test-framework for TwinCAT3 C/C++.
Based on kudaba/simpletest, kudos!
See kudaba/simpletest README.md for basic usage.
Include the static library TcCppTestLib.lib
into your project.
See Sample25: Static Library for more informations.
// Tests/ExampleTests.h
#pragma once
#include "dsian/TcCppTest.h"
DEFINE_TEST_G(BasicExampleTests, ExampleTestsGroup)
{
TEST(1 == 1);
}
///////////////////////////////////////////////////////////////////////////////
// Example.cpp
#include "TcPch.h"
#pragma hdrstop
#include "dsian/TcCppTest.h"
#include "Tests/ExampleTests.h"
// . . .
///////////////////////////////////////////////////////////////////////////////
// State transition from PREOP to SAFEOP
//
// Initialize input parameters
// Allocate memory
HRESULT CExample::SetObjStatePS(PTComInitDataHdr pInitData)
{
m_Trace.Log(tlVerbose, FENTERA);
HRESULT hr = S_OK;
IMPLEMENT_ITCOMOBJECT_EVALUATE_INITDATA(pInitData);
hr = dsian::TestFixture::ExecuteAllTests(
[&](auto msg) { m_Trace.Log(tlAlways, "%s", msg); }) ? hr : ADS_E_ABORTED;
m_Trace.Log(tlVerbose, FLEAVEA "hr=0x%08x", hr);
return hr;
}
// ...