diff options
| author | Edward Barnard | 2017-05-03 13:20:02 +0100 |
|---|---|---|
| committer | Edward Barnard | 2017-05-03 13:20:02 +0100 |
| commit | 29248dcf3e8e1798b09967583fffed95a8856380 (patch) | |
| tree | 09bcdf8a9154e1457f83ace3b3c24703bb40b7e8 /tests/serde_tests/mod.rs | |
| parent | 9ac3cd9e720ed9e412361c51c5611f24b1518402 (diff) | |
| download | rust-plist-0.2.0.tar.bz2 | |
Implement serialisation and deserialisation for the plist Date type.v0.2.0
Diffstat (limited to 'tests/serde_tests/mod.rs')
| -rw-r--r-- | tests/serde_tests/mod.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/serde_tests/mod.rs b/tests/serde_tests/mod.rs index e490a2c..ad5140a 100644 --- a/tests/serde_tests/mod.rs +++ b/tests/serde_tests/mod.rs @@ -1,4 +1,5 @@ -use plist::{EventWriter, PlistEvent, Result as PlistResult}; +use chrono::{TimeZone, UTC}; +use plist::{Date, EventWriter, PlistEvent, Result as PlistResult}; use plist::serde::{Serializer, Deserializer}; use plist::PlistEvent::*; use serde::de::DeserializeOwned; @@ -219,7 +220,7 @@ fn type_with_options() { c: None }; - let ty = TypeWithOptions { + let obj = TypeWithOptions { a: Some("hello".to_owned()), b: None, c: Some(Box::new(inner)) @@ -235,5 +236,30 @@ fn type_with_options() { EndDictionary, EndDictionary]; - assert_roundtrip(ty, Some(comparison)); + assert_roundtrip(obj, Some(comparison)); +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +struct TypeWithDate { + a: Option<i32>, + b: Option<Date> +} + +#[test] +fn type_with_date() { + let date: Date = UTC.ymd(1981, 05, 16).and_hms(11, 32, 06).into(); + + let obj = TypeWithDate { + a: Some(28), + b: Some(date.clone()), + }; + + let comparison = &[StartDictionary(None), + StringValue("a".to_owned()), + IntegerValue(28), + StringValue("b".to_owned()), + DateValue(date), + EndDictionary]; + + assert_roundtrip(obj, Some(comparison)); } |
