Skip to content

Commit

Permalink
Add tests for formating
Browse files Browse the repository at this point in the history
  • Loading branch information
claudex committed Mar 8, 2024
1 parent d2519fd commit 3a5ec8e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/by-util/test_free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore (words) symdir somefakedir

use pretty_assertions::assert_eq;
use crate::common::util::TestScenario;

#[test]
Expand All @@ -23,3 +24,19 @@ fn test_free_wide() {
assert!(result.stdout_str().contains("Mem:"));
assert!(!result.stdout_str().contains("buff/cache"));
}

#[test]
fn test_free_column_format() {
let free_header = " total used free shared buff/cache available";
let free_result = new_ucmd!().succeeds();
assert_eq!(free_result.stdout_str().len(), 207);
assert_eq!(free_result.stdout_str().split("\n").next().unwrap(), free_header)
}

#[test]
fn test_free_wide_column_format() {
let free_header = " total used free shared buffers cache available";
let free_result = new_ucmd!().arg("--wide").succeeds();
assert_eq!(free_result.stdout_str().len(), 231);
assert_eq!(free_result.stdout_str().split("\n").next().unwrap(), free_header)
}

0 comments on commit 3a5ec8e

Please sign in to comment.