Refactored C Tests
The C client tests were getting a bit unwieldy. Moved each block of tests to a separate file based on the functionality being tested. I've just put all of the test code directly in the headers because there doesn't seem to be any reason for the test headers to be included anywhere except in main.c.
This commit is contained in:
80
TestScripts/C Tests/SimuTests.h
Normal file
80
TestScripts/C Tests/SimuTests.h
Normal file
@@ -0,0 +1,80 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef SIMUTESTS_H
|
||||
#define SIMIUTESTS_H
|
||||
|
||||
#include "Test.h"
|
||||
#include "xplaneConnect.h"
|
||||
|
||||
int doSIMUTest(int value, float expected)
|
||||
{
|
||||
int size = 20;
|
||||
float actual[20];
|
||||
char* dref = "sim/operation/override/override_planepath";
|
||||
|
||||
XPCSocket sock = openUDP(IP);
|
||||
int result = pauseSim(sock, value);
|
||||
if (result >= 0)
|
||||
{
|
||||
result = getDREF(sock, dref, &actual, &size);
|
||||
}
|
||||
closeUDP(sock);
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
if (!feq(actual[i], expected) && !isnan(expected))
|
||||
{
|
||||
return -100 - i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int testSIMU_Basic()
|
||||
{
|
||||
int result = doSIMUTest(0, 0);
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = doSIMUTest(1, 1);
|
||||
if (result < 0)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
result = doSIMUTest(0, 0);
|
||||
if (result < 0)
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int testSIMU_Toggle()
|
||||
{
|
||||
int result = doSIMUTest(0, 0);
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = doSIMUTest(2, 1);
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = doSIMUTest(2, 0);
|
||||
if (result < 0)
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user