test: add intended use tests to try/demo the library

This commit is contained in:
2025-09-29 08:08:27 +02:00
parent 357296edd6
commit c6ab35584e
2 changed files with 25 additions and 0 deletions

View File

@@ -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)));
}
}

View File

@@ -1,2 +1,3 @@
pub mod entity_new; pub mod entity_new;
pub mod entity_with_attribute; pub mod entity_with_attribute;
pub mod intended_use;