Skip to content

Commit

Permalink
added test for with_message function
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan26 committed Sep 30, 2024
1 parent 98e9fbc commit 40e8fab
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion zung_mini/src/progbar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<T> ProgBar<T, UnBounded> {
/// ```rust
/// use zung_mini::progbar::ProgBarExt;
///
/// for _ in (0..).progbar().with_message("Processing...".to_string()) {
/// for _ in (0..).progbar().with_message("Processing...") {
/// // Perform work here
/// # break;
/// };
Expand Down Expand Up @@ -517,4 +517,20 @@ mod tests {
assert_eq!(progbar.bound.percentage.get(), i * 10);
}
}

#[test]
fn test_with_message() {
let mut progbar = (0..).progbar().with_message("Loading...");

// Test the initial message
assert_eq!(progbar.message, "Loading...");

// Test updating the message
progbar = progbar.with_message("Processing...");
assert_eq!(progbar.message, "Processing...");

// Ensure the progress bar can still iterate, though unbounded.
assert_eq!(progbar.next(), Some(0)); // First item
assert_eq!(progbar.step, 1); // Progress updated by 1 step
}
}

0 comments on commit 40e8fab

Please sign in to comment.