Brijesh's Git Server — bsh @ dbeb3fca578539e8c1c26f387d87f95341464c16

my own shell program

src/tests/parser_test.rs (view raw)

 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
#[cfg(test)]
mod tests {
    use crate::parser;

    #[test]
    fn test_parse_simple_command() {
        let input = "echo hello";
        let parsed = parser::parse(input).expect("Failed to parse command");
        assert_eq!(parsed.command, "echo");
        assert_eq!(parsed.args, vec!["hello"]);
    }

    #[test]
    fn test_parse_quoted_argument() {
        let input = "echo 'hello world'";
        let parsed = parser::parse(input).expect("Failed to parse command");
        assert_eq!(parsed.command, "echo");
        assert_eq!(parsed.args, vec!["hello world"]);
    }

    #[test]
    fn test_parse_empty_input() {
        let input = "";
        let parsed = parser::parse(input);
        assert!(parsed.is_err(), "Empty input should result in error");
    }
}