1mod datagps;
2
3#[cfg(test)]
4mod tests {
5 use crate::datagps::DataGPS;
6 use crate::datagps::Bauds;
7
8 #[test]
9 fn set_baud_uart_test() {
10 let mut data_gps = DataGPS::new(Bauds::Baud57600);
11 let new_baud = Bauds::Baud9600;
12 data_gps.set_baud_rate(&new_baud);
13 assert_eq!(data_gps.get_baud_rate(),new_baud.get_value());
14 }
15
16 #[test]
17 #[should_panic]
18 fn uart_enabled(){
19 let mut data_gps = DataGPS::new(Bauds::Baud57600);
20 loop{
21 data_gps.read_all_data();
22 }
23 }
24
25 #[test]
26 fn check_longitude(){
27 let mut data_gps = DataGPS::new(Bauds::Baud9600);
28
29 while data_gps.get_longitude().trim()=="No value"{
30 data_gps.read_all_data()
31 }
32 let length = data_gps.get_longitude().len();
33 let dir = data_gps.get_longitude().chars().nth(length-1).expect("Error").to_string();
34 let long = data_gps.get_longitude();
35 let x: Vec<&str> = long.split(".").collect();
36
37 assert_eq!(x[0].to_owned()+&dir,"02155W")
38 }
39}