| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | extern crate task2;
use task2::Config;
#[test]
fn test_parse_config_1() {
    let a = vec![
        "Not interested".to_string(),
        "e".to_string(),
        "Numero Due".to_string(),
    ];
    let c = Config {
        search: 'e',
        line: "Numero Due".to_string(),
    };
    assert_eq!(Config::new(&a), Ok(c));
}
#[test]
#[should_panic]
fn test_parse_config_2() {
    let a = vec![
        "Not interested".to_string(),
        "x".to_string(),
        "Numero Due".to_string(),
    ];
    let c = Config {
        search: 'e',
        line: "Numero Due".to_string(),
    };
    assert_eq!(Config::new(&a), Ok(c));
}
#[test]
fn test_parse_config_3() {
    let a = vec![
        "Not interested".to_string(),
        "0".to_string(),
        "0".to_string(),
    ];
    let c = Config {
        search: '0',
        line: "0".to_string(),
    };
    assert_eq!(Config::new(&a), Ok(c));
}
#[test]
fn test_parse_config_err_1() {
    let a = vec!["Not interested".to_string(), "e".to_string()];
    assert_eq!(Config::new(&a), Err("not enough arguments"));
}
#[test]
fn test_parse_config_err_2() {
    let a = vec!["Not interested".to_string()];
    assert_eq!(Config::new(&a), Err("not enough arguments"));
}
#[test]
fn test_run_1() {
    let c = Config {
        search: 'e',
        line: "Numero Due".to_string(),
    };
    assert_eq!(task2::run(&c), 2);
}
#[test]
fn test_run_2() {
    let c = Config {
        search: '♥',
        line: "♥ The quick brown fox jumps over the lazy dog. ♥".to_string(),
    };
    assert_eq!(task2::run(&c), 2);
}
#[test]
#[should_panic]
fn test_run_3() {
    let c = Config {
        search: 'q',
        line: "♥ The quick brown fox jumps over the lazy dog. ♥".to_string(),
    };
    assert_eq!(task2::run(&c), 2);
}
#[test]
fn test_run_4() {
    let c = Config {
        search: '!',
        line: "♥ The quick brown fox jumps over the lazy dog. ♥".to_string(),
    };
    assert_eq!(task2::run(&c), 0);
}
 |