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

Function push_pop_back

src/pointer.rs:1592–1610  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1590
1591 #[test]
1592 fn push_pop_back() {
1593 let mut ptr = PointerBuf::default();
1594 assert_eq!(ptr, "", "default, root pointer should equal \"\"");
1595 assert_eq!(ptr.count(), 0, "default pointer should have 0 tokens");
1596
1597 ptr.push_back("foo");
1598 assert_eq!(ptr, "/foo", "pointer should equal \"/foo\" after push_back");
1599
1600 ptr.push_back("bar");
1601 assert_eq!(ptr, "/foo/bar");
1602 ptr.push_back("/baz");
1603 assert_eq!(ptr, "/foo/bar/~1baz");
1604
1605 let mut ptr = PointerBuf::from_tokens(["foo", "bar"]);
1606 assert_eq!(ptr.pop_back(), Some("bar".into()));
1607 assert_eq!(ptr, "/foo", "pointer should equal \"/foo\" after pop_back");
1608 assert_eq!(ptr.pop_back(), Some("foo".into()));
1609 assert_eq!(ptr, "", "pointer should equal \"\" after pop_back");
1610 }
1611
1612 #[test]
1613 fn replace_token() {

Callers

nothing calls this directly

Calls 2

from_tokensFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected