Files
makeCAD/crates/doc/src/coil_tests.rs
T
TheMiddleCompany ae0b1edeac Coil: a section from a sketch profile (#4236) (#4239)
* claim: #4236

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil: store an optional sketch and profile selection

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil: sweep a sketch profile along the helix

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil: accept a sketch and profile selection

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil dialog: pick a sketch profile for the section

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil: cargo fmt

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil: refuse a loaded sketch coil that also sets the primitive section

A saved design could add section, section_position or start_angle to a
coil that already has a sketch; eval ignored them instead of refusing the
contradiction as the command does.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil: assert the kernel refusal and exercise hostile profile selections

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Coil dialog: keep the sketch-profile check after rebase

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Format

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
2026-10-24 21:53:13 +00:00

57 lines
1.4 KiB
Rust

use serde_json::{Value, json};
use crate::FeatureKind;
fn kind(v: Value) -> FeatureKind {
serde_json::from_value(v).unwrap()
}
#[test]
fn an_old_coil_saves_unchanged() {
let old = json!({
"type": "coil",
"base": [0.0, 0.0, 0.0],
"axis": [0.0, 0.0, 1.0],
"diameter": "40",
"pitch": "8",
"turns": "4",
"section_size": "3",
"section": "circular",
"operation": "new_body"
});
assert_eq!(serde_json::to_value(kind(old.clone())).unwrap(), old);
}
#[test]
fn a_coil_from_a_sketch_saves_its_sketch_and_profiles() {
let v = json!({
"type": "coil",
"base": [0.0, 0.0, 0.0],
"axis": [0.0, 0.0, 1.0],
"sketch": 7,
"profiles": {"type": "indices", "indices": [0]},
"pitch": "8",
"turns": "4",
"section": "circular",
"operation": "new_body"
});
assert_eq!(serde_json::to_value(kind(v.clone())).unwrap(), v);
}
#[test]
fn all_profiles_are_omitted() {
let v = json!({
"type": "coil",
"base": [0.0, 0.0, 0.0],
"axis": [0.0, 0.0, 1.0],
"sketch": 7,
"pitch": "8",
"turns": "4",
"section": "circular",
"operation": "new_body"
});
let saved = serde_json::to_value(kind(v.clone())).unwrap();
assert_eq!(saved, v);
assert!(saved.get("profiles").is_none());
}