Add log, assert and harness (partial) to test lib
This commit is contained in:
parent
6ac6dd737a
commit
a8af7eca89
9 changed files with 621 additions and 3 deletions
116
include/SDL_test_harness.h
Normal file
116
include/SDL_test_harness.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_test_harness.h
|
||||
*
|
||||
* Include file for SDL test framework.
|
||||
*
|
||||
* This code is a part of the SDL2_test library, not the main SDL library.
|
||||
*/
|
||||
|
||||
/*
|
||||
Defines types for test case definitions and the test execution harness API.
|
||||
|
||||
Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _SDL_test_harness_h
|
||||
#define _SDL_test_harness_h
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
|
||||
//! Definitions for test case structures
|
||||
#define TEST_ENABLED 1
|
||||
#define TEST_DISABLED 0
|
||||
|
||||
//! Definitions of assert results
|
||||
#define ASSERT_PASS 1
|
||||
#define ASSERT_FAIL 0
|
||||
|
||||
//! Definition of all the possible test return values of the test case method
|
||||
#define TEST_ABORTED -1
|
||||
#define TEST_COMPLETED 0
|
||||
#define TEST_SKIPPED 1
|
||||
|
||||
//! Definition of all the possible test results for the harness
|
||||
#define TEST_RESULT_PASSED 0
|
||||
#define TEST_RESULT_FAILED 1
|
||||
#define TEST_RESULT_NO_ASSERT 2
|
||||
#define TEST_RESULT_SKIPPED 3
|
||||
#define TEST_RESULT_KILLED 4
|
||||
#define TEST_RESULT_SETUP_FAILURE 5
|
||||
|
||||
//!< Function pointer to a test case setup function (run before every test)
|
||||
typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
|
||||
|
||||
//!< Function pointer to a test case function
|
||||
typedef void (*SDLTest_TestCaseFp)(void *arg);
|
||||
|
||||
//!< Function pointer to a test case teardown function (run after every test)
|
||||
typedef void (*SDLTest_TestCaseTearDownFp)(void *arg);
|
||||
|
||||
/**
|
||||
* Holds information about a single test case.
|
||||
*/
|
||||
typedef struct SDLTest_TestCaseReference {
|
||||
/*!< Func2Stress */
|
||||
SDLTest_TestCaseFp testCase;
|
||||
/*!< Short name (or function name) "Func2Stress" */
|
||||
char *name;
|
||||
/*!< Long name or full description "This test pushes func2() to the limit." */
|
||||
char *description;
|
||||
/*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
|
||||
int enabled;
|
||||
} SDLTest_TestCaseReference;
|
||||
|
||||
/**
|
||||
* Holds information about a test suite (multiple test cases).
|
||||
*/
|
||||
typedef struct TestSuiteReference {
|
||||
/*!< "PlatformSuite" */
|
||||
char *name;
|
||||
/*!< The function that is run before each test. NULL skips. */
|
||||
SDLTest_TestCaseSetUpFp testSetUp;
|
||||
/*!< The test cases that are run as part of the suite. Last item should be NULL. */
|
||||
const SDLTest_TestCaseReference **testCases;
|
||||
/*!< The function that is run after each test. NULL skips. */
|
||||
SDLTest_TestCaseTearDownFp testTearDown;
|
||||
} TestSuiteReference;
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_test_harness_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Loading…
Add table
Add a link
Reference in a new issue