include/SDL_test_harness.h
changeset 6717 2acd95060548
child 6721 53b71f45a53a
equal deleted inserted replaced
6716:1616f6b3738c 6717:2acd95060548
       
     1 /*
       
     2   Simple DirectMedia Layer
       
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
       
     4 
       
     5   This software is provided 'as-is', without any express or implied
       
     6   warranty.  In no event will the authors be held liable for any damages
       
     7   arising from the use of this software.
       
     8 
       
     9   Permission is granted to anyone to use this software for any purpose,
       
    10   including commercial applications, and to alter it and redistribute it
       
    11   freely, subject to the following restrictions:
       
    12 
       
    13   1. The origin of this software must not be misrepresented; you must not
       
    14      claim that you wrote the original software. If you use this software
       
    15      in a product, an acknowledgment in the product documentation would be
       
    16      appreciated but is not required.
       
    17   2. Altered source versions must be plainly marked as such, and must not be
       
    18      misrepresented as being the original software.
       
    19   3. This notice may not be removed or altered from any source distribution.
       
    20 */
       
    21 
       
    22 /**
       
    23  *  \file SDL_test_harness.h
       
    24  *  
       
    25  *  Include file for SDL test framework.
       
    26  *
       
    27  *  This code is a part of the SDL2_test library, not the main SDL library.
       
    28  */
       
    29 
       
    30 /*
       
    31   Defines types for test case definitions and the test execution harness API.
       
    32   
       
    33   Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
       
    34 */
       
    35 
       
    36 #ifndef _SDL_test_harness_h
       
    37 #define _SDL_test_harness_h
       
    38 
       
    39 #include "begin_code.h"
       
    40 /* Set up for C function definitions, even when using C++ */
       
    41 #ifdef __cplusplus
       
    42 /* *INDENT-OFF* */
       
    43 extern "C" {
       
    44 /* *INDENT-ON* */
       
    45 #endif
       
    46 
       
    47 
       
    48 //! Definitions for test case structures
       
    49 #define TEST_ENABLED  1
       
    50 #define TEST_DISABLED 0
       
    51 
       
    52 //! Definitions of assert results
       
    53 #define ASSERT_PASS		1
       
    54 #define ASSERT_FAIL		0
       
    55 
       
    56 //! Definition of all the possible test return values of the test case method
       
    57 #define TEST_ABORTED		-1
       
    58 #define TEST_COMPLETED		 0
       
    59 #define TEST_SKIPPED		 1
       
    60 
       
    61 //! Definition of all the possible test results for the harness
       
    62 #define TEST_RESULT_PASSED			0
       
    63 #define TEST_RESULT_FAILED			1
       
    64 #define TEST_RESULT_NO_ASSERT			2
       
    65 #define TEST_RESULT_SKIPPED			3
       
    66 #define TEST_RESULT_KILLED			4
       
    67 #define TEST_RESULT_SETUP_FAILURE		5
       
    68 
       
    69 //!< Function pointer to a test case setup function (run before every test)
       
    70 typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
       
    71 
       
    72 //!< Function pointer to a test case function
       
    73 typedef void (*SDLTest_TestCaseFp)(void *arg);
       
    74 
       
    75 //!< Function pointer to a test case teardown function (run after every test)
       
    76 typedef void  (*SDLTest_TestCaseTearDownFp)(void *arg);
       
    77 
       
    78 /**
       
    79  * Holds information about a single test case.
       
    80  */
       
    81 typedef struct SDLTest_TestCaseReference {
       
    82 	/*!< Func2Stress */
       
    83 	SDLTest_TestCaseFp testCase;
       
    84 	/*!< Short name (or function name) "Func2Stress" */
       
    85 	char *name;
       
    86 	/*!< Long name or full description "This test pushes func2() to the limit." */
       
    87 	char *description;
       
    88 	/*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
       
    89 	int enabled;
       
    90 } SDLTest_TestCaseReference;
       
    91 
       
    92 /**
       
    93  * Holds information about a test suite (multiple test cases).
       
    94  */
       
    95 typedef struct TestSuiteReference {
       
    96 	/*!< "PlatformSuite" */
       
    97 	char *name;
       
    98 	/*!< The function that is run before each test. NULL skips. */
       
    99 	SDLTest_TestCaseSetUpFp testSetUp;
       
   100 	/*!< The test cases that are run as part of the suite. Last item should be NULL. */
       
   101 	const SDLTest_TestCaseReference **testCases;
       
   102 	/*!< The function that is run after each test. NULL skips. */
       
   103 	SDLTest_TestCaseTearDownFp testTearDown;
       
   104 } TestSuiteReference;
       
   105 
       
   106 /* Ends C function definitions when using C++ */
       
   107 #ifdef __cplusplus
       
   108 /* *INDENT-OFF* */
       
   109 }
       
   110 /* *INDENT-ON* */
       
   111 #endif
       
   112 #include "close_code.h"
       
   113 
       
   114 #endif /* _SDL_test_harness_h */
       
   115 
       
   116 /* vi: set ts=4 sw=4 expandtab: */