File: display_tests.rs

package info (click to toggle)
rust-debian-changelog 0.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 424 kB
  • sloc: makefile: 2
file content (34 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use debian_changelog::{ChangeLog, Error};
use std::io;

#[test]
fn test_error_display() {
    // Test IO error display
    let io_error = io::Error::new(io::ErrorKind::NotFound, "file not found");
    let error = Error::Io(io_error);
    let display = format!("{}", error);
    assert!(display.contains("IO error"));
    assert!(display.contains("file not found"));

    // Test Parse error display by triggering a parse error
    let result: Result<ChangeLog, _> = "invalid changelog".parse();
    assert!(result.is_err());
    if let Err(parse_error) = result {
        let error = Error::Parse(parse_error);
        let display = format!("{}", error);
        assert!(display.contains("Parse error"));
    }
}

#[test]
fn test_parse_error_from_invalid_input() {
    // Test that parsing invalid input produces errors with proper display
    let result: Result<ChangeLog, _> = "INVALID".parse();
    assert!(result.is_err());

    if let Err(error) = result {
        let display = format!("{}", error);
        // Should contain some error message
        assert!(!display.is_empty());
    }
}