qubit-command 0.4.0

Command-line process running utilities for Rust
Documentation
/*******************************************************************************
 *
 *    Copyright (c) 2026 Haixing Hu.
 *
 *    SPDX-License-Identifier: Apache-2.0
 *
 *    Licensed under the Apache License, Version 2.0.
 *
 ******************************************************************************/
//! Tests for captured output behavior.

use qubit_command::{
    Command,
    CommandRunner,
};

#[test]
fn test_captured_output_records_stdout_truncation() {
    let output = CommandRunner::new()
        .max_stdout_bytes(5)
        .run(Command::new("rustc").arg("--version"))
        .expect("rustc version command should run successfully");

    assert_eq!(output.stdout().len(), 5);
    assert!(output.stdout_truncated());
}

#[test]
fn test_captured_output_can_keep_zero_stdout() {
    let output = CommandRunner::new()
        .max_stdout_bytes(0)
        .run(Command::new("rustc").arg("--version"))
        .expect("rustc version command should run successfully");

    assert!(output.stdout().is_empty());
    assert!(output.stdout_truncated());
}

#[test]
fn test_captured_output_limit_without_truncation() {
    let output = CommandRunner::new()
        .max_stdout_bytes(1024)
        .run(Command::new("rustc").arg("--version"))
        .expect("rustc version command should run successfully");

    assert!(output.stdout().starts_with(b"rustc "));
    assert!(!output.stdout_truncated());
}