Skip to content

Commit cdf2baf

Browse files
committed
Formatting
1 parent 5b9e484 commit cdf2baf

File tree

3 files changed

+96
-98
lines changed

3 files changed

+96
-98
lines changed

ctest/base_ctest.c

Lines changed: 81 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,114 +13,113 @@ void tearDown(void) {}
1313
/**
1414
* @brief Tests _pg_is_int_tuple when passed a tuple of ints
1515
*/
16-
static PyObject*
17-
test__pg_is_int_tuple_nominal(PyObject *self, PyObject *_null)
18-
{
19-
PyObject *arg1 = Py_BuildValue("(iii)", 1, 2, 3);
20-
PyObject *arg2 = Py_BuildValue("(iii)", -1, -2, -3);
21-
PyObject *arg3 = Py_BuildValue("(iii)", 1, -2, -3);
22-
23-
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg1));
24-
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg2));
25-
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg3));
26-
27-
Py_RETURN_NONE;
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);
21+
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));
25+
26+
Py_RETURN_NONE;
2827
}
2928

3029
/**
3130
* @brief Tests _pg_is_int_tuple when passed a tuple of non-numeric values
3231
*/
33-
static PyObject*
34-
test__pg_is_int_tuple_failureModes(PyObject *self, PyObject *_null)
35-
{
36-
PyObject *arg1 =
37-
Py_BuildValue("(sss)", (char *)"Larry", (char *)"Moe", (char *)"Curly");
38-
PyObject *arg2 = Py_BuildValue("(sss)", (char *)NULL, (char *)NULL,
39-
(char *)NULL); // tuple of None's
40-
PyObject *arg3 = Py_BuildValue("(OOO)", arg1, arg2, arg1);
41-
42-
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg1));
43-
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg2));
44-
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg3));
45-
46-
Py_RETURN_NONE;
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;
4745
}
4846

4947
/**
5048
* @brief Tests _pg_is_int_tuple when passed a tuple of floats
5149
*/
52-
static PyObject*
53-
test__pg_is_int_tuple_floats(PyObject *self, PyObject *_null)
54-
{
55-
PyObject *arg1 = Py_BuildValue("(ddd)", 1.0, 2.0, 3.0);
56-
PyObject *arg2 = Py_BuildValue("(ddd)", -1.1, -2.2, -3.3);
57-
PyObject *arg3 = Py_BuildValue("(ddd)", 1.0, -2.0, -3.1);
58-
59-
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg1));
60-
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg2));
61-
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg3));
62-
63-
Py_RETURN_NONE;
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);
54+
55+
TEST_ASSERT_EQUAL(1, _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));
58+
59+
Py_RETURN_NONE;
6460
}
6561

6662
/*=======Test Reset Option=====*/
6763
/* This must be void(void) */
68-
void resetTest(void)
69-
{
70-
tearDown();
71-
setUp();
64+
void resetTest(void) {
65+
tearDown();
66+
setUp();
7267
}
7368

7469
/*=======Exposed Test Reset Option=====*/
75-
static PyObject*
76-
reset_test(PyObject *self, PyObject *_null)
77-
{
78-
resetTest();
70+
static PyObject *reset_test(PyObject *self, PyObject *_null) {
71+
resetTest();
7972

80-
Py_RETURN_NONE;
73+
Py_RETURN_NONE;
8174
}
8275

8376
/*=======Run The Tests=======*/
84-
static PyObject*
85-
run_tests(PyObject *self, PyObject *_null)
86-
{
87-
UnityBegin("base_ctest.c");
88-
RUN_TEST_PG_INTERNAL(test__pg_is_int_tuple_nominal, 15, self, _null);
89-
RUN_TEST_PG_INTERNAL(test__pg_is_int_tuple_failureModes, 29, self, _null);
90-
RUN_TEST_PG_INTERNAL(test__pg_is_int_tuple_floats, 46, self, _null);
91-
92-
return PyLong_FromLong(UnityEnd());
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());
9384
}
9485

9586
static PyMethodDef base_test_methods[] = {
96-
{"test__pg_is_int_tuple_nominal", (PyCFunction)test__pg_is_int_tuple_nominal, METH_NOARGS, "Tests _pg_is_int_tuple when passed a tuple of ints"},
97-
{"test__pg_is_int_tuple_failureModes", (PyCFunction)test__pg_is_int_tuple_failureModes, METH_NOARGS, "Tests _pg_is_int_tuple when passed a tuple of non-numeric values"},
98-
{"test__pg_is_int_tuple_floats", (PyCFunction)test__pg_is_int_tuple_floats, METH_NOARGS, "Tests _pg_is_int_tuple when passed a tuple of floats"},
99-
{"reset_test", (PyCFunction)reset_test, METH_NOARGS, "Resets the test suite between tests, run_tests automatically calls this after each test case it calls"},
100-
{"run_tests", (PyCFunction)run_tests, METH_NOARGS, "Runs all the tests in this test wuite"},
87+
{"test__pg_is_int_tuple_nominal",
88+
(PyCFunction)test__pg_is_int_tuple_nominal, METH_NOARGS,
89+
"Tests _pg_is_int_tuple when passed a tuple of ints"},
90+
{"test__pg_is_int_tuple_failureModes",
91+
(PyCFunction)test__pg_is_int_tuple_failureModes, METH_NOARGS,
92+
"Tests _pg_is_int_tuple when passed a tuple of non-numeric values"},
93+
{"test__pg_is_int_tuple_floats", (PyCFunction)test__pg_is_int_tuple_floats,
94+
METH_NOARGS, "Tests _pg_is_int_tuple when passed a tuple of floats"},
95+
{"reset_test", (PyCFunction)reset_test, METH_NOARGS,
96+
"Resets the test suite between tests, run_tests automatically calls this "
97+
"after each test case it calls"},
98+
{"run_tests", (PyCFunction)run_tests, METH_NOARGS,
99+
"Runs all the tests in this test wuite"},
101100
{NULL, NULL, 0, NULL}};
102101

103-
MODINIT_DEFINE(base_ctest)
104-
{
105-
PyObject* module;
106-
107-
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
108-
"base_ctest",
109-
"C unit tests for the pygame.base internal implementation",
110-
-1,
111-
base_test_methods,
112-
NULL,
113-
NULL,
114-
NULL,
115-
NULL};
116-
117-
/* create the module */
118-
module = PyModule_Create(&_module);
119-
if (!module) {
120-
return NULL;
121-
}
122-
123-
return module;
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;
124123
}
125124

126125
// #undef main

ctest/test_common.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
#ifndef TEST_COMMON_H
44
#define TEST_COMMON_H
55

6-
#define RUN_TEST_PG_INTERNAL(TestFunc, TestLineNum, self_arg, null_arg) \
7-
{ \
8-
Unity.CurrentTestName = #TestFunc; \
9-
Unity.CurrentTestLineNumber = TestLineNum; \
10-
Unity.NumberOfTests++; \
11-
if (TEST_PROTECT()) \
12-
{ \
13-
setUp(); \
14-
TestFunc(self_arg, null_arg); \
15-
} \
16-
if (TEST_PROTECT()) \
17-
{ \
18-
tearDown(); \
19-
} \
20-
UnityConcludeTest(); \
21-
}
6+
#define RUN_TEST_PG_INTERNAL(TestFunc, TestLineNum, self_arg, null_arg) \
7+
{ \
8+
Unity.CurrentTestName = #TestFunc; \
9+
Unity.CurrentTestLineNumber = TestLineNum; \
10+
Unity.NumberOfTests++; \
11+
if (TEST_PROTECT()) { \
12+
setUp(); \
13+
TestFunc(self_arg, null_arg); \
14+
} \
15+
if (TEST_PROTECT()) { \
16+
tearDown(); \
17+
} \
18+
UnityConcludeTest(); \
19+
}
2220

2321
#endif // #ifndef TEST_COMMON_H

test/ctest_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
except ModuleNotFoundError:
77
pass
88

9+
910
class Ctest(unittest.TestCase):
1011
@unittest.skipIf(base_ctest is None, "base_ctest not built")
1112
def test_run_base_ctests(self):

0 commit comments

Comments
 (0)