diff --git a/src/lib.rs b/src/lib.rs index 843c448..ef6c9a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ // limitations under the License. // -// #![no_std] +#![cfg_attr(not(any(feature = "std", test)), no_std)] mod parse; mod sentences; diff --git a/tests/file_log_parser/mod.rs b/tests/file_log_parser/mod.rs index 1b7b713..79f52c7 100644 --- a/tests/file_log_parser/mod.rs +++ b/tests/file_log_parser/mod.rs @@ -7,7 +7,7 @@ use std::{ use nmea::{parse, Nmea}; -use crate::dump_satellites; +use crate::format_satellites; #[test] fn test_parse_file_log() { @@ -88,100 +88,100 @@ fn test_parse_all_logs() { } let sat_state = match i { - 0 => { - "{Beidou 2 Some(11.0) Some(112.0) None}, \ - {Beidou 5 Some(28.0) Some(135.0) None}, \ - {Beidou 7 Some(22.0) Some(49.0) None}, \ - {Beidou 9 Some(2.0) Some(118.0) None}, \ - {Beidou 10 Some(36.0) Some(54.0) Some(18.0)}, \ - {Beidou 11 Some(20.0) Some(75.0) Some(18.0)}, \ - {Beidou 12 Some(5.0) Some(29.0) None}, \ - {Beidou 19 Some(0.0) Some(0.0) None}, \ - {Beidou 20 Some(37.0) Some(296.0) Some(30.0)}, \ - {Beidou 23 Some(66.0) Some(39.0) Some(17.0)}, \ - {Beidou 25 Some(19.0) Some(68.0) None}, \ - {Beidou 28 Some(3.0) Some(153.0) None}, \ - {Galileo 2 Some(56.0) Some(46.0) None}, \ - {Galileo 3 Some(11.0) Some(149.0) None}, \ - {Galileo 7 Some(54.0) Some(298.0) None}, \ - {Galileo 8 Some(60.0) Some(174.0) None}, \ - {Galileo 11 Some(1.0) Some(46.0) None}, \ - {Galileo 25 Some(8.0) Some(52.0) None}, \ - {Galileo 27 Some(11.0) Some(233.0) None}, \ - {Galileo 30 Some(66.0) Some(239.0) None}, \ - {Gps 5 Some(19.0) Some(222.0) Some(19.0)}, \ - {Gps 7 Some(5.0) Some(90.0) Some(18.0)}, \ - {Gps 13 Some(84.0) Some(239.0) Some(23.0)}, \ - {Gps 14 Some(56.0) Some(52.0) Some(16.0)}, \ - {Gps 15 Some(50.0) Some(296.0) Some(30.0)}, \ - {Gps 17 Some(35.0) Some(125.0) Some(24.0)}, \ - {Gps 19 Some(23.0) Some(147.0) None}, \ - {Gps 20 Some(3.0) Some(201.0) None}, \ - {Gps 23 Some(11.0) Some(319.0) Some(23.0)}, \ - {Gps 24 Some(16.0) Some(284.0) Some(25.0)}, \ - {Gps 28 Some(0.0) Some(0.0) Some(19.0)}, \ - {Gps 30 Some(28.0) Some(84.0) Some(20.0)}, \ - {Glonass 68 Some(39.0) Some(185.0) Some(28.0)}, \ - {Glonass 69 Some(63.0) Some(275.0) Some(34.0)}, \ - {Glonass 70 Some(14.0) Some(330.0) Some(22.0)}, \ - {Glonass 79 Some(61.0) Some(298.0) Some(36.0)}, \ - {Glonass 81 Some(0.0) Some(0.0) Some(17.0)}, \ - {Glonass 87 Some(14.0) Some(39.0) None}, \ - {Glonass 88 Some(15.0) Some(82.0) None}" - } - 1 => { - "{Gps 1 Some(9.0) Some(74.0) None}, \ - {Gps 8 Some(3.0) Some(29.0) Some(22.0)}, \ - {Gps 10 Some(4.0) Some(350.0) Some(18.0)}, \ - {Gps 11 Some(19.0) Some(59.0) Some(19.0)}, \ - {Gps 13 Some(59.0) Some(220.0) None}, \ - {Gps 15 Some(45.0) Some(281.0) None}, \ - {Gps 17 Some(36.0) Some(151.0) None}, \ - {Gps 18 Some(11.0) Some(323.0) None}, \ - {Gps 19 Some(17.0) Some(170.0) None}, \ - {Gps 20 Some(6.0) Some(258.0) None}, \ - {Gps 24 Some(13.0) Some(288.0) None}, \ - {Gps 28 Some(65.0) Some(71.0) None}, \ - {Gps 30 Some(35.0) Some(109.0) None}, \ - {Glonass 65 Some(24.0) Some(229.0) None}, \ - {Glonass 66 Some(38.0) Some(296.0) None}, \ - {Glonass 67 Some(11.0) Some(347.0) Some(18.0)}, \ - {Glonass 74 Some(35.0) Some(78.0) None}, \ - {Glonass 75 Some(76.0) Some(343.0) None}, \ - {Glonass 76 Some(29.0) Some(279.0) None}, \ - {Glonass 83 Some(13.0) Some(12.0) Some(10.0)}, \ - {Glonass 84 Some(41.0) Some(67.0) None}, \ - {Glonass 85 Some(26.0) Some(132.0) None}" - } - 2 => { - "{Gps 2 Some(35.0) Some(291.0) None}, \ - {Gps 3 Some(9.0) Some(129.0) None}, \ - {Gps 5 Some(14.0) Some(305.0) None}, \ - {Gps 6 Some(38.0) Some(226.0) None}, \ - {Gps 7 Some(56.0) Some(177.0) None}, \ - {Gps 9 Some(70.0) Some(67.0) None}, \ - {Gps 16 Some(20.0) Some(55.0) None}, \ - {Gps 23 Some(41.0) Some(76.0) None}, \ - {Gps 26 Some(10.0) Some(30.0) None}, \ - {Gps 29 Some(5.0) Some(341.0) None}, \ - {Gps 30 Some(26.0) Some(199.0) None}, \ - {Gps 36 Some(30.0) Some(158.0) None}, \ - {Gps 49 Some(32.0) Some(192.0) None}, \ - {Glonass 66 Some(45.0) Some(91.0) None}, \ - {Glonass 67 Some(67.0) Some(334.0) None}, \ - {Glonass 68 Some(17.0) Some(297.0) None}, \ - {Glonass 75 Some(13.0) Some(25.0) None}, \ - {Glonass 76 Some(49.0) Some(59.0) None}, \ - {Glonass 77 Some(40.0) Some(156.0) None}, \ - {Glonass 78 Some(0.0) Some(183.0) None}, \ - {Glonass 82 Some(15.0) Some(246.0) None}, \ - {Glonass 83 Some(28.0) Some(298.0) None}, \ - {Glonass 84 Some(10.0) Some(352.0) None}" - } + 0 => vec![ + "{Beidou 2 Some(11.0) Some(112.0) None}", + "{Beidou 5 Some(28.0) Some(135.0) None}", + "{Beidou 7 Some(22.0) Some(49.0) None}", + "{Beidou 9 Some(2.0) Some(118.0) None}", + "{Beidou 10 Some(36.0) Some(54.0) Some(18.0)}", + "{Beidou 11 Some(20.0) Some(75.0) Some(18.0)}", + "{Beidou 12 Some(5.0) Some(29.0) None}", + "{Beidou 19 Some(0.0) Some(0.0) None}", + "{Beidou 20 Some(37.0) Some(296.0) Some(30.0)}", + "{Beidou 23 Some(66.0) Some(39.0) Some(17.0)}", + "{Beidou 25 Some(19.0) Some(68.0) None}", + "{Beidou 28 Some(3.0) Some(153.0) None}", + "{Galileo 2 Some(56.0) Some(46.0) None}", + "{Galileo 3 Some(11.0) Some(149.0) None}", + "{Galileo 7 Some(54.0) Some(298.0) None}", + "{Galileo 8 Some(60.0) Some(174.0) None}", + "{Galileo 11 Some(1.0) Some(46.0) None}", + "{Galileo 25 Some(8.0) Some(52.0) None}", + "{Galileo 27 Some(11.0) Some(233.0) None}", + "{Galileo 30 Some(66.0) Some(239.0) None}", + "{Gps 5 Some(19.0) Some(222.0) Some(19.0)}", + "{Gps 7 Some(5.0) Some(90.0) Some(18.0)}", + "{Gps 13 Some(84.0) Some(239.0) Some(23.0)}", + "{Gps 14 Some(56.0) Some(52.0) Some(16.0)}", + "{Gps 15 Some(50.0) Some(296.0) Some(30.0)}", + "{Gps 17 Some(35.0) Some(125.0) Some(24.0)}", + "{Gps 19 Some(23.0) Some(147.0) None}", + "{Gps 20 Some(3.0) Some(201.0) None}", + "{Gps 23 Some(11.0) Some(319.0) Some(23.0)}", + "{Gps 24 Some(16.0) Some(284.0) Some(25.0)}", + "{Gps 28 Some(0.0) Some(0.0) Some(19.0)}", + "{Gps 30 Some(28.0) Some(84.0) Some(20.0)}", + "{Glonass 68 Some(39.0) Some(185.0) Some(28.0)}", + "{Glonass 69 Some(63.0) Some(275.0) Some(34.0)}", + "{Glonass 70 Some(14.0) Some(330.0) Some(22.0)}", + "{Glonass 79 Some(61.0) Some(298.0) Some(36.0)}", + "{Glonass 81 Some(0.0) Some(0.0) Some(17.0)}", + "{Glonass 87 Some(14.0) Some(39.0) None}", + "{Glonass 88 Some(15.0) Some(82.0) None}" + ], + 1 => vec![ + "{Gps 1 Some(9.0) Some(74.0) None}", + "{Gps 8 Some(3.0) Some(29.0) Some(22.0)}", + "{Gps 10 Some(4.0) Some(350.0) Some(18.0)}", + "{Gps 11 Some(19.0) Some(59.0) Some(19.0)}", + "{Gps 13 Some(59.0) Some(220.0) None}", + "{Gps 15 Some(45.0) Some(281.0) None}", + "{Gps 17 Some(36.0) Some(151.0) None}", + "{Gps 18 Some(11.0) Some(323.0) None}", + "{Gps 19 Some(17.0) Some(170.0) None}", + "{Gps 20 Some(6.0) Some(258.0) None}", + "{Gps 24 Some(13.0) Some(288.0) None}", + "{Gps 28 Some(65.0) Some(71.0) None}", + "{Gps 30 Some(35.0) Some(109.0) None}", + "{Glonass 65 Some(24.0) Some(229.0) None}", + "{Glonass 66 Some(38.0) Some(296.0) None}", + "{Glonass 67 Some(11.0) Some(347.0) Some(18.0)}", + "{Glonass 74 Some(35.0) Some(78.0) None}", + "{Glonass 75 Some(76.0) Some(343.0) None}", + "{Glonass 76 Some(29.0) Some(279.0) None}", + "{Glonass 83 Some(13.0) Some(12.0) Some(10.0)}", + "{Glonass 84 Some(41.0) Some(67.0) None}", + "{Glonass 85 Some(26.0) Some(132.0) None}" + ], + 2 => vec![ + "{Gps 2 Some(35.0) Some(291.0) None}", + "{Gps 3 Some(9.0) Some(129.0) None}", + "{Gps 5 Some(14.0) Some(305.0) None}", + "{Gps 6 Some(38.0) Some(226.0) None}", + "{Gps 7 Some(56.0) Some(177.0) None}", + "{Gps 9 Some(70.0) Some(67.0) None}", + "{Gps 16 Some(20.0) Some(55.0) None}", + "{Gps 23 Some(41.0) Some(76.0) None}", + "{Gps 26 Some(10.0) Some(30.0) None}", + "{Gps 29 Some(5.0) Some(341.0) None}", + "{Gps 30 Some(26.0) Some(199.0) None}", + "{Gps 36 Some(30.0) Some(158.0) None}", + "{Gps 49 Some(32.0) Some(192.0) None}", + "{Glonass 66 Some(45.0) Some(91.0) None}", + "{Glonass 67 Some(67.0) Some(334.0) None}", + "{Glonass 68 Some(17.0) Some(297.0) None}", + "{Glonass 75 Some(13.0) Some(25.0) None}", + "{Glonass 76 Some(49.0) Some(59.0) None}", + "{Glonass 77 Some(40.0) Some(156.0) None}", + "{Glonass 78 Some(0.0) Some(183.0) None}", + "{Glonass 82 Some(15.0) Some(246.0) None}", + "{Glonass 83 Some(28.0) Some(298.0) None}", + "{Glonass 84 Some(10.0) Some(352.0) None}" + ], _ => panic!("You need to add sat state for new log here"), }; - assert_eq!(sat_state, dump_satellites(nmea1.satellites())); - assert_eq!(sat_state, dump_satellites(nmea2.satellites())); + assert_eq!(sat_state, format_satellites(nmea1.satellites())); + assert_eq!(sat_state, format_satellites(nmea2.satellites())); } } diff --git a/tests/functional_tests.rs b/tests/functional_tests.rs index fe5cbf8..f9a336d 100644 --- a/tests/functional_tests.rs +++ b/tests/functional_tests.rs @@ -91,42 +91,48 @@ fn test_gsv() { nmea.parse("$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70") .unwrap(); pretty_assertions::assert_eq!( - "{Gps 5 Some(59.0) Some(290.0) Some(20.0)}, \ - {Gps 7 Some(61.0) Some(98.0) Some(15.0)}, \ - {Gps 8 Some(54.0) Some(157.0) Some(30.0)}, \ - {Gps 10 Some(63.0) Some(137.0) Some(17.0)}", - dump_satellites(nmea.satellites()) + vec![ + "{Gps 5 Some(59.0) Some(290.0) Some(20.0)}", + "{Gps 7 Some(61.0) Some(98.0) Some(15.0)}", + "{Gps 8 Some(54.0) Some(157.0) Some(30.0)}", + "{Gps 10 Some(63.0) Some(137.0) Some(17.0)}", + ], + format_satellites(nmea.satellites()) ); // 02 13 26 04 nmea.parse("$GPGSV,3,2,11,02,39,223,19,13,28,070,17,26,23,252,,04,14,186,14*79") .unwrap(); - pretty_assertions:: assert_eq!( - "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}, \ -{Gps 4 Some(14.0) Some(186.0) Some(14.0)}, \ -{Gps 5 Some(59.0) Some(290.0) Some(20.0)}, \ -{Gps 7 Some(61.0) Some(98.0) Some(15.0)}, \ -{Gps 8 Some(54.0) Some(157.0) Some(30.0)}, \ -{Gps 10 Some(63.0) Some(137.0) Some(17.0)}, \ -{Gps 13 Some(28.0) Some(70.0) Some(17.0)}, \ -{Gps 26 Some(23.0) Some(252.0) None}", - dump_satellites(nmea.satellites()) + pretty_assertions::assert_eq!( + vec![ + "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}", + "{Gps 4 Some(14.0) Some(186.0) Some(14.0)}", + "{Gps 5 Some(59.0) Some(290.0) Some(20.0)}", + "{Gps 7 Some(61.0) Some(98.0) Some(15.0)}", + "{Gps 8 Some(54.0) Some(157.0) Some(30.0)}", + "{Gps 10 Some(63.0) Some(137.0) Some(17.0)}", + "{Gps 13 Some(28.0) Some(70.0) Some(17.0)}", + "{Gps 26 Some(23.0) Some(252.0) None}", + ], + format_satellites(nmea.satellites()) ); // 29 16 36 nmea.parse("$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76") .unwrap(); - assert_eq!( - "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}, \ -{Gps 4 Some(14.0) Some(186.0) Some(14.0)}, \ -{Gps 5 Some(59.0) Some(290.0) Some(20.0)}, \ -{Gps 7 Some(61.0) Some(98.0) Some(15.0)}, \ -{Gps 8 Some(54.0) Some(157.0) Some(30.0)}, \ -{Gps 10 Some(63.0) Some(137.0) Some(17.0)}, \ -{Gps 13 Some(28.0) Some(70.0) Some(17.0)}, \ -{Gps 16 Some(9.0) Some(20.0) None}, \ -{Gps 26 Some(23.0) Some(252.0) None}, \ -{Gps 29 Some(9.0) Some(301.0) Some(24.0)}, \ -{Gps 36 None None None}", - dump_satellites(nmea.satellites()) + pretty_assertions::assert_eq!( + vec![ + "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}", + "{Gps 4 Some(14.0) Some(186.0) Some(14.0)}", + "{Gps 5 Some(59.0) Some(290.0) Some(20.0)}", + "{Gps 7 Some(61.0) Some(98.0) Some(15.0)}", + "{Gps 8 Some(54.0) Some(157.0) Some(30.0)}", + "{Gps 10 Some(63.0) Some(137.0) Some(17.0)}", + "{Gps 13 Some(28.0) Some(70.0) Some(17.0)}", + "{Gps 16 Some(9.0) Some(20.0) None}", + "{Gps 26 Some(23.0) Some(252.0) None}", + "{Gps 29 Some(9.0) Some(301.0) Some(24.0)}", + "{Gps 36 None None None}" + ], + format_satellites(nmea.satellites()) ); } @@ -134,43 +140,51 @@ fn test_gsv() { fn test_gsv_real_data() { let mut nmea = Nmea::default(); let real_data = [ + // GPS // 1 3 6 11 "$GPGSV,3,1,12,01,49,196,41,03,71,278,32,06,02,323,27,11,21,196,39*72", + // GPS + // 14 17 19 22 "$GPGSV,3,2,12,14,39,063,33,17,21,292,30,19,20,310,31,22,82,181,36*73", + // GPS + // 23 25 31 32 "$GPGSV,3,3,12,23,34,232,42,25,11,045,33,31,45,092,38,32,14,061,39*75", "$GLGSV,3,1,10,74,40,078,43,66,23,275,31,82,10,347,36,73,15,015,38*6B", "$GLGSV,3,2,10,75,19,135,36,65,76,333,31,88,32,233,33,81,40,302,38*6A", "$GLGSV,3,3,10,72,40,075,43,87,00,000,*6F", + // 26 31 32 "$GPGSV,4,4,15,26,02,112,,31,45,071,,32,01,066,*4C", ]; for line in &real_data { pretty_assertions::assert_eq!(nmea.parse(line).unwrap(), SentenceType::GSV); } pretty_assertions::assert_eq!( - "{Gps 1 Some(49.0) Some(196.0) Some(41.0)}, \ - {Gps 3 Some(71.0) Some(278.0) Some(32.0)}, \ - {Gps 6 Some(2.0) Some(323.0) Some(27.0)}, \ - {Gps 11 Some(21.0) Some(196.0) Some(39.0)}, \ - {Gps 14 Some(39.0) Some(63.0) Some(33.0)}, \ - {Gps 17 Some(21.0) Some(292.0) Some(30.0)}, \ - {Gps 19 Some(20.0) Some(310.0) Some(31.0)}, \ - {Gps 22 Some(82.0) Some(181.0) Some(36.0)}, \ - {Gps 23 Some(34.0) Some(232.0) Some(42.0)}, \ - {Gps 25 Some(11.0) Some(45.0) Some(33.0)}, \ - {Gps 26 Some(2.0) Some(112.0) None}, \ - {Gps 31 Some(45.0) Some(71.0) None}, \ - {Gps 32 Some(1.0) Some(66.0) None}, \ - {Glonass 65 Some(76.0) Some(333.0) Some(31.0)}, \ - {Glonass 66 Some(23.0) Some(275.0) Some(31.0)}, \ - {Glonass 72 Some(40.0) Some(75.0) Some(43.0)}, \ - {Glonass 73 Some(15.0) Some(15.0) Some(38.0)}, \ - {Glonass 74 Some(40.0) Some(78.0) Some(43.0)}, \ - {Glonass 75 Some(19.0) Some(135.0) Some(36.0)}, \ - {Glonass 81 Some(40.0) Some(302.0) Some(38.0)}, \ - {Glonass 82 Some(10.0) Some(347.0) Some(36.0)}, \ - {Glonass 87 Some(0.0) Some(0.0) None}, \ - {Glonass 88 Some(32.0) Some(233.0) Some(33.0)}", - dump_satellites(nmea.satellites()) + vec![ + "{Gps 1 Some(49.0) Some(196.0) Some(41.0)}", + "{Gps 3 Some(71.0) Some(278.0) Some(32.0)}", + "{Gps 6 Some(2.0) Some(323.0) Some(27.0)}", + "{Gps 11 Some(21.0) Some(196.0) Some(39.0)}", + "{Gps 14 Some(39.0) Some(63.0) Some(33.0)}", + "{Gps 17 Some(21.0) Some(292.0) Some(30.0)}", + "{Gps 19 Some(20.0) Some(310.0) Some(31.0)}", + "{Gps 22 Some(82.0) Some(181.0) Some(36.0)}", + "{Gps 23 Some(34.0) Some(232.0) Some(42.0)}", + "{Gps 25 Some(11.0) Some(45.0) Some(33.0)}", + "{Gps 26 Some(2.0) Some(112.0) None}", + "{Gps 31 Some(45.0) Some(71.0) None}", + "{Gps 32 Some(1.0) Some(66.0) None}", + "{Glonass 65 Some(76.0) Some(333.0) Some(31.0)}", + "{Glonass 66 Some(23.0) Some(275.0) Some(31.0)}", + "{Glonass 72 Some(40.0) Some(75.0) Some(43.0)}", + "{Glonass 73 Some(15.0) Some(15.0) Some(38.0)}", + "{Glonass 74 Some(40.0) Some(78.0) Some(43.0)}", + "{Glonass 75 Some(19.0) Some(135.0) Some(36.0)}", + "{Glonass 81 Some(40.0) Some(302.0) Some(38.0)}", + "{Glonass 82 Some(10.0) Some(347.0) Some(36.0)}", + "{Glonass 87 Some(0.0) Some(0.0) None}", + "{Glonass 88 Some(32.0) Some(233.0) Some(33.0)}", + ], + format_satellites(nmea.satellites()) ); } @@ -187,18 +201,20 @@ fn test_gsv_order() { nmea.parse("$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70") .unwrap(); assert_eq!( - "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}, \ - {Gps 4 Some(14.0) Some(186.0) Some(14.0)}, \ - {Gps 5 Some(59.0) Some(290.0) Some(20.0)}, \ - {Gps 7 Some(61.0) Some(98.0) Some(15.0)}, \ - {Gps 8 Some(54.0) Some(157.0) Some(30.0)}, \ - {Gps 10 Some(63.0) Some(137.0) Some(17.0)}, \ - {Gps 13 Some(28.0) Some(70.0) Some(17.0)}, \ - {Gps 16 Some(9.0) Some(20.0) None}, \ - {Gps 26 Some(23.0) Some(252.0) None}, \ - {Gps 29 Some(9.0) Some(301.0) Some(24.0)}, \ - {Gps 36 None None None}", - dump_satellites(nmea.satellites()) + vec![ + "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}", + "{Gps 4 Some(14.0) Some(186.0) Some(14.0)}", + "{Gps 5 Some(59.0) Some(290.0) Some(20.0)}", + "{Gps 7 Some(61.0) Some(98.0) Some(15.0)}", + "{Gps 8 Some(54.0) Some(157.0) Some(30.0)}", + "{Gps 10 Some(63.0) Some(137.0) Some(17.0)}", + "{Gps 13 Some(28.0) Some(70.0) Some(17.0)}", + "{Gps 16 Some(9.0) Some(20.0) None}", + "{Gps 26 Some(23.0) Some(252.0) None}", + "{Gps 29 Some(9.0) Some(301.0) Some(24.0)}", + "{Gps 36 None None None}", + ], + format_satellites(nmea.satellites()) ); } @@ -212,14 +228,16 @@ fn test_gsv_two_of_three() { nmea.parse("$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76") .unwrap(); assert_eq!( - "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}, \ - {Gps 4 Some(14.0) Some(186.0) Some(14.0)}, \ - {Gps 13 Some(28.0) Some(70.0) Some(17.0)}, \ - {Gps 16 Some(9.0) Some(20.0) None}, \ - {Gps 26 Some(23.0) Some(252.0) None}, \ - {Gps 29 Some(9.0) Some(301.0) Some(24.0)}, \ - {Gps 36 None None None}", - dump_satellites(nmea.satellites()) + vec![ + "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}", + "{Gps 4 Some(14.0) Some(186.0) Some(14.0)}", + "{Gps 13 Some(28.0) Some(70.0) Some(17.0)}", + "{Gps 16 Some(9.0) Some(20.0) None}", + "{Gps 26 Some(23.0) Some(252.0) None}", + "{Gps 29 Some(9.0) Some(301.0) Some(24.0)}", + "{Gps 36 None None None}", + ], + format_satellites(nmea.satellites()) ); } @@ -243,19 +261,21 @@ fn test_parse() { assert_eq!(nmea.latitude().unwrap(), 53. + 21.6802 / 60.); assert_eq!(nmea.longitude().unwrap(), -(6. + 30.3372 / 60.)); assert_eq!(nmea.altitude().unwrap(), 61.7); - assert_eq!( - "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}, \ - {Gps 4 Some(14.0) Some(186.0) Some(14.0)}, \ - {Gps 5 Some(59.0) Some(290.0) Some(20.0)}, \ - {Gps 7 Some(61.0) Some(98.0) Some(15.0)}, \ - {Gps 8 Some(54.0) Some(157.0) Some(30.0)}, \ - {Gps 10 Some(63.0) Some(137.0) Some(17.0)}, \ - {Gps 13 Some(28.0) Some(70.0) Some(17.0)}, \ - {Gps 16 Some(9.0) Some(20.0) None}, \ - {Gps 26 Some(23.0) Some(252.0) None}, \ - {Gps 29 Some(9.0) Some(301.0) Some(24.0)}, \ - {Gps 36 None None None}", - dump_satellites(nmea.satellites()) + pretty_assertions::assert_eq!( + vec![ + "{Gps 2 Some(39.0) Some(223.0) Some(19.0)}", + "{Gps 4 Some(14.0) Some(186.0) Some(14.0)}", + "{Gps 5 Some(59.0) Some(290.0) Some(20.0)}", + "{Gps 7 Some(61.0) Some(98.0) Some(15.0)}", + "{Gps 8 Some(54.0) Some(157.0) Some(30.0)}", + "{Gps 10 Some(63.0) Some(137.0) Some(17.0)}", + "{Gps 13 Some(28.0) Some(70.0) Some(17.0)}", + "{Gps 16 Some(9.0) Some(20.0) None}", + "{Gps 26 Some(23.0) Some(252.0) None}", + "{Gps 29 Some(9.0) Some(301.0) Some(24.0)}", + "{Gps 36 None None None}", + ], + format_satellites(nmea.satellites()) ); } @@ -450,13 +470,12 @@ fn test_gll() { assert_eq!(44, nmea.fix_timestamp().unwrap().second()); } -// ensure right order before dump to string -fn dump_satellites(mut sats: Vec) -> String { +/// ensure right order before dump to string +fn format_satellites(mut sats: Vec) -> std::vec::Vec { sats.sort_by_key(|s| (s.gnss_type() as u8, s.prn())); // to not depend on Debug impl for `Satellite` stability - let satellites_strings = sats - .iter() + sats.iter() .map(|s| { format!( "{{{gnss_type:?} {prn} {elevation:?} {azimuth:?} {snr:?}}}", @@ -467,7 +486,5 @@ fn dump_satellites(mut sats: Vec) -> String { snr = s.snr(), ) }) - .collect::>(); - - satellites_strings.join(", ") -} + .collect::>() +} \ No newline at end of file