-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add v3-preview module gathering a few breaking changes
This new module addresses the following breaking changes of #72: - `static` instead of `const` for pre-defined encodings - Private `Encoding` implementation with `unsafe` constructor - Use `MaybeUninit` internally and expose `_uninit` functions - Use static dispatch instead of dynamic dispatch (fixing #97)
- Loading branch information
Showing
11 changed files
with
1,556 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ rustdoc-args = ["--cfg=docsrs"] | |
default = ["std"] | ||
alloc = [] | ||
std = ["alloc"] | ||
v3-preview = [] |
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,5 +1,3 @@ | ||
extern crate data_encoding_fuzz; | ||
|
||
use std::io::Read; | ||
|
||
use data_encoding_fuzz::generate_specification; | ||
|
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,98 @@ | ||
#![no_main] | ||
|
||
use data_encoding::v3_preview::{Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Encoding, False, True}; | ||
use data_encoding_fuzz::{decode_prefix, generate_encoding}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let mut data = data; | ||
let dyn_base = generate_encoding(&mut data); | ||
let mut count = 0; | ||
macro_rules! test { | ||
($Bit:ident, $Msb:ident, $Pad:ident, $Wrap:ident, $Ignore:ident) => { | ||
if let Ok(base) = <&Encoding<$Bit, $Msb, $Pad, $Wrap, $Ignore>>::try_from(&dyn_base) { | ||
count += 1; | ||
let encoded = base.encode(data); | ||
assert_eq!(encoded, dyn_base.encode(data)); | ||
assert_eq!(base.decode(encoded.as_bytes()).unwrap(), data); | ||
if dyn_base.is_canonical() { | ||
let raw = decode_prefix(&dyn_base, &mut data); | ||
assert_eq!(base.encode(&raw).as_bytes(), data); | ||
} | ||
} | ||
}; | ||
} | ||
test!(Bit1, False, False, False, False); | ||
test!(Bit1, False, False, False, True); | ||
test!(Bit1, False, False, True, True); | ||
test!(Bit1, False, True, False, False); | ||
test!(Bit1, False, True, False, True); | ||
test!(Bit1, False, True, True, True); | ||
test!(Bit1, True, False, False, False); | ||
test!(Bit1, True, False, False, True); | ||
test!(Bit1, True, False, True, True); | ||
test!(Bit1, True, True, False, False); | ||
test!(Bit1, True, True, False, True); | ||
test!(Bit1, True, True, True, True); | ||
test!(Bit2, False, False, False, False); | ||
test!(Bit2, False, False, False, True); | ||
test!(Bit2, False, False, True, True); | ||
test!(Bit2, False, True, False, False); | ||
test!(Bit2, False, True, False, True); | ||
test!(Bit2, False, True, True, True); | ||
test!(Bit2, True, False, False, False); | ||
test!(Bit2, True, False, False, True); | ||
test!(Bit2, True, False, True, True); | ||
test!(Bit2, True, True, False, False); | ||
test!(Bit2, True, True, False, True); | ||
test!(Bit2, True, True, True, True); | ||
test!(Bit3, False, False, False, False); | ||
test!(Bit3, False, False, False, True); | ||
test!(Bit3, False, False, True, True); | ||
test!(Bit3, False, True, False, False); | ||
test!(Bit3, False, True, False, True); | ||
test!(Bit3, False, True, True, True); | ||
test!(Bit3, True, False, False, False); | ||
test!(Bit3, True, False, False, True); | ||
test!(Bit3, True, False, True, True); | ||
test!(Bit3, True, True, False, False); | ||
test!(Bit3, True, True, False, True); | ||
test!(Bit3, True, True, True, True); | ||
test!(Bit4, False, False, False, False); | ||
test!(Bit4, False, False, False, True); | ||
test!(Bit4, False, False, True, True); | ||
test!(Bit4, False, True, False, False); | ||
test!(Bit4, False, True, False, True); | ||
test!(Bit4, False, True, True, True); | ||
test!(Bit4, True, False, False, False); | ||
test!(Bit4, True, False, False, True); | ||
test!(Bit4, True, False, True, True); | ||
test!(Bit4, True, True, False, False); | ||
test!(Bit4, True, True, False, True); | ||
test!(Bit4, True, True, True, True); | ||
test!(Bit5, False, False, False, False); | ||
test!(Bit5, False, False, False, True); | ||
test!(Bit5, False, False, True, True); | ||
test!(Bit5, False, True, False, False); | ||
test!(Bit5, False, True, False, True); | ||
test!(Bit5, False, True, True, True); | ||
test!(Bit5, True, False, False, False); | ||
test!(Bit5, True, False, False, True); | ||
test!(Bit5, True, False, True, True); | ||
test!(Bit5, True, True, False, False); | ||
test!(Bit5, True, True, False, True); | ||
test!(Bit5, True, True, True, True); | ||
test!(Bit6, False, False, False, False); | ||
test!(Bit6, False, False, False, True); | ||
test!(Bit6, False, False, True, True); | ||
test!(Bit6, False, True, False, False); | ||
test!(Bit6, False, True, False, True); | ||
test!(Bit6, False, True, True, True); | ||
test!(Bit6, True, False, False, False); | ||
test!(Bit6, True, False, False, True); | ||
test!(Bit6, True, False, True, True); | ||
test!(Bit6, True, True, False, False); | ||
test!(Bit6, True, True, False, True); | ||
test!(Bit6, True, True, True, True); | ||
assert_eq!(count, 1); | ||
}); |
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
Oops, something went wrong.