-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#[cfg(test)] | ||
#[cfg(feature = "derive")] | ||
pub mod with_derive { | ||
use dipa::{DiffPatch, Diffable, Patchable}; | ||
use quickcheck::quickcheck; | ||
use quickcheck_derive::Arbitrary; | ||
use serde_derive::{Deserialize, Serialize}; | ||
use bincode::Options; | ||
use std::collections::BTreeMap; | ||
|
||
#[derive(Clone, Eq, PartialEq, PartialOrd, Ord, Debug, DiffPatch, Serialize, Deserialize, Arbitrary)] | ||
pub struct Basic { | ||
pub items: BTreeMap<u16, Vec<u8>>, | ||
} | ||
|
||
fn tester(mut a: Basic, b: Basic) -> bool { | ||
let bin = bincode::options().with_varint_encoding(); | ||
let created = a.create_delta_towards(&b); | ||
|
||
let serialized = bin.serialize(&created.delta).unwrap(); | ||
let deserialized: <Basic as dipa::Diffable<'_, '_, Basic>>::DeltaOwned = | ||
bin.deserialize(&serialized).unwrap(); | ||
|
||
a.apply_patch(deserialized); | ||
return a == b; | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
quickcheck(tester as fn(Basic, Basic) -> bool); | ||
} | ||
} |