@@ -13,74 +13,78 @@ void tearDown(void) {}
1313/**
1414 * @brief Tests _pg_is_int_tuple when passed a tuple of ints
1515 */
16- static PyObject * test__pg_is_int_tuple_nominal ( PyObject * self ,
17- PyObject * _null ) {
18- PyObject * arg1 = Py_BuildValue ("(iii)" , 1 , 2 , 3 );
19- PyObject * arg2 = Py_BuildValue ("(iii)" , -1 , -2 , -3 );
20- PyObject * arg3 = Py_BuildValue ("(iii)" , 1 , -2 , -3 );
16+ PG_CTEST ( test__pg_is_int_tuple_nominal )
17+ {
18+ PyObject * arg1 = Py_BuildValue ("(iii)" , 1 , 2 , 3 );
19+ PyObject * arg2 = Py_BuildValue ("(iii)" , -1 , -2 , -3 );
20+ PyObject * arg3 = Py_BuildValue ("(iii)" , 1 , -2 , -3 );
2121
22- TEST_ASSERT_EQUAL (1 , _pg_is_int_tuple (arg1 ));
23- TEST_ASSERT_EQUAL (1 , _pg_is_int_tuple (arg2 ));
24- TEST_ASSERT_EQUAL (1 , _pg_is_int_tuple (arg3 ));
22+ TEST_ASSERT_EQUAL (1 , _pg_is_int_tuple (arg1 ));
23+ TEST_ASSERT_EQUAL (1 , _pg_is_int_tuple (arg2 ));
24+ TEST_ASSERT_EQUAL (1 , _pg_is_int_tuple (arg3 ));
2525
26- Py_RETURN_NONE ;
26+ Py_RETURN_NONE ;
2727}
2828
2929/**
3030 * @brief Tests _pg_is_int_tuple when passed a tuple of non-numeric values
3131 */
32- static PyObject * test__pg_is_int_tuple_failureModes ( PyObject * self ,
33- PyObject * _null ) {
34- PyObject * arg1 =
35- Py_BuildValue ("(sss)" , (char * )"Larry" , (char * )"Moe" , (char * )"Curly" );
36- PyObject * arg2 = Py_BuildValue ("(sss)" , (char * )NULL , (char * )NULL ,
37- (char * )NULL ); // tuple of None's
38- PyObject * arg3 = Py_BuildValue ("(OOO)" , arg1 , arg2 , arg1 );
39-
40- TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg1 ));
41- TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg2 ));
42- TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg3 ));
43-
44- Py_RETURN_NONE ;
32+ PG_CTEST ( test__pg_is_int_tuple_failureModes )
33+ {
34+ PyObject * arg1 =
35+ Py_BuildValue ("(sss)" , (char * )"Larry" , (char * )"Moe" , (char * )"Curly" );
36+ PyObject * arg2 = Py_BuildValue ("(sss)" , (char * )NULL , (char * )NULL ,
37+ (char * )NULL ); // tuple of None's
38+ PyObject * arg3 = Py_BuildValue ("(OOO)" , arg1 , arg2 , arg1 );
39+
40+ TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg1 ));
41+ TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg2 ));
42+ TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg3 ));
43+
44+ Py_RETURN_NONE ;
4545}
4646
4747/**
4848 * @brief Tests _pg_is_int_tuple when passed a tuple of floats
4949 */
50- static PyObject * test__pg_is_int_tuple_floats (PyObject * self , PyObject * _null ) {
51- PyObject * arg1 = Py_BuildValue ("(ddd)" , 1.0 , 2.0 , 3.0 );
52- PyObject * arg2 = Py_BuildValue ("(ddd)" , -1.1 , -2.2 , -3.3 );
53- PyObject * arg3 = Py_BuildValue ("(ddd)" , 1.0 , -2.0 , -3.1 );
50+ PG_CTEST (test__pg_is_int_tuple_floats )
51+ {
52+ PyObject * arg1 = Py_BuildValue ("(ddd)" , 1.0 , 2.0 , 3.0 );
53+ PyObject * arg2 = Py_BuildValue ("(ddd)" , -1.1 , -2.2 , -3.3 );
54+ PyObject * arg3 = Py_BuildValue ("(ddd)" , 1.0 , -2.0 , -3.1 );
5455
55- TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg1 ));
56- TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg2 ));
57- TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg3 ));
56+ TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg1 ));
57+ TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg2 ));
58+ TEST_ASSERT_EQUAL (0 , _pg_is_int_tuple (arg3 ));
5859
59- Py_RETURN_NONE ;
60+ Py_RETURN_NONE ;
6061}
6162
6263/*=======Test Reset Option=====*/
6364/* This must be void(void) */
64- void resetTest (void ) {
65- tearDown ();
66- setUp ();
65+ void resetTest (void )
66+ {
67+ tearDown ();
68+ setUp ();
6769}
6870
6971/*=======Exposed Test Reset Option=====*/
70- static PyObject * reset_test (PyObject * self , PyObject * _null ) {
71- resetTest ();
72+ static PyObject * reset_test (PyObject * self , PyObject * _null )
73+ {
74+ resetTest ();
7275
73- Py_RETURN_NONE ;
76+ Py_RETURN_NONE ;
7477}
7578
7679/*=======Run The Tests=======*/
77- static PyObject * run_tests (PyObject * self , PyObject * _null ) {
78- UnityBegin ("base_ctest.c" );
79- RUN_TEST_PG_INTERNAL (test__pg_is_int_tuple_nominal , 15 , self , _null );
80- RUN_TEST_PG_INTERNAL (test__pg_is_int_tuple_failureModes , 29 , self , _null );
81- RUN_TEST_PG_INTERNAL (test__pg_is_int_tuple_floats , 46 , self , _null );
82-
83- return PyLong_FromLong (UnityEnd ());
80+ static PyObject * run_tests (PyObject * self , PyObject * _null )
81+ {
82+ UnityBegin ("base_ctest.c" );
83+ RUN_TEST_PG_INTERNAL (test__pg_is_int_tuple_nominal );
84+ RUN_TEST_PG_INTERNAL (test__pg_is_int_tuple_failureModes );
85+ RUN_TEST_PG_INTERNAL (test__pg_is_int_tuple_floats );
86+
87+ return PyLong_FromLong (UnityEnd ());
8488}
8589
8690static PyMethodDef base_test_methods [] = {
@@ -99,37 +103,27 @@ static PyMethodDef base_test_methods[] = {
99103 "Runs all the tests in this test wuite" },
100104 {NULL , NULL , 0 , NULL }};
101105
102- MODINIT_DEFINE (base_ctest ) {
103- PyObject * module ;
104-
105- static struct PyModuleDef _module = {
106- PyModuleDef_HEAD_INIT ,
107- "base_ctest" ,
108- "C unit tests for the pygame.base internal implementation" ,
109- -1 ,
110- base_test_methods ,
111- NULL ,
112- NULL ,
113- NULL ,
114- NULL };
115-
116- /* create the module */
117- module = PyModule_Create (& _module );
118- if (!module ) {
119- return NULL ;
120- }
121-
122- return module ;
106+ MODINIT_DEFINE (base_ctest )
107+ {
108+ PyObject * module ;
109+
110+ static struct PyModuleDef _module = {
111+ PyModuleDef_HEAD_INIT ,
112+ "base_ctest" ,
113+ "C unit tests for the pygame.base internal implementation" ,
114+ -1 ,
115+ base_test_methods ,
116+ NULL ,
117+ NULL ,
118+ NULL ,
119+ NULL };
120+
121+ /* create the module */
122+ module = PyModule_Create (& _module );
123+ if (!module )
124+ {
125+ return NULL ;
126+ }
127+
128+ return module ;
123129}
124-
125- // #undef main
126- // /*=======MAIN=====*/
127- // int main(void) {
128- // Py_Initialize();
129- // UnityBegin("test_base.c");
130- // RUN_TEST(test__pg_is_int_tuple_nominal, 17);
131- // RUN_TEST(test__pg_is_int_tuple_failureModes, 31);
132- // RUN_TEST(test__pg_is_int_tuple_floats, 45);
133-
134- // return (UnityEnd());
135- // }
0 commit comments