-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from rodrimati1992/trim_nul_release
0.2.10 version
- Loading branch information
Showing
7 changed files
with
90 additions
and
28 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "const_panic" | ||
version = "0.2.9" | ||
version = "0.2.10" | ||
authors = ["rodrimati1992 <[email protected]>"] | ||
edition = "2021" | ||
license = "Zlib" | ||
|
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 |
---|---|---|
|
@@ -44,4 +44,6 @@ mod main_tests { | |
mod pvcount_tests; | ||
|
||
mod string_tests; | ||
|
||
mod utils_tests; | ||
} |
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,34 @@ | ||
use const_panic::utils::bytes_up_to; | ||
|
||
|
||
macro_rules! case { | ||
($bytes:expr, $upto:expr) => ({ | ||
const SLICE: &[u8] = bytes_up_to($bytes, $upto); | ||
assert_eq!(slice, ); | ||
}) | ||
} | ||
|
||
|
||
#[test] | ||
fn test_bytes_up_to_isconst() { | ||
const SLICE: &[u8] = bytes_up_to(&[10, 20], 1); | ||
|
||
assert_eq!(SLICE, &[10][..]); | ||
} | ||
|
||
#[test] | ||
fn test_bytes_up_to() { | ||
const BYTES: &[u8] = &[3, 5, 8, 13, 21, 34]; | ||
|
||
let iter = (0..=BYTES.len() + 2).chain([usize::MAX - 1, usize::MAX]); | ||
|
||
for bytes_len in iter.clone() { | ||
let bytes = BYTES.get(..bytes_len).unwrap_or(BYTES); | ||
for upto in iter.clone() { | ||
assert_eq!( | ||
bytes_up_to(bytes, upto), | ||
bytes.get(..upto).unwrap_or(bytes), | ||
) | ||
} | ||
} | ||
} |