diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/rust/litrs/src/bool/tests.rs | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/litrs/src/bool/tests.rs')
-rw-r--r-- | third_party/rust/litrs/src/bool/tests.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/third_party/rust/litrs/src/bool/tests.rs b/third_party/rust/litrs/src/bool/tests.rs new file mode 100644 index 0000000000..4b829244b8 --- /dev/null +++ b/third_party/rust/litrs/src/bool/tests.rs @@ -0,0 +1,48 @@ +use crate::{ + Literal, BoolLit, + test_util::assert_parse_ok_eq, +}; + +macro_rules! assert_bool_parse { + ($input:literal, $expected:expr) => { + assert_parse_ok_eq( + $input, Literal::parse($input), Literal::Bool($expected), "Literal::parse"); + assert_parse_ok_eq($input, BoolLit::parse($input), $expected, "BoolLit::parse"); + }; +} + + + +#[test] +fn parse_ok() { + assert_bool_parse!("false", BoolLit::False); + assert_bool_parse!("true", BoolLit::True); +} + +#[test] +fn parse_err() { + assert!(Literal::parse("fa").is_err()); + assert!(Literal::parse("fal").is_err()); + assert!(Literal::parse("fals").is_err()); + assert!(Literal::parse(" false").is_err()); + assert!(Literal::parse("false ").is_err()); + assert!(Literal::parse("False").is_err()); + + assert!(Literal::parse("tr").is_err()); + assert!(Literal::parse("tru").is_err()); + assert!(Literal::parse(" true").is_err()); + assert!(Literal::parse("true ").is_err()); + assert!(Literal::parse("True").is_err()); +} + +#[test] +fn value() { + assert!(!BoolLit::False.value()); + assert!(BoolLit::True.value()); +} + +#[test] +fn as_str() { + assert_eq!(BoolLit::False.as_str(), "false"); + assert_eq!(BoolLit::True.as_str(), "true"); +} |