2 * Copyright (c) 2020 Tilman Sauerbeck (tilman at code-monkey de)
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 // Verifies that a single RMC message with position, date and time
27 // does not suffice for getting a valid TimeAndPos result.
29 fn process_rmc_only() {
31 $GPRMC,110338.000,,1234.5678,N,12345.6789,E,\
34 let mut input_iter = input.iter();
36 let mut tap = gps::TimeAndPos::new();
37 let mut gps = gps::Gps::new();
39 let has_fix = gps.update(&mut tap, || {
40 input_iter.next().and_then(|&b| Some(b))
43 assert_eq!(false, has_fix);
46 // Verifies that a single GGA message with position and time
47 // does not suffice for getting a valid TimeAndPos result.
49 fn process_gga_only() {
51 $GPGGA,110338.000,1234.5678,N,12345.6789,E,\
52 1,04,2.4,190.3,M,48.0,M,,0000*58";
53 let mut input_iter = input.iter();
55 let mut tap = gps::TimeAndPos::new();
56 let mut gps = gps::Gps::new();
58 let has_fix = gps.update(&mut tap, || {
59 input_iter.next().and_then(|&b| Some(b))
62 assert_eq!(false, has_fix);
65 // Verifies that a GGA message received after a RMC message
66 // does suffice for getting a valid TimeAndPos result.
68 fn process_rmc_and_gga() {
70 $GPRMC,110338.000,,1234.5678,N,12345.6789,E,\
72 $GPGGA,110338.000,1234.5678,N,12345.6789,E,\
73 1,04,2.4,190.3,M,48.0,M,,0000*58";
74 let mut input_iter = input.iter();
76 let mut tap = gps::TimeAndPos::new();
77 let mut gps = gps::Gps::new();
79 let has_fix = gps.update(&mut tap, || {
80 input_iter.next().and_then(|&b| Some(b))
83 assert_eq!(true, has_fix);
84 assert_eq!(1477998218, tap.unix_time);
85 assert_eq!(tap.latitude, 7545678);
86 assert_eq!(tap.longitude, 74256789);