Skip to content

Commit 1e676f6

Browse files
author
Cruz Monrreal
authored
Merge pull request #7605 from 0xc0170/fix_astyle_tests
tests: astyle fix
2 parents 6561a7f + 5f39232 commit 1e676f6

File tree

110 files changed

+2984
-2049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2984
-2049
lines changed

TESTS/events/queue/main.cpp

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "utest.h"
2222

2323
#if !DEVICE_USTICKER
24-
#error [NOT_SUPPORTED] test not supported
24+
#error [NOT_SUPPORTED] test not supported
2525
#endif
2626

2727
using namespace utest::v1;
@@ -38,32 +38,38 @@ using namespace utest::v1;
3838
volatile bool touched = false;
3939

4040
// static functions
41-
void func5(int a0, int a1, int a2, int a3, int a4) {
41+
void func5(int a0, int a1, int a2, int a3, int a4)
42+
{
4243
touched = true;
4344
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3 | a4, 0x1f);
4445
}
4546

46-
void func4(int a0, int a1, int a2, int a3) {
47+
void func4(int a0, int a1, int a2, int a3)
48+
{
4749
touched = true;
48-
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3, 0xf);
50+
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3, 0xf);
4951
}
5052

51-
void func3(int a0, int a1, int a2) {
53+
void func3(int a0, int a1, int a2)
54+
{
5255
touched = true;
5356
TEST_ASSERT_EQUAL(a0 | a1 | a2, 0x7);
5457
}
5558

56-
void func2(int a0, int a1) {
59+
void func2(int a0, int a1)
60+
{
5761
touched = true;
5862
TEST_ASSERT_EQUAL(a0 | a1, 0x3);
5963
}
6064

61-
void func1(int a0) {
65+
void func1(int a0)
66+
{
6267
touched = true;
6368
TEST_ASSERT_EQUAL(a0, 0x1);
6469
}
6570

66-
void func0() {
71+
void func0()
72+
{
6773
touched = true;
6874
}
6975

@@ -95,40 +101,44 @@ SIMPLE_POSTS_TEST(1, 0x01)
95101
SIMPLE_POSTS_TEST(0)
96102

97103

98-
void time_func(Timer *t, int ms) {
104+
void time_func(Timer *t, int ms)
105+
{
99106
TEST_ASSERT_INT_WITHIN(DELTA(ms), ms, t->read_ms());
100107
t->reset();
101108
}
102109

103110
template <int N>
104-
void call_in_test() {
111+
void call_in_test()
112+
{
105113
Timer tickers[N];
106114

107115
EventQueue queue(TEST_EQUEUE_SIZE);
108116

109117
for (int i = 0; i < N; i++) {
110118
tickers[i].start();
111-
queue.call_in((i+1)*100, time_func, &tickers[i], (i+1)*100);
119+
queue.call_in((i + 1) * 100, time_func, &tickers[i], (i + 1) * 100);
112120
}
113121

114-
queue.dispatch(N*100);
122+
queue.dispatch(N * 100);
115123
}
116124

117125
template <int N>
118-
void call_every_test() {
126+
void call_every_test()
127+
{
119128
Timer tickers[N];
120129

121130
EventQueue queue(TEST_EQUEUE_SIZE);
122131

123132
for (int i = 0; i < N; i++) {
124133
tickers[i].start();
125-
queue.call_every((i+1)*100, time_func, &tickers[i], (i+1)*100);
134+
queue.call_every((i + 1) * 100, time_func, &tickers[i], (i + 1) * 100);
126135
}
127136

128-
queue.dispatch(N*100);
137+
queue.dispatch(N * 100);
129138
}
130139

131-
void allocate_failure_test() {
140+
void allocate_failure_test()
141+
{
132142
EventQueue queue(TEST_EQUEUE_SIZE);
133143
int id;
134144

@@ -139,12 +149,14 @@ void allocate_failure_test() {
139149
TEST_ASSERT(!id);
140150
}
141151

142-
void no() {
152+
void no()
153+
{
143154
TEST_ASSERT(false);
144155
}
145156

146157
template <int N>
147-
void cancel_test1() {
158+
void cancel_test1()
159+
{
148160
EventQueue queue(TEST_EQUEUE_SIZE);
149161

150162
int ids[N];
@@ -153,7 +165,7 @@ void cancel_test1() {
153165
ids[i] = queue.call_in(1000, no);
154166
}
155167

156-
for (int i = N-1; i >= 0; i--) {
168+
for (int i = N - 1; i >= 0; i--) {
157169
queue.cancel(ids[i]);
158170
}
159171

@@ -164,31 +176,38 @@ void cancel_test1() {
164176
// Testing the dynamic arguments to the event class
165177
unsigned counter = 0;
166178

167-
void count5(unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a5) {
179+
void count5(unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a5)
180+
{
168181
counter += a0 + a1 + a2 + a3 + a5;
169182
}
170183

171-
void count4(unsigned a0, unsigned a1, unsigned a2, unsigned a3) {
184+
void count4(unsigned a0, unsigned a1, unsigned a2, unsigned a3)
185+
{
172186
counter += a0 + a1 + a2 + a3;
173187
}
174188

175-
void count3(unsigned a0, unsigned a1, unsigned a2) {
189+
void count3(unsigned a0, unsigned a1, unsigned a2)
190+
{
176191
counter += a0 + a1 + a2;
177192
}
178193

179-
void count2(unsigned a0, unsigned a1) {
194+
void count2(unsigned a0, unsigned a1)
195+
{
180196
counter += a0 + a1;
181197
}
182198

183-
void count1(unsigned a0) {
199+
void count1(unsigned a0)
200+
{
184201
counter += a0;
185202
}
186203

187-
void count0() {
204+
void count0()
205+
{
188206
counter += 0;
189207
}
190208

191-
void event_class_test() {
209+
void event_class_test()
210+
{
192211
counter = 0;
193212
EventQueue queue(TEST_EQUEUE_SIZE);
194213

@@ -211,7 +230,8 @@ void event_class_test() {
211230
TEST_ASSERT_EQUAL(counter, 30);
212231
}
213232

214-
void event_class_helper_test() {
233+
void event_class_helper_test()
234+
{
215235
counter = 0;
216236
EventQueue queue(TEST_EQUEUE_SIZE);
217237

@@ -234,7 +254,8 @@ void event_class_helper_test() {
234254
TEST_ASSERT_EQUAL(counter, 15);
235255
}
236256

237-
void event_inference_test() {
257+
void event_inference_test()
258+
{
238259
counter = 0;
239260
EventQueue queue(TEST_EQUEUE_SIZE);
240261

@@ -259,23 +280,26 @@ void event_inference_test() {
259280

260281
int timeleft_events[2];
261282

262-
void check_time_left(EventQueue* queue, int index, int expected) {
283+
void check_time_left(EventQueue *queue, int index, int expected)
284+
{
263285
const int event_id = timeleft_events[index];
264286
TEST_ASSERT_INT_WITHIN(2, expected, queue->time_left(event_id));
265287
touched = true;
266288
}
267289

268-
void time_left(EventQueue* queue, int index) {
290+
void time_left(EventQueue *queue, int index)
291+
{
269292
const int event_id = timeleft_events[index];
270293
TEST_ASSERT_EQUAL(0, queue->time_left(event_id));
271294
}
272295

273-
void time_left_test() {
296+
void time_left_test()
297+
{
274298
EventQueue queue(TEST_EQUEUE_SIZE);
275299

276300
// Enque check events
277-
TEST_ASSERT(queue.call_in(50, check_time_left, &queue, 0, 100-50));
278-
TEST_ASSERT(queue.call_in(200, check_time_left, &queue, 1, 200-200));
301+
TEST_ASSERT(queue.call_in(50, check_time_left, &queue, 0, 100 - 50));
302+
TEST_ASSERT(queue.call_in(200, check_time_left, &queue, 1, 200 - 200));
279303

280304
// Enque events to be checked
281305
timeleft_events[0] = queue.call_in(100, time_left, &queue, 0);
@@ -299,7 +323,8 @@ void time_left_test() {
299323
}
300324

301325
// Test setup
302-
utest::v1::status_t test_setup(const size_t number_of_cases) {
326+
utest::v1::status_t test_setup(const size_t number_of_cases)
327+
{
303328
GREENTEA_SETUP(20, "default_auto");
304329
return verbose_test_setup_handler(number_of_cases);
305330
}
@@ -327,7 +352,8 @@ const Case cases[] = {
327352

328353
Specification specification(test_setup, cases);
329354

330-
int main() {
355+
int main()
356+
{
331357
return !Harness::run(specification);
332358
}
333359

TESTS/events/timing/main.cpp

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
using namespace utest::v1;
2626

2727
#if !DEVICE_USTICKER
28-
#error [NOT_SUPPORTED] test not supported
28+
#error [NOT_SUPPORTED] test not supported
2929
#endif
3030

3131
// Test delay
@@ -42,16 +42,18 @@ using namespace utest::v1;
4242
#endif
4343

4444
// Random number generation to skew timing values
45-
float gauss(float mu, float sigma) {
46-
float x = (float)rand() / ((float)RAND_MAX+1);
47-
float y = (float)rand() / ((float)RAND_MAX+1);
48-
float x2pi = x*2.0*M_PI;
49-
float g2rad = sqrt(-2.0 * log(1.0-y));
45+
float gauss(float mu, float sigma)
46+
{
47+
float x = (float)rand() / ((float)RAND_MAX + 1);
48+
float y = (float)rand() / ((float)RAND_MAX + 1);
49+
float x2pi = x * 2.0 * M_PI;
50+
float g2rad = sqrt(-2.0 * log(1.0 - y));
5051
float z = cos(x2pi) * g2rad;
51-
return mu + z*sigma;
52+
return mu + z * sigma;
5253
}
5354

54-
float chisq(float sigma) {
55+
float chisq(float sigma)
56+
{
5557
return pow(gauss(0, sqrt(sigma)), 2);
5658
}
5759

@@ -62,40 +64,43 @@ DigitalOut led(LED1);
6264
equeue_sema_t sema;
6365

6466
// Timer timing test
65-
void timer_timing_test() {
67+
void timer_timing_test()
68+
{
6669
timer.reset();
6770
timer.start();
6871
int prev = timer.read_us();
6972

70-
while (prev < TEST_EVENTS_TIMING_TIME*1000) {
73+
while (prev < TEST_EVENTS_TIMING_TIME * 1000) {
7174
int next = timer.read_us();
7275
if (next < prev) {
7376
printf("backwards drift %d -> %d (%08x -> %08x)\r\n",
74-
prev, next, prev, next);
77+
prev, next, prev, next);
7578
}
7679
TEST_ASSERT(next >= prev);
7780
prev = next;
7881
}
7982
}
8083

8184
// equeue tick timing test
82-
void tick_timing_test() {
85+
void tick_timing_test()
86+
{
8387
unsigned start = equeue_tick();
8488
int prev = 0;
8589

8690
while (prev < TEST_EVENTS_TIMING_TIME) {
8791
int next = equeue_tick() - start;
8892
if (next < prev) {
8993
printf("backwards drift %d -> %d (%08x -> %08x)\r\n",
90-
prev, next, prev, next);
94+
prev, next, prev, next);
9195
}
9296
TEST_ASSERT(next >= prev);
9397
prev = next;
9498
}
9599
}
96100

97101
// equeue semaphore timing test
98-
void semaphore_timing_test() {
102+
void semaphore_timing_test()
103+
{
99104
srand(0);
100105
timer.reset();
101106
timer.start();
@@ -124,8 +129,9 @@ void semaphore_timing_test() {
124129

125130

126131
// Test setup
127-
utest::v1::status_t test_setup(const size_t number_of_cases) {
128-
GREENTEA_SETUP((number_of_cases+1)*TEST_EVENTS_TIMING_TIME/1000, "default_auto");
132+
utest::v1::status_t test_setup(const size_t number_of_cases)
133+
{
134+
GREENTEA_SETUP((number_of_cases + 1)*TEST_EVENTS_TIMING_TIME / 1000, "default_auto");
129135
return verbose_test_setup_handler(number_of_cases);
130136
}
131137

@@ -137,7 +143,8 @@ const Case cases[] = {
137143

138144
Specification specification(test_setup, cases);
139145

140-
int main() {
146+
int main()
147+
{
141148
return !Harness::run(specification);
142149
}
143150

TESTS/integration/basic/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616
#include "test_env.h"
1717

18-
int main() {
18+
int main()
19+
{
1920
GREENTEA_SETUP(15, "default_auto");
2021
GREENTEA_TESTSUITE_RESULT(true);
2122
}

0 commit comments

Comments
 (0)