include/SDL_test_harness.h
changeset 6717 2acd95060548
child 6721 53b71f45a53a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/SDL_test_harness.h	Fri Nov 30 23:25:34 2012 -0800
     1.3 @@ -0,0 +1,116 @@
     1.4 +/*
     1.5 +  Simple DirectMedia Layer
     1.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     1.7 +
     1.8 +  This software is provided 'as-is', without any express or implied
     1.9 +  warranty.  In no event will the authors be held liable for any damages
    1.10 +  arising from the use of this software.
    1.11 +
    1.12 +  Permission is granted to anyone to use this software for any purpose,
    1.13 +  including commercial applications, and to alter it and redistribute it
    1.14 +  freely, subject to the following restrictions:
    1.15 +
    1.16 +  1. The origin of this software must not be misrepresented; you must not
    1.17 +     claim that you wrote the original software. If you use this software
    1.18 +     in a product, an acknowledgment in the product documentation would be
    1.19 +     appreciated but is not required.
    1.20 +  2. Altered source versions must be plainly marked as such, and must not be
    1.21 +     misrepresented as being the original software.
    1.22 +  3. This notice may not be removed or altered from any source distribution.
    1.23 +*/
    1.24 +
    1.25 +/**
    1.26 + *  \file SDL_test_harness.h
    1.27 + *  
    1.28 + *  Include file for SDL test framework.
    1.29 + *
    1.30 + *  This code is a part of the SDL2_test library, not the main SDL library.
    1.31 + */
    1.32 +
    1.33 +/*
    1.34 +  Defines types for test case definitions and the test execution harness API.
    1.35 +  
    1.36 +  Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
    1.37 +*/
    1.38 +
    1.39 +#ifndef _SDL_test_harness_h
    1.40 +#define _SDL_test_harness_h
    1.41 +
    1.42 +#include "begin_code.h"
    1.43 +/* Set up for C function definitions, even when using C++ */
    1.44 +#ifdef __cplusplus
    1.45 +/* *INDENT-OFF* */
    1.46 +extern "C" {
    1.47 +/* *INDENT-ON* */
    1.48 +#endif
    1.49 +
    1.50 +
    1.51 +//! Definitions for test case structures
    1.52 +#define TEST_ENABLED  1
    1.53 +#define TEST_DISABLED 0
    1.54 +
    1.55 +//! Definitions of assert results
    1.56 +#define ASSERT_PASS		1
    1.57 +#define ASSERT_FAIL		0
    1.58 +
    1.59 +//! Definition of all the possible test return values of the test case method
    1.60 +#define TEST_ABORTED		-1
    1.61 +#define TEST_COMPLETED		 0
    1.62 +#define TEST_SKIPPED		 1
    1.63 +
    1.64 +//! Definition of all the possible test results for the harness
    1.65 +#define TEST_RESULT_PASSED			0
    1.66 +#define TEST_RESULT_FAILED			1
    1.67 +#define TEST_RESULT_NO_ASSERT			2
    1.68 +#define TEST_RESULT_SKIPPED			3
    1.69 +#define TEST_RESULT_KILLED			4
    1.70 +#define TEST_RESULT_SETUP_FAILURE		5
    1.71 +
    1.72 +//!< Function pointer to a test case setup function (run before every test)
    1.73 +typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
    1.74 +
    1.75 +//!< Function pointer to a test case function
    1.76 +typedef void (*SDLTest_TestCaseFp)(void *arg);
    1.77 +
    1.78 +//!< Function pointer to a test case teardown function (run after every test)
    1.79 +typedef void  (*SDLTest_TestCaseTearDownFp)(void *arg);
    1.80 +
    1.81 +/**
    1.82 + * Holds information about a single test case.
    1.83 + */
    1.84 +typedef struct SDLTest_TestCaseReference {
    1.85 +	/*!< Func2Stress */
    1.86 +	SDLTest_TestCaseFp testCase;
    1.87 +	/*!< Short name (or function name) "Func2Stress" */
    1.88 +	char *name;
    1.89 +	/*!< Long name or full description "This test pushes func2() to the limit." */
    1.90 +	char *description;
    1.91 +	/*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
    1.92 +	int enabled;
    1.93 +} SDLTest_TestCaseReference;
    1.94 +
    1.95 +/**
    1.96 + * Holds information about a test suite (multiple test cases).
    1.97 + */
    1.98 +typedef struct TestSuiteReference {
    1.99 +	/*!< "PlatformSuite" */
   1.100 +	char *name;
   1.101 +	/*!< The function that is run before each test. NULL skips. */
   1.102 +	SDLTest_TestCaseSetUpFp testSetUp;
   1.103 +	/*!< The test cases that are run as part of the suite. Last item should be NULL. */
   1.104 +	const SDLTest_TestCaseReference **testCases;
   1.105 +	/*!< The function that is run after each test. NULL skips. */
   1.106 +	SDLTest_TestCaseTearDownFp testTearDown;
   1.107 +} TestSuiteReference;
   1.108 +
   1.109 +/* Ends C function definitions when using C++ */
   1.110 +#ifdef __cplusplus
   1.111 +/* *INDENT-OFF* */
   1.112 +}
   1.113 +/* *INDENT-ON* */
   1.114 +#endif
   1.115 +#include "close_code.h"
   1.116 +
   1.117 +#endif /* _SDL_test_harness_h */
   1.118 +
   1.119 +/* vi: set ts=4 sw=4 expandtab: */