From 3a5ec8e2885d3b0c4c6b942455e6f0246a898f54 Mon Sep 17 00:00:00 2001 From: Xavier Claude Date: Fri, 8 Mar 2024 22:04:49 +0100 Subject: [PATCH] Add tests for formating --- tests/by-util/test_free.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/by-util/test_free.rs b/tests/by-util/test_free.rs index 8fb36af1..e50bcf09 100644 --- a/tests/by-util/test_free.rs +++ b/tests/by-util/test_free.rs @@ -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] @@ -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) +} \ No newline at end of file