MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / it_should_take

Function it_should_take

src/ast.rs:594–617  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

592
593 #[test]
594 fn it_should_take() {
595 let ast = parse_to_ast(
596 "{'prop': 'asdf', 'other': 'text'}",
597 &Default::default(),
598 &ParseOptions::default(),
599 )
600 .unwrap();
601 let mut obj = match ast.value {
602 Some(Value::Object(obj)) => obj,
603 _ => unreachable!(),
604 };
605
606 assert_eq!(obj.properties.len(), 2);
607 assert_eq!(obj.take_string("asdf"), None);
608 assert_eq!(obj.properties.len(), 2);
609 assert_eq!(obj.take_number("prop"), None);
610 assert_eq!(obj.properties.len(), 2);
611 assert!(obj.take_string("prop").is_some());
612 assert_eq!(obj.properties.len(), 1);
613 assert_eq!(obj.take("something"), None);
614 assert_eq!(obj.properties.len(), 1);
615 assert!(obj.take("other").is_some());
616 assert_eq!(obj.properties.len(), 0);
617 }
618
619 #[test]
620 fn it_should_get() {

Callers

nothing calls this directly

Calls 1

parse_to_astFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…