summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-11-01 22:56:06 +0100
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-11-01 22:56:06 +0100
commitd28241cf589d2773bd3e28e05ca173c58561e913 (patch)
tree22acc45fa0de1aa100da69463d508d0c39d16bab /src
parent220c27fc152d8ad533e5450af2157b1061a47332 (diff)
downloadrust_rrule-d28241cf589d2773bd3e28e05ca173c58561e913.zip
docs + more tests
Diffstat (limited to 'src')
-rw-r--r--src/iter/poslist.rs3
-rw-r--r--src/lib.rs4
-rw-r--r--src/utils.rs22
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<Tz> 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<Tz> 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<T>(v: &Option<Vec<T>>) -> 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