Skip to content

Commit

Permalink
Merge pull request #95 from paxproject/ss/pax-manifest-parsing-tests
Browse files Browse the repository at this point in the history
Add tests to pax-manifest parsing
  • Loading branch information
warfaj authored Feb 3, 2024
2 parents 1465e30 + 0ba56e1 commit 42efdc0
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pax-manifest/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#[cfg(test)]
#[cfg(feature = "parsing")]
mod tests {

use pax_manifest::{utils, ValueDefinition};

#[test]
fn test_parse_empty() {
assert!(matches!(utils::parse_value(""), Err(_)));
}

#[test]
fn test_parse_identifier() {
let res = utils::parse_value("identifier");
if let Ok(ValueDefinition::Identifier(token, _)) = res {
assert_eq!(&token.raw_value, "identifier");
} else {
panic!("unexpected result: {:?}", res);
}
}

#[test]
fn test_parse_literal_number() {
let res = utils::parse_value("5");
if let Ok(ValueDefinition::LiteralValue(token)) = res {
assert_eq!(&token.raw_value, "5");
} else {
panic!("unexpected result: {:?}", res);
}
}

#[test]
fn test_parse_expression() {
let res = utils::parse_value("{5 + 3}");
if let Ok(ValueDefinition::Expression(token, _)) = res {
assert_eq!(&token.raw_value, "{5 + 3}");
} else {
panic!("unexpected result: {:?}", res);
}
}

#[test]
fn test_parse_with_extra() {
let res = utils::parse_value("{5 + 3}this_shouldn't succeed");
assert!(matches!(res, Err(_)));
}
}

0 comments on commit 42efdc0

Please sign in to comment.