File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ #include " doctest.h"
2+ #include " util/parameter.hh"
3+
4+ TEST_CASE (" basic usage" ) {
5+
6+ //
7+ LatchedParam<float , 1 , 4096 > x;
8+ LatchedParam<float , 1 , 4096 > y;
9+
10+ x = 2 .4f ;
11+ CHECK (x.val == 2 .4f );
12+ CHECK (x.changed == false );
13+
14+ x.store_changed (10 .f );
15+ CHECK (x.val == 10 .f );
16+ CHECK (x.changed == true );
17+
18+ CHECK (y.val == 0 .f );
19+ CHECK (y.changed == false );
20+ y = x;
21+ CHECK (y.val == 10 .f );
22+ CHECK (y.changed == true );
23+
24+ CHECK (y.did_change ());
25+ CHECK_FALSE (y.did_change ());
26+ }
Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ struct LatchedParam {
3232 void operator =(T x) {
3333 val = x;
3434 }
35+
36+ LatchedParam &operator =(LatchedParam const &x) {
37+ val = x.val ;
38+ changed = x.changed ;
39+ return *this ;
40+ }
41+
3542 operator T () {
3643 return val;
3744 }
You can’t perform that action at this time.
0 commit comments