Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::error::Error;
use core::fmt;

/// Length exceeds string's capacity
Expand All @@ -19,7 +20,7 @@ impl fmt::Debug for ExceedsCapacity {
}
}

impl core::fmt::Display for ExceedsCapacity {
impl fmt::Display for ExceedsCapacity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!(
"String length ({}) exceeds capacity ({})",
Expand All @@ -28,4 +29,4 @@ impl core::fmt::Display for ExceedsCapacity {
}
}

impl core::error::Error for ExceedsCapacity {}
impl Error for ExceedsCapacity {}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ pub type StrVec112 = StrVec<u128, 112, Align128>;
#[cfg(test)]
mod tests {
mod bounded_str_tests;
mod error_tests;
mod fixed_str_tests;
mod str_vec_tests;
}
9 changes: 9 additions & 0 deletions src/tests/bounded_str_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ fn test_alignment() {
assert_eq!(mem::align_of::<BStr127>(), 128);
}

#[test]
fn test_ord() {
assert!(BStr7::from("a") < BStr7::from("b"));
assert!(BStr15::from("a") < BStr15::from("b"));
assert!(BStr31::from("a") < BStr31::from("b"));
assert!(BStr63::from("a") < BStr63::from("b"));
assert!(BStr127::from("a") < BStr127::from("b"));
}

#[test]
fn test_push_str() {
let mut s = BStr15::new();
Expand Down
15 changes: 15 additions & 0 deletions src/tests/error_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[cfg(feature = "std")]
mod std {
use ::std::boxed::Box;
use core::error::Error;

use crate::ExceedsCapacity;

#[test]
fn test_error() {
let _: Box<dyn Error> = Box::new(ExceedsCapacity {
length: 16,
capacity: 8,
});
}
}
9 changes: 9 additions & 0 deletions src/tests/fixed_str_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ fn test_alignment() {
assert_eq!(mem::align_of::<FStr128>(), 128);
}

#[test]
fn test_ord() {
assert!(FStr8::from("a") < FStr8::from("b"));
assert!(FStr16::from("a") < FStr16::from("b"));
assert!(FStr32::from("a") < FStr32::from("b"));
assert!(FStr64::from("a") < FStr64::from("b"));
assert!(FStr128::from("a") < FStr128::from("b"));
}

const fn f() -> FStr24 {
FStr24::const_try_from("abc").unwrap()
}
Expand Down
Loading