Skip to content

Commit

Permalink
fix: period_union with empty args (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShootingKing-AM authored Mar 24, 2023
1 parent 86a4b10 commit 1f4f07d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion aw-transform/src/period_union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn period_union(events1: &[Event], events2: &[Event]) -> Vec<Event> {

let mut events_union = Vec::new();

if !events1.is_empty() {
if !sorted_events.is_empty() {
events_union.push(sorted_events.pop_front().unwrap())
}

Expand Down Expand Up @@ -110,4 +110,30 @@ mod tests {
let e_result = period_union(&[e1], &[e2]);
assert_eq!(e_result.len(), 2);
}

#[test]
fn test_period_union_2nd_empty() {
let e1 = Event {
id: None,
timestamp: DateTime::from_str("2000-01-01T00:00:01Z").unwrap(),
duration: Duration::seconds(1),
data: json_map! {"test": json!(1)},
};

let e_result = period_union(&[e1], &[]);
assert_eq!(e_result.len(), 1);
}

#[test]
fn test_period_union_1st_empty() {
let e1 = Event {
id: None,
timestamp: DateTime::from_str("2000-01-01T00:00:01Z").unwrap(),
duration: Duration::seconds(1),
data: json_map! {"test": json!(1)},
};

let e_result = period_union(&[], &[e1]);
assert_eq!(e_result.len(), 1);
}
}

0 comments on commit 1f4f07d

Please sign in to comment.