MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / test_rust_enum_and_variants

Function test_rust_enum_and_variants

tests/extraction_suite/rust.rs:119–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117
118#[test]
119fn test_rust_enum_and_variants() {
120 let source = r#"
121pub enum Color {
122 Red,
123 Green,
124 Blue(u8, u8, u8),
125}
126"#;
127 let extractor = RustExtractor;
128 let result = extractor.extract("color.rs", source);
129 assert!(result.errors.is_empty(), "errors: {:?}", result.errors);
130 let enums: Vec<_> = result
131 .nodes
132 .iter()
133 .filter(|n| n.kind == NodeKind::Enum)
134 .collect();
135 assert_eq!(enums.len(), 1);
136 assert_eq!(enums[0].name, "Color");
137 let variants: Vec<_> = result
138 .nodes
139 .iter()
140 .filter(|n| n.kind == NodeKind::EnumVariant)
141 .collect();
142 assert_eq!(
143 variants.len(),
144 3,
145 "expected 3 variants, got: {:?}",
146 variants.iter().map(|n| &n.name).collect::<Vec<_>>()
147 );
148 assert!(variants.iter().any(|v| v.name == "Red"));
149 assert!(variants.iter().any(|v| v.name == "Blue"));
150}
151
152#[test]
153fn test_rust_trait() {

Callers

nothing calls this directly

Calls 2

collectMethod · 0.80
extractMethod · 0.45

Tested by

no test coverage detected