From c6ab35584e4a3e22c8c75fcc7c86448566501f91 Mon Sep 17 00:00:00 2001 From: davidemazzocchi Date: Mon, 29 Sep 2025 08:08:27 +0200 Subject: [PATCH] test: add intended use tests to try/demo the library --- 01.workspace/heave/src/tst/intended_use.rs | 24 ++++++++++++++++++++++ 01.workspace/heave/src/tst/mod.rs | 1 + 2 files changed, 25 insertions(+) create mode 100644 01.workspace/heave/src/tst/intended_use.rs diff --git a/01.workspace/heave/src/tst/intended_use.rs b/01.workspace/heave/src/tst/intended_use.rs new file mode 100644 index 0000000..db5f2a1 --- /dev/null +++ b/01.workspace/heave/src/tst/intended_use.rs @@ -0,0 +1,24 @@ +#[cfg(test)] +mod tests { + use crate::*; + #[test] + fn check_001() { + // Demonstrates the costruction of a new entity instance + let _product = Entity::new("product") + .with_attribute("name", "laptop") + .with_attribute("price", 200000u64) + .with_attribute("discount", 2.5f64) + .with_attribute("in_stock", true); + } + #[test] + fn check_002() { + // Demonstrate attribute value reading + let product = Entity::new("product") + .with_attribute("name", "laptop") + .with_attribute("price", 200000u64); + let name = product.value_of("name"); + let price = product.value_of("price"); + assert_eq!(name, Some(&Value::Text(String::from("laptop")))); + assert_eq!(price, Some(&Value::UnsignedInt(200000))); + } +} diff --git a/01.workspace/heave/src/tst/mod.rs b/01.workspace/heave/src/tst/mod.rs index 31af15c..84b3ec7 100644 --- a/01.workspace/heave/src/tst/mod.rs +++ b/01.workspace/heave/src/tst/mod.rs @@ -1,2 +1,3 @@ pub mod entity_new; pub mod entity_with_attribute; +pub mod intended_use;