-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
7 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![cfg(feature = "decode")] | ||
|
||
use mrf_manifest::{Manifest, SECTION_NAME}; | ||
|
||
const MANIFEST: &str = include_str!("test-manifest.json"); | ||
|
||
#[test] | ||
fn decode_works() { | ||
let manifest: Manifest<'_> = serde_json::from_str(MANIFEST).unwrap(); | ||
// Calling `serde_json::to_string` on a string will encode it into its JSON representation | ||
// which is a fully escaped representation of the string | ||
let escaped_manifest = serde_json::to_string(&MANIFEST).unwrap(); | ||
|
||
let wat_src = format!(r#"( module ( @custom "{SECTION_NAME}" {escaped_manifest} ) )"#); | ||
let wasm_blob = wat::parse_str(wat_src).unwrap(); | ||
|
||
let (parsed_manifest, section_range) = mrf_manifest::decode(&wasm_blob).unwrap().unwrap(); | ||
assert_eq!(manifest, parsed_manifest); | ||
assert_eq!(section_range, 8..245); | ||
} |
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,12 @@ | ||
{ | ||
"manifestVersion": "v1", | ||
"apiVersion": "v1", | ||
"name": "test-manifest", | ||
"version": "0.0.1-cattywampus", | ||
"activityTypes": [ | ||
"Announce", | ||
"Create", | ||
"Delete", | ||
"Like" | ||
] | ||
} |
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