Repository: sharkdp/bat
File: tests/integration_tests.rs (Rust)

Code before:
        .assert()
        .success()
        .stdout("   1 line 1\n   2 \n   3 \n   5 line 5\n   6 \n   7 \n  20 line 20\n  21 line 21\n  22 \n  23 \n  24 line 24\n  25 \n  26 line 26\n  27 \n  28 \n  30 line 30\n");

    bat()
        .arg("empty_lines.txt")
        .arg("--squeeze-blank")
        .arg("--squeeze-limit=5")
        .arg("--decorations=always")
        .arg("--number")
        .assert()
        .success()
        .stdout("   1 line 1\n   2 \n   3 \n   4 \n   5 line 5\n   6 \n   7 \n   8 \n   9 \n  10 \n  20 line 20\n  21 line 21\n  22 \n  23 \n  24 line 24\n  25 \n  26 line 26\n  27 \n  28 \n  29 \n  30 line 30\n");
}

#[test]
fn list_themes() {
    let default_theme_chunk: &str;
    #[cfg(target_os = "macos")]
    {
        default_theme_chunk = from_utf8(b"Monokai Extended Light\x1B[0m (default)").unwrap();
    }
    #[cfg(not(target_os = "macos"))]
    {
        default_theme_chunk = from_utf8(b"Monokai Extended\x1B[0m (default)").unwrap();
    }

    bat()
        .arg("--color=always")
        .arg("--list-themes")
        .assert()
        .success()
        .stdout(predicate::str::contains("DarkNeon").normalize())
        .stdout(predicate::str::contains(default_theme_chunk).normalize())
        .stdout(predicate::str::contains("Output the square of a number.").normalize());
}

#[test]
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
fn short_help() {
    test_help("-h", "../doc/short-help.txt");
}

#[test]
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
fn long_help() {
    test_help("--help", "../doc/long-help.txt");
}

fn test_help(arg: &str, expect_file: &str) {
    let assert = bat().arg(arg).assert();

Review comment (suggestion):
```suggestion
    #[cfg(target_os = "macos")]
    let default_theme_chunk = "Monokai Extended Light\x1B[0m (default)";

    #[cfg(not(target_os = "macos"))]
    let default_theme_chunk = "Monokai Extended\x1B[0m (default)";
```

Code after:
        .assert()
        .success()
        .stdout("   1 line 1\n   2 \n   3 \n   5 line 5\n   6 \n   7 \n  20 line 20\n  21 line 21\n  22 \n  23 \n  24 line 24\n  25 \n  26 line 26\n  27 \n  28 \n  30 line 30\n");

    bat()
        .arg("empty_lines.txt")
        .arg("--squeeze-blank")
        .arg("--squeeze-limit=5")
        .arg("--decorations=always")
        .arg("--number")
        .assert()
        .success()
        .stdout("   1 line 1\n   2 \n   3 \n   4 \n   5 line 5\n   6 \n   7 \n   8 \n   9 \n  10 \n  20 line 20\n  21 line 21\n  22 \n  23 \n  24 line 24\n  25 \n  26 line 26\n  27 \n  28 \n  29 \n  30 line 30\n");
}

#[test]
fn list_themes() {
    #[cfg(target_os = "macos")]
    let default_theme_chunk = "Monokai Extended Light\x1B[0m (default)";

    #[cfg(not(target_os = "macos"))]
    let default_theme_chunk = "Monokai Extended\x1B[0m (default)";

    bat()
        .arg("--color=always")
        .arg("--list-themes")
        .assert()
        .success()
        .stdout(predicate::str::contains("DarkNeon").normalize())
        .stdout(predicate::str::contains(default_theme_chunk).normalize())
        .stdout(predicate::str::contains("Output the square of a number.").normalize());
}

#[test]
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
fn short_help() {
    test_help("-h", "../doc/short-help.txt");
}

#[test]
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
fn long_help() {
    test_help("--help", "../doc/long-help.txt");
}

fn test_help(arg: &str, expect_file: &str) {
    let assert = bat().arg(arg).assert();
    expect_test::expect_file![expect_file]
        .assert_eq(&String::from_utf8_lossy(&assert.get_output().stdout));
}