Files
radicle-git/test/test-helpers/src/roundtrip.rs
T
Fintan Halpenny 70b571b67b radicle-git init
Port over all git relevant parts of the radicle-link repository[0].
The packages that are kept are:
* git-ext
* git-ref-format
* git-trailers
* link-git
* macros
* std-ext
* test -- only the portions that test the above

The development and testing scripts are also added for local and CI
testing.

[0]: https://github.com/radicle-dev/radicle-link/
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-08 12:07:51 +01:00

37 lines
887 B
Rust

// Copyright © 2019-2020 The Radicle Foundation <hello@radicle.foundation>
//
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
// Linking Exception. For full terms see the included LICENSE file.
use std::{
fmt::{Debug, Display},
str::FromStr,
};
use pretty_assertions::assert_eq;
pub fn json<A>(a: A)
where
for<'de> A: Debug + PartialEq + serde::Serialize + serde::Deserialize<'de>,
{
assert_eq!(
a,
serde_json::from_str(&serde_json::to_string(&a).unwrap()).unwrap()
)
}
pub fn cbor<A>(a: A)
where
for<'de> A: Debug + PartialEq + minicbor::Encode + minicbor::Decode<'de>,
{
assert_eq!(a, minicbor::decode(&minicbor::to_vec(&a).unwrap()).unwrap())
}
pub fn str<A>(a: A)
where
A: Debug + PartialEq + Display + FromStr,
<A as FromStr>::Err: Debug,
{
assert_eq!(a, a.to_string().parse().unwrap())
}