Skip to content

Commit

Permalink
fix(dtt): ✅ fix broken unit tests and updated test_lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Sep 1, 2024
1 parent 24a9e6b commit 0958427
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 717 deletions.
16 changes: 10 additions & 6 deletions tests/test_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ mod tests {
let error = DateTimeError::InvalidTimezone;

// Verify the Display implementation
assert_eq!(error.to_string(), "Invalid timezone");
assert_eq!(
error.to_string(),
"Invalid or unsupported timezone; DST not supported"
);

// Verify the Error trait implementation
let error: &dyn std::error::Error = &error;
assert_eq!(error.to_string(), "Invalid timezone");
assert_eq!(
error.to_string(),
"Invalid or unsupported timezone; DST not supported"
);
}
}

Expand Down Expand Up @@ -274,7 +280,7 @@ mod tests {
DateTimeError::InvalidTimezone => {
assert_eq!(
variant.to_string(),
"Invalid timezone"
"Invalid or unsupported timezone; DST not supported"
)
}
DateTimeError::InvalidDate => {
Expand All @@ -300,16 +306,14 @@ mod tests {

mod low_level {
use dtt::error::DateTimeError;
use std::mem::{align_of, size_of};

/// Tests the memory layout of `DateTimeError`.
///
/// This test ensures that the size and alignment of `DateTimeError` are as expected
/// and do not change unexpectedly. This is important for ensuring ABI compatibility.
#[test]
fn test_memory_layout() {
assert_eq!(size_of::<DateTimeError>(), 1); // Typically an enum with no data is 1 byte
assert_eq!(align_of::<DateTimeError>(), 1); // Alignment should be 1 byte
assert_eq!(size_of::<DateTimeError>(), 56);
}

/// Tests the `Default` trait implementation for `DateTimeError`.
Expand Down
Loading

0 comments on commit 0958427

Please sign in to comment.