Skip to content

Instantly share code, notes, and snippets.

@leonkunert
Created May 21, 2014 19:50
Show Gist options
  • Save leonkunert/1d07c9d2f5969e393435 to your computer and use it in GitHub Desktop.
Save leonkunert/1d07c9d2f5969e393435 to your computer and use it in GitHub Desktop.
fn calculate_return(cost :f64, given :f64) -> f64 {
return given - cost
}
#[test]
fn calculate_return_test(){
assert_eq!(calculate_return(13.23f64, 15.00f64), 1.77f64);
}
#[test]
fn calculate_return_test2(){
assert_eq!(calculate_return(132.23f64, 150.00f64), 17.77f64);
}
#[test]
fn calculate_return_test3(){
assert_eq!(calculate_return(1f64, 2f64), 1f64);
}
fn main() {
println!("{}",calculate_return(123.45, 130.00));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment