Added doxygen-compatible comments

This commit is contained in:
Markus Kauppila 2011-05-30 11:53:59 +03:00
parent 7004e4ae6d
commit 73fa28c71c
5 changed files with 1584 additions and 63 deletions

View file

@ -25,16 +25,17 @@
#include <stdlib.h>
/*! \brief return value of test case. Non-zero value means that the test failed */
static int _testReturnValue;
void
TestInit()
TestCaseInit()
{
_testReturnValue = 0;
}
void
TestQuit()
TestCaseQuit()
{
exit(_testReturnValue);
}

View file

@ -23,15 +23,34 @@
#include <SDL/SDL.h>
// \todo Should these be consts?
#define TEST_ENABLED 1
#define TEST_DISABLED 0
/*!
* Holds information about a test case
*/
typedef struct TestCaseReference {
char *name; /* "Func2Stress" */
char *description; /* "This test beats the crap out of func2()" */
int enabled; /* Set to TEST_ENABLED or TEST_DISABLED */
long requirements; /* Set to TEST_REQUIRES_OPENGL, TEST_REQUIRES_AUDIO, ... */
char *name; /*!< "Func2Stress" */
char *description; /*!< "This test beats the crap out of func2()" */
int enabled; /*!< Set to TEST_ENABLED or TEST_DISABLED */
long requirements; /*!< Set to TEST_REQUIRES_OPENGL, TEST_REQUIRES_AUDIO, ... */
} TestCaseReference;
void TestInit();
void TestQuit();
/*! \fn TestCaseInit
* Initialized the test case. Must be called at
* the beginning of every test case, before doing
* anything else.
*/
void TestCaseInit();
/*! \fn TestCaseQuit
* Deinitializes and exits the test case
*
*/
void TestCaseQuit();
void AssertEquals(char *message, Uint32 expected, Uint32 actual);

View file

@ -28,50 +28,56 @@
#include "SDL_test.h"
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "hello", "description", 1, 0 };
static const TestCaseReference test1 =
(TestCaseReference){ "hello", "description", TEST_ENABLED, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "hello2", "description", 1, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "hello2", "description", TEST_DISABLED, 0 };
static const TestCaseReference test3 =
(TestCaseReference){ "hello3", "description", TEST_ENABLED, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, NULL
&test1, &test2, &test3, NULL
};
TestCaseReference **QueryTestCaseReferences() {
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
}
void hello(void *arg){
TestInit();
/* Test case functions */
void hello(void *arg)
{
TestCaseInit();
const char *revision = SDL_GetRevision();
printf("Revision is %s\n", revision);
AssertEquals("will fail", 3, 5);
TestQuit();
TestCaseQuit();
}
void hello2(void *arg) {
TestInit();
void hello2(void *arg)
{
TestCaseInit();
// why this isn't segfaulting?
char *msg = "eello";
msg[0] = 'H';
TestQuit();
TestCaseQuit();
}
void hello3(void *arg) {
TestInit();
void hello3(void *arg)
{
TestCaseInit();
printf("hello3\n");
AssertEquals("passes", 3, 3);
TestQuit();
TestCaseQuit();
}
#endif