Skip to content

Instantly share code, notes, and snippets.

@leonkunert
Created May 21, 2014 19:50
Show Gist options
  • Select an option

  • Save leonkunert/1d07c9d2f5969e393435 to your computer and use it in GitHub Desktop.

Select an option

Save leonkunert/1d07c9d2f5969e393435 to your computer and use it in GitHub Desktop.

Revisions

  1. leonkunert created this gist May 21, 2014.
    23 changes: 23 additions & 0 deletions calculate_return.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@

    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));
    }