dials_test.cpp¶
file tests/app/dials_test.cpp · Test suite
Tests of the dashboard dials nmeasim::app::CompassDial and nmeasim::app::WindDial.
Source tests/app/dials_test.cpp
Covers the relative-angle helpers nmeasim::app::signed_relative_angle and nmeasim::app::format_wind_angle, how nmeasim::app::DashboardWidget passes a vessel state to both dials and writes the apparent wind on its tile in the same form, the override controls of the rudder (its limit, and staying disabled outside steering mode), and that the dials paint their face in the night and the daylight theme on the offscreen platform. The file reads no fixtures.
Test cases¶
4 test cases, in source order.
| Test case | Tags |
|---|---|
| relative angles fold to port and starboard | [app][dials] |
| the dashboard feeds the compass and the wind dial | [app][dials] |
| the dials paint in both themes | [app][dials] |
| the rudder control keeps to its limit and stays disabled outside steering mode | [app][dials] |
Summary¶
File-local functions
| Name | Description |
|---|---|
format_wind_angle() |
Formats a wind angle relative to the bow as sailors say it: 104°P, 30°S, 0° ahead or 180° astern. |
signed_relative_angle() |
Folds an angle relative to the bow into (-180, 180], negative to port. |
File-local functions¶
format_wind_angle()¶
QString format_wind_angle(double relative_deg)
Formats a wind angle relative to the bow as sailors say it: 104°P, 30°S, 0° ahead or 180° astern.
The angle is folded with signed_relative_angle and rounded to whole degrees; the side letter is P for port and S for starboard, and is left out when the rounded angle is 0 or 180. For example 255.8 gives 104°P and 359.6 gives 0°.
Parameters
| Name | Type | Description |
|---|---|---|
relative_deg |
double |
Angle clockwise from the bow, in degrees; any finite value. |
Returns QString: The rounded magnitude with a degree sign and, off the centreline, the side letter.
Declared in tests/app/dials_test.cpp:29 · defined in src/app/widgets/dials.cpp:61
signed_relative_angle()¶
double signed_relative_angle(double relative_deg) noexcept
Folds an angle relative to the bow into (-180, 180], negative to port.
Parameters
| Name | Type | Description |
|---|---|---|
relative_deg |
double |
Angle clockwise from the bow, in degrees; any finite value, including negative values and values of 360 or more. |
Returns double: The same direction in (-180, 180]: 0 dead ahead, positive to starboard, negative to port, 180 dead astern.
Declared in tests/app/dials_test.cpp:30 · defined in src/app/widgets/dials.cpp:51