Server: domain (entities, value objects, ports), protocol (postcard wire types), application (config service, data projection), adapters (config-memory, tcp-server), bootstrap (composition root with fake data). Client: client-domain (layout engine, render tree, HAL ports), client-application (message handling, repaint commands), adapters (tcp-client, display-terminal), client-desktop (end-to-end working). ESP32: client-esp32 firmware with ILI9341 display over SPI, WiFi networking. Display test verified on hardware — landscape orientation, text rendering works. 60 workspace tests, all passing.
78 lines
2.0 KiB
Rust
78 lines
2.0 KiB
Rust
use std::collections::BTreeMap;
|
|
use domain::Value;
|
|
|
|
#[test]
|
|
fn estimated_size_of_string_is_its_byte_length() {
|
|
let v = Value::String("hello".into());
|
|
assert_eq!(v.estimated_size(), 5);
|
|
}
|
|
|
|
#[test]
|
|
fn estimated_size_of_number_is_8_bytes() {
|
|
assert_eq!(Value::Number(3.14).estimated_size(), 8);
|
|
}
|
|
|
|
#[test]
|
|
fn estimated_size_of_null_and_bool_is_1() {
|
|
assert_eq!(Value::Null.estimated_size(), 1);
|
|
assert_eq!(Value::Bool(true).estimated_size(), 1);
|
|
}
|
|
|
|
#[test]
|
|
fn estimated_size_of_nested_structure_sums_recursively() {
|
|
let v = Value::Object(BTreeMap::from([
|
|
("key".into(), Value::String("value".into())),
|
|
("num".into(), Value::Number(1.0)),
|
|
]));
|
|
assert_eq!(v.estimated_size(), 19);
|
|
}
|
|
|
|
#[test]
|
|
fn estimated_size_of_array_sums_elements() {
|
|
let v = Value::Array(vec![
|
|
Value::String("abc".into()),
|
|
Value::Number(1.0),
|
|
]);
|
|
assert_eq!(v.estimated_size(), 11);
|
|
}
|
|
|
|
#[test]
|
|
fn get_path_returns_none_for_missing_key() {
|
|
let data = Value::Object(BTreeMap::from([
|
|
("main".into(), Value::Number(1.0)),
|
|
]));
|
|
assert_eq!(data.get_path("$.missing"), None);
|
|
}
|
|
|
|
#[test]
|
|
fn get_path_returns_none_when_traversing_non_object() {
|
|
let data = Value::Object(BTreeMap::from([
|
|
("temp".into(), Value::Number(5.4)),
|
|
]));
|
|
assert_eq!(data.get_path("$.temp.nested"), None);
|
|
}
|
|
|
|
#[test]
|
|
fn get_path_accesses_array_by_index() {
|
|
let data = Value::Object(BTreeMap::from([
|
|
("items".into(), Value::Array(vec![
|
|
Value::String("first".into()),
|
|
Value::String("second".into()),
|
|
])),
|
|
]));
|
|
assert_eq!(
|
|
data.get_path("$.items[1]"),
|
|
Some(&Value::String("second".into()))
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn get_path_traverses_nested_object() {
|
|
let data = Value::Object(BTreeMap::from([
|
|
("main".into(), Value::Object(BTreeMap::from([
|
|
("temp".into(), Value::Number(5.4)),
|
|
]))),
|
|
]));
|
|
assert_eq!(data.get_path("$.main.temp"), Some(&Value::Number(5.4)));
|
|
}
|