mod common;
use assert_cmd::prelude::*;
use common::dircat_cmd;
use predicates::prelude::*;
use std::fs;
use tempfile::tempdir;
#[test]
fn test_line_numbers() -> Result<(), Box<dyn std::error::Error>> {
let temp = tempdir()?;
fs::write(temp.path().join("lines.txt"), "Line 1\nLine 2\n\nLine 4")?;
dircat_cmd()
.arg("-L") .current_dir(temp.path())
.assert()
.success()
.stdout(predicate::str::contains(" 1 | Line 1"))
.stdout(predicate::str::contains(" 2 | Line 2"))
.stdout(predicate::str::contains(" 3 | \n")) .stdout(predicate::str::contains(" 4 | Line 4"));
temp.close()?;
Ok(())
}
#[test]
fn test_remove_empty_lines() -> Result<(), Box<dyn std::error::Error>> {
let temp = tempdir()?;
fs::write(temp.path().join("lines.txt"), "Line 1\n \nLine 3\n\n")?;
dircat_cmd()
.arg("-l") .current_dir(temp.path())
.assert()
.success()
.stdout(predicate::str::contains("Line 1\nLine 3\n```"));
temp.close()?;
Ok(())
}