@@ -34,16 +34,20 @@ TEST_CASE("basic interpolation") {
3434 auto output_fn = [&](unsigned , float v) { out = v; };
3535 auto read_fn = [](unsigned ) { return 8 .f ; };
3636
37- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
37+ arr.add_new_readings (read_fn);
38+ arr.get_interp_values (output_fn);
3839 CHECK (out == doctest::Approx (2 .f ));
3940
40- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
41+ arr.add_new_readings (read_fn);
42+ arr.get_interp_values (output_fn);
4143 CHECK (out == doctest::Approx (4 .f ));
4244
43- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
45+ arr.add_new_readings (read_fn);
46+ arr.get_interp_values (output_fn);
4447 CHECK (out == doctest::Approx (6 .f ));
4548
46- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
49+ arr.add_new_readings (read_fn);
50+ arr.get_interp_values (output_fn);
4751 CHECK (out == 8 .f ); // snap: exact match, no floating-point accumulation
4852}
4953
@@ -88,25 +92,31 @@ TEST_CASE("multi channel interpolates independently") {
8892 arr.mark_new_data_ready ();
8993 float out0 = 0 .f , out1 = 0 .f ;
9094 auto output_fn = [&](unsigned i, float v) {
91- if (i == 0 ) out0 = v;
92- else out1 = v;
95+ if (i == 0 )
96+ out0 = v;
97+ else
98+ out1 = v;
9399 };
94100 // ch0 target=4 (step=1), ch1 target=8 (step=2)
95101 auto read_fn = [](unsigned i) { return i == 0 ? 4 .f : 8 .f ; };
96102
97- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
103+ arr.add_new_readings (read_fn);
104+ arr.get_interp_values (output_fn);
98105 CHECK (out0 == doctest::Approx (1 .f ));
99106 CHECK (out1 == doctest::Approx (2 .f ));
100107
101- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
108+ arr.add_new_readings (read_fn);
109+ arr.get_interp_values (output_fn);
102110 CHECK (out0 == doctest::Approx (2 .f ));
103111 CHECK (out1 == doctest::Approx (4 .f ));
104112
105- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
113+ arr.add_new_readings (read_fn);
114+ arr.get_interp_values (output_fn);
106115 CHECK (out0 == doctest::Approx (3 .f ));
107116 CHECK (out1 == doctest::Approx (6 .f ));
108117
109- arr.add_new_readings (read_fn); arr.get_interp_values (output_fn);
118+ arr.add_new_readings (read_fn);
119+ arr.get_interp_values (output_fn);
110120 CHECK (out0 == 4 .f ); // snap
111121 CHECK (out1 == 8 .f ); // snap
112122}
@@ -124,7 +134,7 @@ TEST_CASE("adapts num updates to measured period") {
124134 // --- Cycle 1: ISR fires, target=8, num_updates=4 ---
125135 arr.mark_new_data_ready ();
126136 arr.add_new_readings ([](unsigned ) { return 8 .f ; }); // count=0 -> skip set_num_updates
127- arr.get_interp_values (output_fn); // count=1, step=8/4=2, out=2
137+ arr.get_interp_values (output_fn); // count=1, step=8/4=2, out=2
128138 CHECK (out == doctest::Approx (2 .f ));
129139 arr.add_new_readings ([](unsigned ) { return 8 .f ; });
130140 arr.get_interp_values (output_fn); // count=2, out=4
@@ -134,17 +144,17 @@ TEST_CASE("adapts num updates to measured period") {
134144 // --- Cycle 2: ISR fires, target=16, immediately adapted ---
135145 arr.mark_new_data_ready ();
136146 arr.add_new_readings ([](unsigned ) { return 16 .f ; }); // count=2 -> set_num_updates(2), step=(16-4)/2=6
137- arr.get_interp_values (output_fn); // count=1, out=4+6=10
138- CHECK (out == doctest::Approx (10 .f )); // correctly at the midpoint
147+ arr.get_interp_values (output_fn); // count=1, out=4+6=10
148+ CHECK (out == doctest::Approx (10 .f )); // correctly at the midpoint
139149 arr.add_new_readings ([](unsigned ) { return 16 .f ; });
140150 arr.get_interp_values (output_fn); // count=2 >= num_updates=2: snap=16
141151 CHECK (out == 16 .f );
142152
143153 // --- Cycle 3: ISR fires, target=0 ---
144154 arr.mark_new_data_ready ();
145155 arr.add_new_readings ([](unsigned ) { return 0 .f ; }); // count=2 -> set_num_updates(2), step=(0-16)/2=-8
146- arr.get_interp_values (output_fn); // count=1, out=16-8=8
147- CHECK (out == doctest::Approx (8 .f )); // correctly at the midpoint
156+ arr.get_interp_values (output_fn); // count=1, out=16-8=8
157+ CHECK (out == doctest::Approx (8 .f )); // correctly at the midpoint
148158 arr.add_new_readings ([](unsigned ) { return 0 .f ; });
149159 arr.get_interp_values (output_fn); // count=2 >= num_updates=2: snap=0
150160 CHECK (out == 0 .f );
@@ -159,9 +169,12 @@ TEST_CASE("mark multiple times is processed once") {
159169 int call_count = 0 ;
160170 float out = 0 .f ;
161171 arr.add_new_readings ([](unsigned ) { return 8 .f ; });
162- arr.get_interp_values ([&](unsigned , float v) { out = v; call_count++; });
172+ arr.get_interp_values ([&](unsigned , float v) {
173+ out = v;
174+ call_count++;
175+ });
163176
164- CHECK (call_count == 1 ); // output_fn called exactly once (1 channel)
177+ CHECK (call_count == 1 ); // output_fn called exactly once (1 channel)
165178 CHECK (out == doctest::Approx (2 .f )); // normal step, not doubled
166179}
167180
@@ -172,7 +185,10 @@ TEST_CASE("second mark before add uses latest reading") {
172185 arr.set_num_updates (4 );
173186 float out = 0 .f ;
174187 int call_count = 0 ;
175- auto output_fn = [&](unsigned , float v) { out = v; call_count++; };
188+ auto output_fn = [&](unsigned , float v) {
189+ out = v;
190+ call_count++;
191+ };
176192
177193 arr.mark_new_data_ready ();
178194 arr.add_new_readings ([](unsigned ) { return 4 .f ; });
@@ -187,7 +203,7 @@ TEST_CASE("second mark before add uses latest reading") {
187203 arr.add_new_readings ([](unsigned ) { return 8 .f ; });
188204 arr.get_interp_values (output_fn);
189205 CHECK (call_count == 1 ); // flag processed exactly once (1 channel, 1 call)
190- CHECK (out == 8 .f ); // snapped to 8.f (num_updates adapted to 1)
206+ CHECK (out == 8 .f ); // snapped to 8.f (num_updates adapted to 1)
191207}
192208
193209TEST_CASE (" size returns N" ) {
@@ -198,19 +214,22 @@ TEST_CASE("size returns N") {
198214
199215TEST_CASE (" filter concept is enforced" ) {
200216 struct ValidFilter {
201- float add_val (float v) { return v; }
217+ float add_val (float v) {
218+ return v;
219+ }
202220 };
203221 struct NoAddVal {
204- float process (float v) { return v; } // wrong method name
222+ float process (float v) {
223+ return v;
224+ } // wrong method name
205225 };
206226 struct WrongReturnType {
207- void add_val (float ) {} // void is not convertible to float
227+ void add_val (float ) {
228+ } // void is not convertible to float
208229 };
209230
210231 // Test the requires expression directly (same constraint as on the class template)
211- auto satisfies = []<typename F>() {
212- return IsSimpleFilter<F, float >;
213- };
232+ auto satisfies = []<typename F>() { return IsSimpleFilter<F, float >; };
214233 static_assert (satisfies.template operator ()<ValidFilter>());
215234 static_assert (!satisfies.template operator ()<NoAddVal>());
216235 static_assert (!satisfies.template operator ()<WrongReturnType>());
0 commit comments