From cc688c4dc73d3b13be5aba1bd292cc31265c5d04 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 6 Oct 2020 00:18:37 +0300 Subject: Allow days with no expenses Also fix "spelling" mistake in output ("..." instead of ".."). --- budget/tests/budget.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'budget/tests/budget.rs') diff --git a/budget/tests/budget.rs b/budget/tests/budget.rs index 32828f8..1cc02e7 100644 --- a/budget/tests/budget.rs +++ b/budget/tests/budget.rs @@ -82,6 +82,10 @@ fn can_parse_account() -> Result<(), ParseError>{ }, ], }, + Day { + date: NaiveDate::from_ymd(2020, 10, 3), + expenses: Vec::::new(), + }, ], }; @@ -95,32 +99,32 @@ fn can_parse_account() -> Result<(), ParseError>{ #[test] fn can_calculate() -> Result<(), ParseError> { let mut should_be = Calculated { - all_day_average: 11.355, - essential_day_average: 9.45, + all_day_average: 7.57, + essential_day_average: 6.3, categories_day_average: HashMap::::new(), essential_subtotal: 18.9, categories_subtotal: HashMap::::new(), total: 22.71, balance: 397.29, - days_left: 34.9881109643329, - days_left_essential: 42.041269841269845, + days_left: 52.48216644649934, + days_left_essential: 63.06190476190476, }; should_be.categories_day_average.insert( "supplies".to_string(), - 1.905, + 1.27, ); should_be.categories_day_average.insert( "products".to_string(), - 3.5, + 2.3333333333333335, ); should_be.categories_day_average.insert( "transport".to_string(), - 3.45, + 2.3000000000000003, ); should_be.categories_day_average.insert( "utilities".to_string(), - 2.5, + 1.6666666666666667, ); should_be.categories_subtotal.insert( -- cgit v1.2.3