-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utils): additional set operations (#39)
* rename traits * subset * intersection * prove set intersection * assert invariants * fix doctest
- Loading branch information
Showing
13 changed files
with
524 additions
and
105 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![no_main] | ||
|
||
use std::collections::HashSet; | ||
use std::ops::Range; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
use tlsn_utils_fuzz::{assert_invariants, SmallSet}; | ||
|
||
use utils::range::*; | ||
|
||
fuzz_target!(|r: (Range<u8>, SmallSet)| { | ||
let s1 = r.0; | ||
let s2: RangeSet<u8> = r.1.into(); | ||
|
||
let h1: HashSet<u8> = HashSet::from_iter(s1.clone()); | ||
let h2: HashSet<u8> = HashSet::from_iter(s2.iter()); | ||
|
||
let intersection = s1.intersection(&s2); | ||
let h3: HashSet<u8> = HashSet::from_iter(intersection.iter()); | ||
|
||
assert_eq!(h3, h1.intersection(&h2).copied().collect::<HashSet<_>>()); | ||
|
||
assert_invariants(intersection); | ||
}); |
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 @@ | ||
#![no_main] | ||
|
||
use std::collections::HashSet; | ||
use std::ops::Range; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
use tlsn_utils_fuzz::SmallSet; | ||
|
||
use utils::range::*; | ||
|
||
fuzz_target!(|r: (Range<u8>, SmallSet)| { | ||
let s1 = r.0; | ||
let s2: RangeSet<u8> = r.1.into(); | ||
|
||
let h1: HashSet<u8> = HashSet::from_iter(s1.clone()); | ||
let h2: HashSet<u8> = HashSet::from_iter(s2.iter()); | ||
|
||
assert_eq!(s1.is_subset(&s2), h1.is_subset(&h2)); | ||
}); |
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,24 @@ | ||
#![no_main] | ||
|
||
use std::collections::HashSet; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
use tlsn_utils_fuzz::{assert_invariants, SmallSet}; | ||
|
||
use utils::range::*; | ||
|
||
fuzz_target!(|r: (SmallSet, SmallSet)| { | ||
let s1: RangeSet<u8> = r.0.into(); | ||
let s2: RangeSet<u8> = r.1.into(); | ||
|
||
let h1: HashSet<u8> = HashSet::from_iter(s1.iter()); | ||
let h2: HashSet<u8> = HashSet::from_iter(s2.iter()); | ||
|
||
let intersection = s1.intersection(&s2); | ||
let h3: HashSet<u8> = HashSet::from_iter(intersection.iter()); | ||
|
||
assert_eq!(h3, h1.intersection(&h2).copied().collect::<HashSet<_>>()); | ||
|
||
assert_invariants(intersection); | ||
}); |
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,19 @@ | ||
#![no_main] | ||
|
||
use std::collections::HashSet; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
use tlsn_utils_fuzz::SmallSet; | ||
|
||
use utils::range::*; | ||
|
||
fuzz_target!(|r: (SmallSet, SmallSet)| { | ||
let s1: RangeSet<u8> = r.0.into(); | ||
let s2: RangeSet<u8> = r.1.into(); | ||
|
||
let h1: HashSet<u8> = HashSet::from_iter(s1.iter()); | ||
let h2: HashSet<u8> = HashSet::from_iter(s2.iter()); | ||
|
||
assert_eq!(s1.is_subset(&s2), h1.is_subset(&h2)); | ||
}); |
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.