diff --git a/.gitignore b/.gitignore
index 13d712b..8b95939 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,5 @@ cache.out
tarpaulin-report.html
*.bkp
coverage/
+testdata/
+snapshots/
diff --git a/badges/coverage.svg b/badges/coverage.svg
index 7eeb722..17e15c6 100644
--- a/badges/coverage.svg
+++ b/badges/coverage.svg
@@ -1 +1 @@
-
+
diff --git a/weaponry/Cargo.toml b/weaponry/Cargo.toml
index 43e3a6f..f0d583f 100644
--- a/weaponry/Cargo.toml
+++ b/weaponry/Cargo.toml
@@ -8,7 +8,7 @@ more_fields = {path ="../more_fields"}
comfy-table = "7.1.4"
csv = "1.3.1"
probability = "0.20.3"
-rusqlite = { version = "0.33.0" } # , features = ["bundled"]
+rusqlite = { version = "0.33.0" , features = ["bundled"]}
serde = { version = "1.0.217", features = ["derive"] }
serde_rusqlite = "0.37.0"
serde_json = { version = "1.0.138", features = ["alloc"] }
@@ -24,10 +24,9 @@ regex = "1.11.1"
pretty_assertions = "^1.4"
logos = "^0.15"
clap = { version = "4.5.30", features = ["derive"] }
+insta = { version = "1.42.2", features = ["yaml"] }
[[bench]]
name = "iter_creation"
harness = false
-# [lints.rust]
-# unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
diff --git a/weaponry/src/weaponry_structs/equipement_advanced_repr.rs b/weaponry/src/weaponry_structs/equipement_advanced_repr.rs
index 87e6575..5fff657 100644
--- a/weaponry/src/weaponry_structs/equipement_advanced_repr.rs
+++ b/weaponry/src/weaponry_structs/equipement_advanced_repr.rs
@@ -43,6 +43,7 @@ pub struct RefinedEquipement {
}
/// The complete equipement list, refined with all advanced stats
+#[derive(Serialize)]
pub struct RefinedEquipementList {
/// Inner list of Refined Equipements
// TODO[!]: The use of pub stays for the usage of the example showcasing the macro in export
@@ -414,3 +415,49 @@ macro_rules! sort_by_size_then {
}
};
}
+
+#[cfg(test)]
+mod test {
+ use super::{AdvancedStats, RefinedEquipementList};
+ use crate::{
+ interfaces::{RecipeCollection, ToAnalysis},
+ weaponry_structs::{
+ Equipement, InitialEquipementList, equipement_structs::InnerEquipementStats,
+ },
+ };
+
+ #[ignore]
+ #[test]
+ fn test_export_tex() {
+ todo!()
+ }
+ #[ignore]
+ #[test]
+ fn test_export_csv() {
+ todo!()
+ }
+
+ #[test]
+ fn test_analysis() {
+ let ls = RefinedEquipementList::default();
+ let mut ls = ls.inner_filter(|c| c.inner.rarity == 0);
+ ls.inner_sort(|l, r| l.inner.rarity.cmp(&r.inner.rarity));
+ let _ = std::fs::create_dir("testdata");
+ let _ = std::fs::remove_file("testdata/testgraph.html");
+ let _ = std::fs::remove_file("testdata/testgraph_plots.html");
+ assert!(ls.write_html("testgraph").is_ok());
+ }
+ #[test]
+ fn test_scenario() {
+ let ls = RefinedEquipementList::default();
+ let _chart = ls.make_cross_plots_graph();
+ let _chart2 = ls.make_regular_graph();
+ }
+ #[test]
+ fn test_impls() {
+ let a = AdvancedStats::from(&InnerEquipementStats::random_new());
+ let _ = serde_json::to_string(&a);
+ let ls = InitialEquipementList::from_vectored(vec![Equipement::default()]);
+ let _ = RefinedEquipementList::from(ls);
+ }
+}
diff --git a/weaponry/src/weaponry_structs/equipement_scenario.rs b/weaponry/src/weaponry_structs/equipement_scenario.rs
index 1722064..a608414 100644
--- a/weaponry/src/weaponry_structs/equipement_scenario.rs
+++ b/weaponry/src/weaponry_structs/equipement_scenario.rs
@@ -57,7 +57,8 @@ pub struct IndividualElementsScenario {
impl CrossRecipeScenario {
/// Generate all the operations to be processed with the current config
- // TODO[!]: Consider adding to interface
+ ///
+ /// This is a very implementation specific step and function internally as a helper
fn generate_selected_operation(
&self,
) -> Result, FatalEquipementError> {
@@ -141,6 +142,7 @@ impl Scenario for CrossRecipeScenario {
#[cfg(test)]
mod test {
+ use super::{ConfigEquipementScenario, CrossRecipeScenario};
use crate::{
interfaces::{RecipeDatabase, Scenario},
weaponry_structs::{
@@ -149,13 +151,8 @@ mod test {
},
};
- use super::{ConfigEquipementScenario, CrossRecipeScenario};
-
- #[test]
- fn test_scenario() {}
- #[test]
- fn test_deserde_into() {
- let b = CrossRecipeScenario {
+ fn mock_cross_with_db() -> CrossRecipeScenario {
+ let cross_rec_scenario = CrossRecipeScenario {
database: EquipementDatabase {
conn: rusqlite::Connection::open_in_memory().unwrap(),
},
@@ -168,16 +165,57 @@ mod test {
finishing: None,
},
};
-
- b.get_database()
+ cross_rec_scenario
+ .get_database()
.initialize_empty_table::("Finishing")
.unwrap();
- b.get_database()
+ cross_rec_scenario
+ .get_database()
.insert_row::(
"Finishing",
DatabaseEquipementStats::random_new(),
)
.unwrap();
+ cross_rec_scenario
+ }
+
+ #[test]
+ fn test_no_gen() {
+ let refined_list = CrossRecipeScenario::new_with_config(ConfigEquipementScenario {
+ table_name: "Equipements".into(),
+ db_path: String::new(),
+ shape: None,
+ materials: None,
+ nature: None,
+ finishing: None,
+ })
+ .unwrap();
+ assert!(refined_list.generate_selected_operation().is_err());
+ }
+ #[test]
+ fn test_scenario_with_snapshot() {
+ let path_a = "../databases/weapons.db";
+ let path_b = "./databases/weapons.db";
+ let path = if std::fs::exists(path_a).unwrap() {
+ path_a
+ } else {
+ path_b
+ };
+ let refined_list = CrossRecipeScenario::new_with_config(ConfigEquipementScenario {
+ table_name: "Equipements".into(),
+ db_path: path.into(),
+ shape: Some(()),
+ materials: Some(1),
+ nature: Some(()),
+ finishing: Some(()),
+ })
+ .unwrap();
+ let final_list = refined_list.generate_refined_recipes().unwrap();
+ insta::assert_yaml_snapshot!(final_list);
+ }
+ #[test]
+ fn test_deserde_into() {
+ let b = mock_cross_with_db();
::get_database(&b);
let r = b
.deserde_into_processed_representation::(None)
diff --git a/weaponry/testgraph.html b/weaponry/testgraph.html
new file mode 100644
index 0000000..bdad448
--- /dev/null
+++ b/weaponry/testgraph.html
@@ -0,0 +1,515 @@
+
+
+
+
+ Ravenous Balancing
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file