commit 56a34cab2c941537894a8d45e00a8a0c22102ba7 from: witcher date: Fri Jan 6 14:50:49 2023 UTC Add integration test for `types.rs` commit - bda18df0aafe22fad505453b2dcdbe9868c90a54 commit + 56a34cab2c941537894a8d45e00a8a0c22102ba7 blob - /dev/null blob + bb99f5509528e4e497358f9312df7a5e236d0c59 (mode 644) --- /dev/null +++ tests/types.rs @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2023 witcher + * + * SPDX-License-Identifier: CC0-1.0 + */ + +use chrono::NaiveDate; +use todotxt_parser::{Tag, Task}; + +const TASK_STR: &str = + "x (A) 2016-05-20 2016-04-30 measure space for +chapelShelving @chapel due:2016-05-30"; + +#[test] +fn test_task_try_from_str() { + let res = Task::try_from(TASK_STR).unwrap(); + assert_eq!( + res, + Task::new( + true, + 1, + Some(NaiveDate::from_ymd_opt(2016, 5, 20).unwrap()), + Some(NaiveDate::from_ymd_opt(2016, 4, 30).unwrap()), + "measure space for +chapelShelving @chapel due:2016-05-30", + vec![ + Tag::Project("chapelShelving"), + Tag::Context("chapel"), + Tag::Due(NaiveDate::from_ymd_opt(2016, 5, 30).unwrap()) + ] + ) + ); +}