MCPcopy Create free account
hub / github.com/chanced/jsonptr / parse

Function parse

src/pointer.rs:1518–1567  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1516
1517 #[test]
1518 fn parse() {
1519 let tests = [
1520 ("", Ok("")),
1521 ("/", Ok("/")),
1522 ("/foo", Ok("/foo")),
1523 ("/foo/bar", Ok("/foo/bar")),
1524 ("/foo/bar/baz", Ok("/foo/bar/baz")),
1525 ("/foo/bar/baz/~0", Ok("/foo/bar/baz/~0")),
1526 ("/foo/bar/baz/~1", Ok("/foo/bar/baz/~1")),
1527 ("/foo/bar/baz/~01", Ok("/foo/bar/baz/~01")),
1528 ("/foo/bar/baz/~10", Ok("/foo/bar/baz/~10")),
1529 ("/foo/bar/baz/~11", Ok("/foo/bar/baz/~11")),
1530 ("/foo/bar/baz/~1/~0", Ok("/foo/bar/baz/~1/~0")),
1531 ("missing-slash", Err(ParseError::NoLeadingSlash)),
1532 (
1533 "/~",
1534 Err(ParseError::InvalidEncoding {
1535 offset: 0,
1536 source: EncodingError {
1537 offset: 1,
1538 source: InvalidEncoding::Tilde,
1539 },
1540 }),
1541 ),
1542 (
1543 "/~2",
1544 Err(ParseError::InvalidEncoding {
1545 offset: 0,
1546 source: EncodingError {
1547 offset: 1,
1548 source: InvalidEncoding::Tilde,
1549 },
1550 }),
1551 ),
1552 (
1553 "/~a",
1554 Err(ParseError::InvalidEncoding {
1555 offset: 0,
1556 source: EncodingError {
1557 offset: 1,
1558 source: InvalidEncoding::Tilde,
1559 },
1560 }),
1561 ),
1562 ];
1563 for (input, expected) in tests {
1564 let actual = Pointer::parse(input).map(Pointer::as_str);
1565 assert_eq!(actual, expected);
1566 }
1567 }
1568
1569 #[test]
1570 fn parse_error_offsets() {

Callers 10

visit_borrowed_strMethod · 0.85
try_fromMethod · 0.85
parse_error_offsetsFunction · 0.85
qc_splitFunction · 0.85
intersectionFunction · 0.85
from_box_to_bufFunction · 0.85
quick_miette_spikeFunction · 0.85
assign_errorFunction · 0.85
resolve_errorFunction · 0.85
parse_errorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected