diff options
| author | xxanqw <[email protected]> | 2025-11-26 13:52:24 +0200 |
|---|---|---|
| committer | xxanqw <[email protected]> | 2025-11-26 13:52:24 +0200 |
| commit | 175a320d84197896c5b6e038c0d67bbaa84baff0 (patch) | |
| tree | 2202964b0d063eea16a9db59c102cd12b74c78ad /tests | |
| parent | 5e2888348e28f8340a54153c618c5373bc194ec5 (diff) | |
| download | mikusays-c-175a320d84197896c5b6e038c0d67bbaa84baff0.tar.gz mikusays-c-175a320d84197896c5b6e038c0d67bbaa84baff0.zip | |
Add color handling and CLI integration tests
- Implemented a comprehensive color module in `src/color.rs` that supports named colors, hex, RGB, HSL, ANSI, and truecolor formats.
- Added parsing functions for different color formats with error handling.
- Introduced conversion methods for colors to RGB and ANSI escape codes.
- Created a `ColorMode` enum to detect terminal color capabilities.
- Added linear interpolation for colors in HSV space.
- Developed integration tests in `tests/integration_tests.rs` to verify CLI functionality, including listing styles and error handling for missing or conflicting arguments.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/integration_tests.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs new file mode 100644 index 0000000..c589db0 --- /dev/null +++ b/tests/integration_tests.rs @@ -0,0 +1,55 @@ +use std::process::Command; +use std::str; + +#[test] +fn test_cli_list_styles() { + let output = Command::new("target/debug/mikusays") + .arg("--list") + .output() + .expect("Failed to execute command"); + + assert!(output.status.success()); + let stdout = str::from_utf8(&output.stdout).expect("Invalid UTF-8"); + + // Should contain style listing information + assert!(stdout.contains("Available Miku art styles:")); + assert!(stdout.contains("Total styles:")); + assert!(stdout.contains("--- Style")); +} + +#[test] +fn test_cli_error_no_text() { + let output = Command::new("target/debug/mikusays") + .output() + .expect("Failed to execute command"); + + assert!(!output.status.success()); + let stderr = str::from_utf8(&output.stderr).expect("Invalid UTF-8"); + assert!(stderr.contains("Error: Text is required when not using --list")); +} + +#[test] +fn test_cli_error_conflicting_args() { + let output = Command::new("target/debug/mikusays") + .arg("Test") + .arg("--rainbow") + .arg("--color") + .arg("red") + .output() + .expect("Failed to execute command"); + + assert!(!output.status.success()); + let stderr = str::from_utf8(&output.stderr).expect("Invalid UTF-8"); + assert!(stderr.contains("Cannot use --rainbow and --color together")); +} + +#[test] +fn test_cli_basic_functionality() { + // Test that the binary runs and produces some output + let output = Command::new("target/debug/mikusays") + .arg("--list") + .output() + .expect("Failed to execute command"); + + assert!(output.status.success()); +} |
