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

Function intersection

src/pointer.rs:2249–2298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2247
2248 #[test]
2249 fn intersection() {
2250 struct Test {
2251 base: &'static str,
2252 a_suffix: &'static str,
2253 b_suffix: &'static str,
2254 }
2255
2256 let tests = [
2257 Test {
2258 base: "",
2259 a_suffix: "/",
2260 b_suffix: "/a/b/c",
2261 },
2262 Test {
2263 base: "",
2264 a_suffix: "",
2265 b_suffix: "",
2266 },
2267 Test {
2268 base: "/a",
2269 a_suffix: "/",
2270 b_suffix: "/suffix",
2271 },
2272 Test {
2273 base: "/a",
2274 a_suffix: "/suffix",
2275 b_suffix: "",
2276 },
2277 Test {
2278 base: "/¦\\>‶“lv\u{eedd}\u{8a}Y\n\u{99}𘐷vT\n\u{4}Hª\\ 嗱\\Yl6Y`\"1\u{6dd}\u{17}\0\u{10}ዄ8\"Z닍6i)V;\u{6be4c}\u{b}\u{59836}`\u{1e}㑍§~05\u{1d}\u{8a}[뵔\u{437c3}j\u{f326}\";*\u{c}*U\u{1b}\u{8a}I\u{4}묁",
2279 a_suffix: "/Y\u{2064}",
2280 b_suffix: "",
2281 }
2282 ];
2283
2284 for Test {
2285 base,
2286 a_suffix,
2287 b_suffix,
2288 } in tests
2289 {
2290 let base = PointerBuf::parse(base).expect(&format!("failed to parse ${base}"));
2291 let mut a = base.clone();
2292 let mut b = base.clone();
2293 a.append(PointerBuf::parse(a_suffix).unwrap());
2294 b.append(PointerBuf::parse(b_suffix).unwrap());
2295 let intersection = a.intersection(&b);
2296 assert_eq!(intersection, base);
2297 }
2298 }
2299
2300 #[test]
2301 fn into_iter() {

Callers

nothing calls this directly

Calls 3

parseFunction · 0.85
appendMethod · 0.80
intersectionMethod · 0.80

Tested by

no test coverage detected