diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91c3d0e..9351b25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,25 +48,23 @@ jobs: - name: Prepare test resources shell: bash run: | - cd tests + mkdir tests curl -sSfLO 'https://github.com/Ortham/testing-plugins/archive/1.4.0.zip' 7z x 1.4.0.zip - mv testing-plugins-1.4.0 testing-plugins + mv testing-plugins-1.4.0 tests/testing-plugins curl -sSfLO 'https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z' 7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z - mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 libloot_win32 + mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 tests/libloot_win32 curl -sSfLO 'https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z' 7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z - mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 libloot_win64 + mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 tests/libloot_win64 curl -sSfLO 'https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z' 7z x loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z - mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python - - cd .. + mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 tests/loot_api_python - name: Build and run tests run: cargo test --workspace @@ -91,8 +89,6 @@ jobs: - name: Build and run C++ tests shell: bash run: | - mkdir ffi/build - cd ffi/build - cmake .. - cmake --build . - ctest + cmake cmake -B ffi/build ffi + cmake --build ffi/build + ctest --test-dir ffi/build diff --git a/src/lib.rs b/src/lib.rs index c8b9c5c..90e5994 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -406,6 +406,32 @@ mod tests { ); } + #[test] + fn expression_parsing_should_ignore_whitespace_between_function_arguments() { + let is_ok = |s: &str| Expression::from_str(s).is_ok(); + + assert!(is_ok("version(\"Cargo.toml\", \"1.2\", ==)")); + assert!(is_ok( + "version(\"Unofficial Oblivion Patch.esp\",\"3.4.0\",>=)" + )); + assert!(is_ok( + "version(\"Unofficial Skyrim Patch.esp\", \"2.0\", >=)" + )); + assert!(is_ok("version(\"..\\TESV.exe\", \"1.8\", >) and not checksum(\"EternalShineArmorAndWeapons.esp\",3E85A943)")); + assert!(is_ok("version(\"..\\TESV.exe\",\"1.8\",>) and not checksum(\"EternalShineArmorAndWeapons.esp\",3E85A943)")); + assert!(is_ok("checksum(\"HM_HotkeyMod.esp\",374C564C)")); + assert!(is_ok("checksum(\"HM_HotkeyMod.esp\",CF00AFFD)")); + assert!(is_ok( + "checksum(\"HM_HotkeyMod.esp\",374C564C) or checksum(\"HM_HotkeyMod.esp\",CF00AFFD)" + )); + assert!(is_ok("( checksum(\"HM_HotkeyMod.esp\",374C564C) or checksum(\"HM_HotkeyMod.esp\",CF00AFFD) )")); + assert!(is_ok("file(\"UFO - Ultimate Follower Overhaul.esp\")")); + assert!(is_ok("( checksum(\"HM_HotkeyMod.esp\",374C564C) or checksum(\"HM_HotkeyMod.esp\",CF00AFFD) ) and file(\"UFO - Ultimate Follower Overhaul.esp\")")); + assert!(is_ok( + "many(\"Deeper Thoughts (\\(Curie\\)|- (Expressive )?Curie)\\.esp\")" + )); + } + #[test] fn compound_condition_parse_should_handle_a_single_condition() { let result = CompoundCondition::parse("file(\"Cargo.toml\")").unwrap().1; diff --git a/tests/parsing.rs b/tests/parsing.rs deleted file mode 100644 index d89ed6c..0000000 --- a/tests/parsing.rs +++ /dev/null @@ -1,52 +0,0 @@ -extern crate loot_condition_interpreter; - -use std::str::FromStr; - -use loot_condition_interpreter::{Error, Expression}; - -fn expression(string: &str) -> Result { - Expression::from_str(string) -} - -#[test] -fn expression_parsing_should_ignore_whitespace_between_function_arguments() { - let e = expression("version(\"Cargo.toml\", \"1.2\", ==)"); - assert!(e.is_ok()); - - let e = expression("version(\"Unofficial Oblivion Patch.esp\",\"3.4.0\",>=)"); - assert!(e.is_ok()); - - let e = expression("version(\"Unofficial Skyrim Patch.esp\", \"2.0\", >=)"); - assert!(e.is_ok()); - - let e = expression("version(\"..\\TESV.exe\", \"1.8\", >) and not checksum(\"EternalShineArmorAndWeapons.esp\",3E85A943)"); - assert!(e.is_ok()); - - let e = expression("version(\"..\\TESV.exe\",\"1.8\",>) and not checksum(\"EternalShineArmorAndWeapons.esp\",3E85A943)"); - assert!(e.is_ok()); - - let e = expression("checksum(\"HM_HotkeyMod.esp\",374C564C)"); - assert!(e.is_ok()); - - let e = expression("checksum(\"HM_HotkeyMod.esp\",CF00AFFD)"); - assert!(e.is_ok()); - - let e = expression( - "checksum(\"HM_HotkeyMod.esp\",374C564C) or checksum(\"HM_HotkeyMod.esp\",CF00AFFD)", - ); - assert!(e.is_ok()); - - let e = expression( - "( checksum(\"HM_HotkeyMod.esp\",374C564C) or checksum(\"HM_HotkeyMod.esp\",CF00AFFD) )", - ); - assert!(e.is_ok()); - - let e = expression("file(\"UFO - Ultimate Follower Overhaul.esp\")"); - assert!(e.is_ok()); - - let e = expression("( checksum(\"HM_HotkeyMod.esp\",374C564C) or checksum(\"HM_HotkeyMod.esp\",CF00AFFD) ) and file(\"UFO - Ultimate Follower Overhaul.esp\")"); - assert!(e.is_ok()); - - let e = expression("many(\"Deeper Thoughts (\\(Curie\\)|- (Expressive )?Curie)\\.esp\")"); - assert!(e.is_ok()); -}