mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Make integration test a unit test
I don't know why I implemented it as an integration test.
This commit is contained in:
@@ -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
|
||||
|
||||
+26
@@ -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;
|
||||
|
||||
@@ -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, Error> {
|
||||
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());
|
||||
}
|
||||
Reference in New Issue
Block a user