-
Notifications
You must be signed in to change notification settings - Fork 227
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
1 parent
a720487
commit 49ef36d
Showing
5 changed files
with
60 additions
and
56 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
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
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 |
---|---|---|
@@ -1,3 +1,26 @@ | ||
use serde::{de::DeserializeOwned, Serialize}; | ||
use std::fmt::Debug; | ||
use std::{fs, path::PathBuf}; | ||
|
||
pub mod apalache; | ||
pub mod command; | ||
pub mod lite; | ||
|
||
/// Test that a struct `T` can be: | ||
/// | ||
/// - serialized to JSON | ||
/// - parsed back from the serialized JSON of the previous step | ||
/// - that the two parsed structs are equal according to their `PartialEq` impl | ||
pub fn test_serialization_roundtrip<T>(obj: &T) | ||
where | ||
T: Debug + PartialEq + Serialize + DeserializeOwned, | ||
{ | ||
let serialized = serde_json::to_string(obj).unwrap(); | ||
let parsed = serde_json::from_str(&serialized).unwrap(); | ||
assert_eq!(obj, &parsed); | ||
} | ||
|
||
/// Read a file into a string | ||
pub fn read_file(dir: &str, file: &str) -> String { | ||
fs::read_to_string(PathBuf::from(dir.to_owned() + file)).unwrap() | ||
} |