Skip to content

Commit 5b3e77e

Browse files
authored
Apply clang format for tests (#149)
$ clang-format -i *.c crc32.h hagl_hal_color.h hagl_hal.h
1 parent 663cd34 commit 5b3e77e

8 files changed

Lines changed: 172 additions & 312 deletions

File tree

tests/crc32.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ SPDX-License-Identifier: MIT
3434
#ifndef _CRC32_H
3535
#define _CRC32_H
3636

37-
#include <stdint.h>
3837
#include <stddef.h>
38+
#include <stdint.h>
3939

40-
static uint32_t
41-
crc32(const uint8_t *data, size_t length) {
40+
static uint32_t crc32(const uint8_t *data, size_t length) {
4241
uint32_t crc = 0xFFFFFFFF;
4342
for (size_t i = 0; i < length; i++) {
4443
crc ^= data[i];

tests/test_circle.c

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,21 @@ SPDX-License-Identifier: MIT
3333

3434
#include <string.h>
3535

36-
#include "greatest.h"
3736
#include "crc32.h"
37+
#include "greatest.h"
3838
#include "hagl/bitmap.h"
39-
#include "hagl/pixel.h"
40-
#include "hagl/clip.h"
4139
#include "hagl/circle.h"
40+
#include "hagl/clip.h"
41+
#include "hagl/pixel.h"
4242

43-
#define TEST_WIDTH 320
43+
#define TEST_WIDTH 320
4444
#define TEST_HEIGHT 240
45-
#define TEST_DEPTH 16
45+
#define TEST_DEPTH 16
4646

4747
static hagl_bitmap_t bitmap;
4848
static uint8_t buffer[TEST_WIDTH * TEST_HEIGHT * (TEST_DEPTH / 8)];
4949

50-
static uint32_t
51-
count_pixels(hagl_bitmap_t *bitmap, hagl_color_t color) {
50+
static uint32_t count_pixels(hagl_bitmap_t *bitmap, hagl_color_t color) {
5251
uint32_t count = 0;
5352
for (int16_t y = 0; y < bitmap->height; y++) {
5453
for (int16_t x = 0; x < bitmap->width; x++) {
@@ -60,8 +59,7 @@ count_pixels(hagl_bitmap_t *bitmap, hagl_color_t color) {
6059
return count;
6160
}
6261

63-
static void
64-
setup_callback(void *data) {
62+
static void setup_callback(void *data) {
6563
memset(buffer, 0, sizeof(buffer));
6664
hagl_bitmap_init(&bitmap, TEST_WIDTH, TEST_HEIGHT, TEST_DEPTH, buffer);
6765
}
@@ -77,8 +75,7 @@ setup_callback(void *data) {
7775
* \ /
7876
* (100,110)
7977
*/
80-
TEST
81-
test_draw_circle(void) {
78+
TEST test_draw_circle(void) {
8279
hagl_draw_circle(&bitmap, 100, 100, 10, 0xFFFF);
8380

8481
/* On outline: cardinal points */
@@ -102,8 +99,7 @@ test_draw_circle(void) {
10299
PASS();
103100
}
104101

105-
TEST
106-
test_draw_circle_regression(void) {
102+
TEST test_draw_circle_regression(void) {
107103
hagl_draw_circle(&bitmap, 100, 100, 10, 0xFFFF);
108104

109105
uint32_t crc = crc32(bitmap.buffer, bitmap.size);
@@ -115,8 +111,7 @@ test_draw_circle_regression(void) {
115111
/*
116112
* Circle with radius 0:
117113
*/
118-
TEST
119-
test_draw_circle_radius_0(void) {
114+
TEST test_draw_circle_radius_0(void) {
120115
hagl_draw_circle(&bitmap, 50, 50, 0, 0xFFFF);
121116

122117
/* On outline: the center pixel */
@@ -145,8 +140,7 @@ test_draw_circle_radius_0(void) {
145140
*
146141
* Produces a cross/diamond with 4 pixels. Center is empty.
147142
*/
148-
TEST
149-
test_draw_circle_radius_1(void) {
143+
TEST test_draw_circle_radius_1(void) {
150144
hagl_draw_circle(&bitmap, 100, 100, 1, 0xFFFF);
151145

152146
/* On outline: cardinal neighbors */
@@ -170,8 +164,7 @@ test_draw_circle_radius_1(void) {
170164
PASS();
171165
}
172166

173-
TEST
174-
test_draw_circle_radius_1_regression(void) {
167+
TEST test_draw_circle_radius_1_regression(void) {
175168
hagl_draw_circle(&bitmap, 100, 100, 1, 0xFFFF);
176169

177170
uint32_t crc = crc32(bitmap.buffer, bitmap.size);
@@ -184,8 +177,7 @@ test_draw_circle_radius_1_regression(void) {
184177
* Circle clipped by top-left corner of display:
185178
* Center at (5,5), radius 10. Top and left arcs are clipped.
186179
*/
187-
TEST
188-
test_draw_circle_clip_top_left(void) {
180+
TEST test_draw_circle_clip_top_left(void) {
189181
hagl_draw_circle(&bitmap, 5, 5, 10, 0xFFFF);
190182

191183
/* On outline: visible cardinal points */
@@ -209,8 +201,7 @@ test_draw_circle_clip_top_left(void) {
209201
PASS();
210202
}
211203

212-
TEST
213-
test_draw_circle_clip_top_left_regression(void) {
204+
TEST test_draw_circle_clip_top_left_regression(void) {
214205
hagl_draw_circle(&bitmap, 5, 5, 10, 0xFFFF);
215206

216207
uint32_t crc = crc32(bitmap.buffer, bitmap.size);
@@ -229,8 +220,7 @@ test_draw_circle_clip_top_left_regression(void) {
229220
* \ /
230221
* (-50,-60)
231222
*/
232-
TEST
233-
test_draw_circle_clip_outside(void) {
223+
TEST test_draw_circle_clip_outside(void) {
234224
hagl_draw_circle(&bitmap, -50, -50, 10, 0xFFFF);
235225

236226
ASSERT_EQ(0, count_pixels(&bitmap, 0xFFFF));
@@ -241,8 +231,7 @@ test_draw_circle_clip_outside(void) {
241231
* Circle clipped by a custom clip window:
242232
* Center at (15,15), radius 10, clip (10,10)-(25,25).
243233
*/
244-
TEST
245-
test_draw_circle_custom_clip(void) {
234+
TEST test_draw_circle_custom_clip(void) {
246235
hagl_set_clip(&bitmap, 10, 10, 25, 25);
247236
hagl_draw_circle(&bitmap, 15, 15, 10, 0xFFFF);
248237

@@ -267,8 +256,7 @@ test_draw_circle_custom_clip(void) {
267256
PASS();
268257
}
269258

270-
TEST
271-
test_draw_circle_custom_clip_regression(void) {
259+
TEST test_draw_circle_custom_clip_regression(void) {
272260
hagl_set_clip(&bitmap, 10, 10, 25, 25);
273261
hagl_draw_circle(&bitmap, 15, 15, 10, 0xFFFF);
274262

@@ -289,8 +277,7 @@ test_draw_circle_custom_clip_regression(void) {
289277
* \XXXXXXXX/
290278
* (100,110)
291279
*/
292-
TEST
293-
test_fill_circle(void) {
280+
TEST test_fill_circle(void) {
294281
hagl_fill_circle(&bitmap, 100, 100, 10, 0xFFFF);
295282

296283
/* On fill: cardinal points */
@@ -313,8 +300,7 @@ test_fill_circle(void) {
313300
PASS();
314301
}
315302

316-
TEST
317-
test_fill_circle_regression(void) {
303+
TEST test_fill_circle_regression(void) {
318304
hagl_fill_circle(&bitmap, 100, 100, 10, 0xFFFF);
319305

320306
uint32_t crc = crc32(bitmap.buffer, bitmap.size);
@@ -326,8 +312,7 @@ test_fill_circle_regression(void) {
326312
/*
327313
* Filled circle with radius 0:
328314
*/
329-
TEST
330-
test_fill_circle_radius_0(void) {
315+
TEST test_fill_circle_radius_0(void) {
331316
hagl_fill_circle(&bitmap, 50, 50, 0, 0xFFFF);
332317

333318
/* On fill: the center pixel */
@@ -349,8 +334,7 @@ test_fill_circle_radius_0(void) {
349334
* Filled circle with radius 1:
350335
* Should produce a filled cross with 5 pixels.
351336
*/
352-
TEST
353-
test_fill_circle_radius_1(void) {
337+
TEST test_fill_circle_radius_1(void) {
354338
hagl_fill_circle(&bitmap, 100, 100, 1, 0xFFFF);
355339

356340
/* On fill: cardinal neighbors */
@@ -374,8 +358,7 @@ test_fill_circle_radius_1(void) {
374358
PASS();
375359
}
376360

377-
TEST
378-
test_fill_circle_radius_1_regression(void) {
361+
TEST test_fill_circle_radius_1_regression(void) {
379362
hagl_fill_circle(&bitmap, 100, 100, 1, 0xFFFF);
380363

381364
uint32_t crc = crc32(bitmap.buffer, bitmap.size);
@@ -389,8 +372,7 @@ test_fill_circle_radius_1_regression(void) {
389372
* Center at (5,5), radius 10. Top and left portions are clipped.
390373
* Same dimensions as test_draw_circle_clip_top_left.
391374
*/
392-
TEST
393-
test_fill_circle_clip_top_left(void) {
375+
TEST test_fill_circle_clip_top_left(void) {
394376
hagl_fill_circle(&bitmap, 5, 5, 10, 0xFFFF);
395377

396378
/* On fill: visible cardinal points */
@@ -410,8 +392,7 @@ test_fill_circle_clip_top_left(void) {
410392
PASS();
411393
}
412394

413-
TEST
414-
test_fill_circle_clip_top_left_regression(void) {
395+
TEST test_fill_circle_clip_top_left_regression(void) {
415396
hagl_fill_circle(&bitmap, 5, 5, 10, 0xFFFF);
416397

417398
uint32_t crc = crc32(bitmap.buffer, bitmap.size);
@@ -424,8 +405,7 @@ test_fill_circle_clip_top_left_regression(void) {
424405
* Filled circle entirely outside the display:
425406
* Center at (-50,-50), radius 10. No pixels visible.
426407
*/
427-
TEST
428-
test_fill_circle_clip_outside(void) {
408+
TEST test_fill_circle_clip_outside(void) {
429409
hagl_fill_circle(&bitmap, -50, -50, 10, 0xFFFF);
430410

431411
ASSERT_EQ(0, count_pixels(&bitmap, 0xFFFF));
@@ -436,8 +416,7 @@ test_fill_circle_clip_outside(void) {
436416
* Filled circle clipped by a custom clip window:
437417
* Center at (15,15), radius 10, clip (10,10)-(25,25).
438418
*/
439-
TEST
440-
test_fill_circle_custom_clip(void) {
419+
TEST test_fill_circle_custom_clip(void) {
441420
hagl_set_clip(&bitmap, 10, 10, 25, 25);
442421
hagl_fill_circle(&bitmap, 15, 15, 10, 0xFFFF);
443422

@@ -468,8 +447,7 @@ test_fill_circle_custom_clip(void) {
468447
PASS();
469448
}
470449

471-
TEST
472-
test_fill_circle_custom_clip_regression(void) {
450+
TEST test_fill_circle_custom_clip_regression(void) {
473451
hagl_set_clip(&bitmap, 10, 10, 25, 25);
474452
hagl_fill_circle(&bitmap, 15, 15, 10, 0xFFFF);
475453

@@ -505,8 +483,7 @@ SUITE(circle_suite) {
505483

506484
GREATEST_MAIN_DEFS();
507485

508-
int
509-
main(int argc, char **argv) {
486+
int main(int argc, char **argv) {
510487
GREATEST_MAIN_BEGIN();
511488
RUN_SUITE(circle_suite);
512489
GREATEST_MAIN_END();

0 commit comments

Comments
 (0)