Skip to content

Commit feea0f5

Browse files
committed
Code formatting
1 parent aeea700 commit feea0f5

File tree

2 files changed

+82
-93
lines changed

2 files changed

+82
-93
lines changed

ctest/base_ctest.c

Lines changed: 62 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,78 +13,72 @@ void tearDown(void) {}
1313
/**
1414
* @brief Tests _pg_is_int_tuple when passed a tuple of ints
1515
*/
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);
16+
PG_CTEST(test__pg_is_int_tuple_nominal) {
17+
PyObject *arg1 = Py_BuildValue("(iii)", 1, 2, 3);
18+
PyObject *arg2 = Py_BuildValue("(iii)", -1, -2, -3);
19+
PyObject *arg3 = Py_BuildValue("(iii)", 1, -2, -3);
2120

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));
21+
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg1));
22+
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg2));
23+
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg3));
2524

26-
Py_RETURN_NONE;
25+
Py_RETURN_NONE;
2726
}
2827

2928
/**
3029
* @brief Tests _pg_is_int_tuple when passed a tuple of non-numeric values
3130
*/
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;
31+
PG_CTEST(test__pg_is_int_tuple_failureModes) {
32+
PyObject *arg1 =
33+
Py_BuildValue("(sss)", (char *)"Larry", (char *)"Moe", (char *)"Curly");
34+
PyObject *arg2 = Py_BuildValue("(sss)", (char *)NULL, (char *)NULL,
35+
(char *)NULL); // tuple of None's
36+
PyObject *arg3 = Py_BuildValue("(OOO)", arg1, arg2, arg1);
37+
38+
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg1));
39+
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg2));
40+
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg3));
41+
42+
Py_RETURN_NONE;
4543
}
4644

4745
/**
4846
* @brief Tests _pg_is_int_tuple when passed a tuple of floats
4947
*/
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);
48+
PG_CTEST(test__pg_is_int_tuple_floats) {
49+
PyObject *arg1 = Py_BuildValue("(ddd)", 1.0, 2.0, 3.0);
50+
PyObject *arg2 = Py_BuildValue("(ddd)", -1.1, -2.2, -3.3);
51+
PyObject *arg3 = Py_BuildValue("(ddd)", 1.0, -2.0, -3.1);
5552

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));
53+
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg1));
54+
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg2));
55+
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg3));
5956

60-
Py_RETURN_NONE;
57+
Py_RETURN_NONE;
6158
}
6259

6360
/*=======Test Reset Option=====*/
6461
/* This must be void(void) */
65-
void resetTest(void)
66-
{
67-
tearDown();
68-
setUp();
62+
void resetTest(void) {
63+
tearDown();
64+
setUp();
6965
}
7066

7167
/*=======Exposed Test Reset Option=====*/
72-
static PyObject *reset_test(PyObject *self, PyObject *_null)
73-
{
74-
resetTest();
68+
static PyObject *reset_test(PyObject *self, PyObject *_null) {
69+
resetTest();
7570

76-
Py_RETURN_NONE;
71+
Py_RETURN_NONE;
7772
}
7873

7974
/*=======Run The Tests=======*/
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());
75+
static PyObject *run_tests(PyObject *self, PyObject *_null) {
76+
UnityBegin("base_ctest.c");
77+
RUN_TEST_PG_INTERNAL(test__pg_is_int_tuple_nominal);
78+
RUN_TEST_PG_INTERNAL(test__pg_is_int_tuple_failureModes);
79+
RUN_TEST_PG_INTERNAL(test__pg_is_int_tuple_floats);
80+
81+
return PyLong_FromLong(UnityEnd());
8882
}
8983

9084
static PyMethodDef base_test_methods[] = {
@@ -103,27 +97,25 @@ static PyMethodDef base_test_methods[] = {
10397
"Runs all the tests in this test wuite"},
10498
{NULL, NULL, 0, NULL}};
10599

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

ctest/test_common.h

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
#ifndef TEST_COMMON_H
66
#define TEST_COMMON_H
77

8-
struct TestCase
9-
{
10-
char *test_name;
11-
int line_num;
8+
struct TestCase {
9+
char *test_name;
10+
int line_num;
1211
};
1312

1413
/*
@@ -23,25 +22,23 @@ struct TestCase
2322
case that we tell it about and automatically populates the unity fields
2423
with the requisite data.
2524
*/
26-
#define PG_CTEST(TestFunc) \
27-
static struct TestCase meta_##TestFunc = {#TestFunc, __LINE__}; \
28-
static PyObject *TestFunc##(PyObject * self, PyObject * _null)
25+
#define PG_CTEST(TestFunc) \
26+
static struct TestCase meta_##TestFunc = {#TestFunc, __LINE__}; \
27+
static PyObject *TestFunc##(PyObject * self, PyObject * _null)
2928

30-
#define RUN_TEST_PG_INTERNAL(TestFunc) \
31-
{ \
32-
Unity.CurrentTestName = meta_##TestFunc.test_name; \
33-
Unity.CurrentTestLineNumber = meta_##TestFunc.line_num; \
34-
Unity.NumberOfTests++; \
35-
if (TEST_PROTECT()) \
36-
{ \
37-
setUp(); \
38-
TestFunc(self, _null); \
39-
} \
40-
if (TEST_PROTECT()) \
41-
{ \
42-
tearDown(); \
43-
} \
44-
UnityConcludeTest(); \
45-
}
29+
#define RUN_TEST_PG_INTERNAL(TestFunc) \
30+
{ \
31+
Unity.CurrentTestName = meta_##TestFunc.test_name; \
32+
Unity.CurrentTestLineNumber = meta_##TestFunc.line_num; \
33+
Unity.NumberOfTests++; \
34+
if (TEST_PROTECT()) { \
35+
setUp(); \
36+
TestFunc(self, _null); \
37+
} \
38+
if (TEST_PROTECT()) { \
39+
tearDown(); \
40+
} \
41+
UnityConcludeTest(); \
42+
}
4643

4744
#endif // #ifndef TEST_COMMON_H

0 commit comments

Comments
 (0)