Skip to content

Commit

Permalink
Merge pull request #2 from AeroRust/no_std-test-fixes
Browse files Browse the repository at this point in the history
functional_tests - improve readability and use vec & no_std attribute
  • Loading branch information
patrickoppel authored Jul 17, 2022
2 parents 3c46eb0 + 533f16e commit 3e904ef
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 187 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// limitations under the License.
//

// #![no_std]
#![cfg_attr(not(any(feature = "std", test)), no_std)]

mod parse;
mod sentences;
Expand Down
186 changes: 93 additions & 93 deletions tests/file_log_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use nmea::{parse, Nmea};

use crate::dump_satellites;
use crate::format_satellites;

#[test]
fn test_parse_file_log() {
Expand Down Expand Up @@ -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()));
}
}

Expand Down
Loading

0 comments on commit 3e904ef

Please sign in to comment.