Added more tests
This commit is contained in:
parent
77b732824b
commit
97c91a7e84
|
@ -14,11 +14,11 @@ pub fn locator_from_coordinates(lat: f32, long: f32) -> ArrayString<6> {
|
||||||
|
|
||||||
let false_north = if lat < 90.0 { lat + 90.0 } else { lat - 90.0 };
|
let false_north = if lat < 90.0 { lat + 90.0 } else { lat - 90.0 };
|
||||||
|
|
||||||
let long_field = ((false_east / 20.0) as usize);
|
let long_field = (false_east / 20.0) as usize;
|
||||||
let mut long_rest = false_east % 20.0;
|
let mut long_rest = false_east % 20.0;
|
||||||
target_buf.push(FIELD_SYMBOLS.chars().nth(long_field).unwrap());
|
target_buf.push(FIELD_SYMBOLS.chars().nth(long_field).unwrap());
|
||||||
|
|
||||||
let lat_field = ((false_north / 10.0) as usize);
|
let lat_field = (false_north / 10.0) as usize;
|
||||||
let mut lat_rest = false_north % 10.0;
|
let mut lat_rest = false_north % 10.0;
|
||||||
target_buf.push(FIELD_SYMBOLS.chars().nth(lat_field).unwrap());
|
target_buf.push(FIELD_SYMBOLS.chars().nth(lat_field).unwrap());
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,45 @@ mod tests {
|
||||||
use wspr_beacon::loc;
|
use wspr_beacon::loc;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn assert_true() {
|
fn test_locations() {
|
||||||
let res = loc::locator_from_coordinates(49.4395, 7.7635);
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(49.4395, 7.7635).as_str(),
|
||||||
|
"JN39vk"
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(res.as_str(), "JN39vk")
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(74.998306, 148.833363).as_str(),
|
||||||
|
"QQ44kx"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(64.701746, -18.640812).as_str(),
|
||||||
|
"IP04qq"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(19.251825, -81.541811).as_str(),
|
||||||
|
"EK99fg"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(-23.587708, 45.25882).as_str(),
|
||||||
|
"LG26pj"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(-77.566746, 167.875652).as_str(),
|
||||||
|
"RB32wk"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(-17.632622, -149.472404).as_str(),
|
||||||
|
"BH52gi"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
loc::locator_from_coordinates(-19.77516, -43.959542).as_str(),
|
||||||
|
"GH80af"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue