Test parse_constant

master
Raymon Zutekouw 3 years ago
parent cecf68905a
commit 64f097b0ff
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 20
      src/main.rs

@ -249,3 +249,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_constant() {
assert_eq!(parse_constant(&"42"), Ok(42));
assert_eq!(parse_constant(&"0x2A"), Ok(42));
assert_eq!(parse_constant(&"\"*\""), Ok(42));
assert!(
matches!(
parse_constant(&"\'*\'"),
Err(std::num::ParseIntError { .. })
),
"Char literals are declared with \"_\", not \'_\'"
);
}
}

Loading…
Cancel
Save