X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=test%2Fgps_test.rs;h=57c88991f5fcb6a7eb4c75900f3c75529b521d79;hb=8131a71527b5279bca9b80aac37596f6264ea2a1;hp=bed56a7371a1a91035b247c13c117dd25f1e8af7;hpb=6f2603fafd5b07040e0202cbb6808511f86c07c6;p=gps-watch.git diff --git a/test/gps_test.rs b/test/gps_test.rs index bed56a7..57c8899 100644 --- a/test/gps_test.rs +++ b/test/gps_test.rs @@ -21,8 +21,11 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use common::fixed15_49; use common::gps; +type Fixed = fixed15_49::Fixed15_49; + // Verifies that a single RMC message with position, date and time // does not suffice for getting a valid TimeAndPos result. #[test] @@ -82,6 +85,31 @@ $GPGGA,110338.000,1234.5678,N,12345.6789,E,\ assert_eq!(true, has_fix); assert_eq!(1477998218, tap.unix_time); - assert_eq!(tap.latitude, 7545678); - assert_eq!(tap.longitude, 74256789); + assert_eq!(7545678, tap.latitude_deg); + assert_eq!(74256789, tap.longitude_deg); + assert_eq!(0.21949487565883447, tap.latitude_rad.to_f32()); + assert_eq!(2.160042433347846, tap.longitude_rad.to_f32()); +} + +#[test] +fn distance_cm0() { + let tap0 = gps::TimeAndPos { + system_time: 0, + unix_time: 0, + latitude_deg: 0, + longitude_deg: 0, + latitude_rad: Fixed::from_f32(49.02541333).to_radians(), + longitude_rad: Fixed::from_f32(8.79440167).to_radians(), + }; + + let tap1 = gps::TimeAndPos { + system_time: 1, + unix_time: 1, + latitude_deg: 0, + longitude_deg: 0, + latitude_rad: Fixed::from_f32(49.02541000).to_radians(), + longitude_rad: Fixed::from_f32(8.79443667).to_radians(), + }; + + assert_eq!(349, tap1.distance_cm(&tap0)); }