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/iter/poslist.rs | 3 +-- src/lib.rs | 4 ++-- src/utils.rs | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/iter/poslist.rs b/src/iter/poslist.rs index 635c1d3..8e468aa 100644 --- a/src/iter/poslist.rs +++ b/src/iter/poslist.rs @@ -51,8 +51,7 @@ pub fn build_poslist( timeset[timepos as usize].minute as u32, timeset[timepos as usize].second as u32, ); - // XXX: can this ever be in the array? - // - compare the actual date instead? + if !poslist.iter().any(|&p| p == res) { poslist.push(res); } diff --git a/src/lib.rs b/src/lib.rs index 00e6805..806b942 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ //! properties are represented by the `RRule` type and the rdate and exdate properties are represented by the DateTime type //! provided by the [chrono](https://crates.io/crates/chrono) and [chrono-tz](https://crates.io/crates/chrono-tz) crates. //! -//! # Building RRule and RRuleSet types +//! # Building RRule and RRuleSet //! Both of the types implements the `std::str::FromStr` trait so that they can be parsed and built from a `str`. `RRule` //! can additionally be constructured from the `Option` type which help build the recurrence rule. `RRuleSet` //! can also be built by composing mutliple `RRule`s for its rrule and exrule properties and DateTime for its @@ -78,7 +78,7 @@ //! Construct RRuleSet from one rrule and exrule. //! The rrule will occur weekly on Tuesday and Wednesday and the exrule //! will occur weekly on Wednesday, and therefore the end result will contain -//! weekly recurrences just on Wednesday. +//! weekly recurrences on Wednesday only. //! ``` //! extern crate rrule; //! extern crate chrono; 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