From d28241cf589d2773bd3e28e05ca173c58561e913 Mon Sep 17 00:00:00 2001 From: Fredrik Meringdal Date: Sun, 1 Nov 2020 22:56:06 +0100 Subject: docs + more tests --- src/utils.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index ef09d54..161e6c2 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -13,3 +13,25 @@ pub fn is_some_and_not_empty(v: &Option>) -> bool { None => false, } } + + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn python_mod(){ + assert_eq!(pymod(2, -3), -1); + assert_eq!(pymod(-2, 3), 1); + assert_eq!(pymod(-2, -3), -2); + assert_eq!(pymod(-3, -3), 0); + assert_eq!(pymod(3, 3), 0); + assert_eq!(pymod(2, 3), 2); + assert_eq!(pymod(4, 3), 1); + assert_eq!(pymod(3, 3), 0); + assert_eq!(pymod(6, 3), 0); + assert_eq!(pymod(-6, 3), 0); + assert_eq!(pymod(-6, -3), 0); + assert_eq!(pymod(6, -3), 0); + } +} \ No newline at end of file -- cgit v1.2.3