diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d5de76..b1720b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -... +### Changed + +- Router display now uses different characters to represent root and matchable nodes. ## [0.2.1] - 2024-09-04 diff --git a/README.md b/README.md index a5d1e2b5..1cfe5190 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,8 @@ fn main() -> Result<(), Box> { Routers can print their routes as an tree diagram. -`[*]` here represents nodes within the route tree that can be matched against. +- `▼` represents the root node. +- `●` represents nodes within the tree that can be matched against. Currenty, this doesn't handle split multi-byte characters well. @@ -236,27 +237,28 @@ use std::error::Error; use wayfind::Router; const ROUTER_DISPLAY: &str = " -$ -╰─ / - ├─ pet [*] - │ ╰─ / - │ ├─ findBy - │ │ ├─ Status [*] - │ │ ╰─ Tags [*] - │ ╰─ {petId} [*] - │ ╰─ /uploadImage [*] - ├─ store/ - │ ├─ inventory [*] - │ ╰─ order [*] - │ ╰─ / - │ ╰─ {orderId} [*] - ╰─ user [*] - ╰─ / - ├─ createWithList [*] - ├─ log - │ ├─ in [*] - │ ╰─ out [*] - ╰─ {username} [*] +▼ +├─ / +│ ├─ pet ● +│ │ ╰─ / +│ │ ├─ findBy +│ │ │ ├─ Status ● +│ │ │ ╰─ Tags ● +│ │ ╰─ {petId} ● +│ │ ╰─ /uploadImage ● +│ ├─ store/ +│ │ ├─ inventory ● +│ │ ╰─ order ● +│ │ ╰─ / +│ │ ╰─ {orderId} ● +│ ╰─ user ● +│ ╰─ / +│ ├─ createWithList ● +│ ├─ log +│ │ ├─ in ● +│ │ ╰─ out ● +│ ╰─ {username} ● +╰─ {*catch_all} ● "; fn main() -> Result<(), Box> { @@ -278,7 +280,9 @@ fn main() -> Result<(), Box> { router.insert("/user/logout", 12)?; router.insert("/user/{username}", 13)?; - assert_eq!(router.to_string(), ROUTER_DISPLAY.trim_end()); + router.insert("{*catch_all}", 14)?; + + assert_eq!(router.to_string(), ROUTER_DISPLAY.trim()); Ok(()) } ``` diff --git a/src/node/display.rs b/src/node/display.rs index 87526d66..dbd081ec 100644 --- a/src/node/display.rs +++ b/src/node/display.rs @@ -13,7 +13,7 @@ impl Display for Node { ) -> std::fmt::Result { let constraint = node.constraint.as_ref().map(|c| String::from_utf8_lossy(c)); let key = match &node.kind { - NodeKind::Root => "$".to_string(), + NodeKind::Root => "▼".to_string(), NodeKind::Static => String::from_utf8_lossy(&node.prefix).to_string(), NodeKind::Dynamic => { let name = String::from_utf8_lossy(&node.prefix); @@ -31,16 +31,15 @@ impl Display for Node { } }; - let value = node - .data - .as_ref() - .map_or(String::new(), |_node_data| " [*]".to_string()); - if is_root { writeln!(output, "{key}")?; } else { let branch = if is_last { "╰─" } else { "├─" }; - writeln!(output, "{padding}{branch} {key}{value}")?; + if node.data.is_some() { + writeln!(output, "{padding}{branch} {key} ●")?; + } else { + writeln!(output, "{padding}{branch} {key}")?; + } } // Ensure we align children correctly @@ -79,6 +78,6 @@ impl Display for Node { }; debug_node(&mut output, self, &padding, true, true)?; - write!(f, "\n{}", output.trim_end()) + write!(f, "{}", output.trim_end()) } } diff --git a/tests/constraints.rs b/tests/constraints.rs index 70322ca3..bf0551aa 100644 --- a/tests/constraints.rs +++ b/tests/constraints.rs @@ -76,21 +76,21 @@ fn test_multiple_constraints() -> Result<(), Box> { router.insert("/posts/{year:even_year}/{slug:valid_slug}", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ p │ ├─ osts/ │ │ ╰─ {year:even_year} │ │ ╰─ / - │ │ ╰─ {slug:valid_slug} [*] + │ │ ╰─ {slug:valid_slug} ● │ ╰─ rofile/ │ ╰─ {username:length_3_to_10} │ ╰─ . - │ ╰─ {ext:png_or_jpg} [*] + │ ╰─ {ext:png_or_jpg} ● ╰─ user/ ╰─ {name:length_3_to_10} ╰─ / - ╰─ {id:year_1000_to_10000} [*] + ╰─ {id:year_1000_to_10000} ● "###); assert_router_matches!(router, { diff --git a/tests/matchit_delete.rs b/tests/matchit_delete.rs index 2304e2aa..faa8f288 100644 --- a/tests/matchit_delete.rs +++ b/tests/matchit_delete.rs @@ -25,40 +25,40 @@ fn normalized() -> Result<(), Box> { router.insert("/s/s/{y}/d", 13)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ s [*] - │ ╰─ /s [*] + ├─ s ● + │ ╰─ /s ● │ ╰─ / - │ ├─ s [*] - │ │ ╰─ /s [*] + │ ├─ s ● + │ │ ╰─ /s ● │ ├─ {s} - │ │ ╰─ /x [*] + │ │ ╰─ /x ● │ ╰─ {y} - │ ╰─ /d [*] + │ ╰─ /d ● ├─ x/ │ ├─ {bar} - │ │ ╰─ /baz [*] + │ │ ╰─ /baz ● │ ╰─ {foo} - │ ╰─ /bar [*] + │ ╰─ /bar ● ├─ {bar} │ ╰─ / │ ╰─ {bay} - │ ╰─ /bay [*] + │ ╰─ /bay ● ├─ {fod} │ ╰─ / - │ ├─ baz/bax/foo [*] + │ ├─ baz/bax/foo ● │ ╰─ {baz} │ ╰─ / │ ╰─ {bax} - │ ╰─ /foo [*] + │ ╰─ /foo ● ╰─ {foo} ╰─ / - ├─ baz/bax [*] + ├─ baz/bax ● ├─ {bar} - │ ╰─ /baz [*] + │ ╰─ /baz ● ╰─ {baz} - ╰─ /bax [*] + ╰─ /bax ● "###); assert_eq!(router.delete("/x/{foo}/bar"), Ok(())); @@ -76,9 +76,7 @@ fn normalized() -> Result<(), Box> { assert_eq!(router.delete("/s/s/{s}/x"), Ok(())); assert_eq!(router.delete("/s/s/{y}/d"), Ok(())); - insta::assert_snapshot!(router, @r###" - $ - "###); + insta::assert_snapshot!(router, @"▼"); Ok(()) } @@ -90,10 +88,10 @@ fn test() -> Result<(), Box> { router.insert("/home/{id}", 1)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /home [*] + ▼ + ╰─ /home ● ╰─ / - ╰─ {id} [*] + ╰─ {id} ● "###); assert_eq!(router.delete("/home"), Ok(())); @@ -116,9 +114,7 @@ fn test() -> Result<(), Box> { The specified path does not exist in the router "###); - insta::assert_snapshot!(router, @r###" - $ - "###); + insta::assert_snapshot!(router, @"▼"); Ok(()) } @@ -134,20 +130,20 @@ fn blog() -> Result<(), Box> { router.insert("/favicon.ico", 5)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ favicon.ico [*] + ├─ favicon.ico ● ├─ posts/ │ ╰─ {year} │ ╰─ / - │ ├─ top [*] + │ ├─ top ● │ ╰─ {month} │ ╰─ / - │ ├─ index [*] - │ ╰─ {post} [*] + │ ├─ index ● + │ ╰─ {post} ● ├─ static/ - │ ╰─ {*path} [*] - ╰─ {page} [*] + │ ╰─ {*path} ● + ╰─ {page} ● "###); assert_eq!(router.delete("/{page}"), Ok(())); @@ -157,9 +153,7 @@ fn blog() -> Result<(), Box> { assert_eq!(router.delete("/static/{*path}"), Ok(())); assert_eq!(router.delete("/favicon.ico"), Ok(())); - insta::assert_snapshot!(router, @r###" - $ - "###); + insta::assert_snapshot!(router, @"▼"); Ok(()) } @@ -173,46 +167,46 @@ fn catchall() -> Result<(), Box> { router.insert("/bar/{*catchall}", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ bar [*] - │ ╰─ / [*] - │ ╰─ {*catchall} [*] + ├─ bar ● + │ ╰─ / ● + │ ╰─ {*catchall} ● ╰─ foo/ - ╰─ {*catchall} [*] + ╰─ {*catchall} ● "###); assert_eq!(router.delete("/foo/{*catchall}"), Ok(())); assert_eq!(router.delete("/bar/"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ╰─ bar [*] + ╰─ bar ● ╰─ / - ╰─ {*catchall} [*] + ╰─ {*catchall} ● "###); router.insert("/foo/{*catchall}", 4)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ bar [*] + ├─ bar ● │ ╰─ / - │ ╰─ {*catchall} [*] + │ ╰─ {*catchall} ● ╰─ foo/ - ╰─ {*catchall} [*] + ╰─ {*catchall} ● "###); assert_eq!(router.delete("/bar/{*catchall}"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ bar [*] + ├─ bar ● ╰─ foo/ - ╰─ {*catchall} [*] + ╰─ {*catchall} ● "###); Ok(()) @@ -232,394 +226,394 @@ fn overlapping_routes() -> Result<(), Box> { router.insert("/articles/{category}/{id}", 8)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/home"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ├─ home │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/home", 9)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/home/{id}"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] - ╰─ users [*] + │ ╰─ {id} ● + ├─ home ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/home/{id}", 10)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/users"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ users ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/users", 11)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/users/{id}"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / ╰─ {id} - ╰─ /posts [*] + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/users/{id}", 12)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/users/{id}/posts"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] + ╰─ {id} ● ╰─ /posts ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/users/{id}/posts", 13)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/users/{id}/posts/{post_id}"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● "###); router.insert("/users/{id}/posts/{post_id}", 14)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/articles"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ articles │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/articles", 15)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/articles/{category}"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / │ ╰─ {category} │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/articles/{category}", 16)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); assert_eq!(router.delete("/articles/{category}/{id}"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] - ├─ home [*] + │ ╰─ {category} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); router.insert("/articles/{category}/{id}", 17)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ articles [*] + ├─ articles ● │ ╰─ / - │ ╰─ {category} [*] + │ ╰─ {category} ● │ ╰─ / - │ ╰─ {id} [*] - ├─ home [*] + │ ╰─ {id} ● + ├─ home ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ users [*] + │ ╰─ {id} ● + ╰─ users ● ╰─ / - ╰─ {id} [*] - ╰─ /posts [*] + ╰─ {id} ● + ╰─ /posts ● ╰─ / - ╰─ {post_id} [*] + ╰─ {post_id} ● "###); Ok(()) @@ -632,11 +626,11 @@ fn trailing_slash() -> Result<(), Box> { router.insert("/foo", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ foo [*] + ├─ foo ● ╰─ {home} - ╰─ / [*] + ╰─ / ● "###); let error = router.delete("/").unwrap_err(); @@ -649,11 +643,11 @@ fn trailing_slash() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ foo [*] + ├─ foo ● ╰─ {home} - ╰─ / [*] + ╰─ / ● "###); let error = router.delete("/{home}").unwrap_err(); @@ -666,11 +660,11 @@ fn trailing_slash() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ foo [*] + ├─ foo ● ╰─ {home} - ╰─ / [*] + ╰─ / ● "###); let error = router.delete("/foo/").unwrap_err(); @@ -683,20 +677,20 @@ fn trailing_slash() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ foo [*] + ├─ foo ● ╰─ {home} - ╰─ / [*] + ╰─ / ● "###); assert_eq!(router.delete("/foo"), Ok(())); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ╰─ {home} - ╰─ / [*] + ╰─ / ● "###); let error = router.delete("/{home}").unwrap_err(); @@ -709,17 +703,15 @@ fn trailing_slash() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ╰─ {home} - ╰─ / [*] + ╰─ / ● "###); assert_eq!(router.delete("/{home}/"), Ok(())); - insta::assert_snapshot!(router, @r###" - $ - "###); + insta::assert_snapshot!(router, @"▼"); Ok(()) } @@ -730,15 +722,13 @@ fn remove_root() -> Result<(), Box> { router.insert("/", 0)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● "###); assert_eq!(router.delete("/"), Ok(())); - insta::assert_snapshot!(router, @r###" - $ - "###); + insta::assert_snapshot!(router, @"▼"); Ok(()) } @@ -753,23 +743,23 @@ fn check_escaped_params() -> Result<(), Box> { router.insert("/baz/{product}/{user}/{id}", 4)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ ba │ ├─ r/ │ │ ╰─ {user} │ │ ╰─ / - │ │ ╰─ {id} [*] - │ │ ╰─ /baz [*] + │ │ ╰─ {id} ● + │ │ ╰─ /baz ● │ ╰─ z/ │ ╰─ {product} │ ╰─ / │ ╰─ {user} │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ foo/ - ╰─ {id} [*] - ╰─ /bar [*] + ╰─ {id} ● + ╰─ /bar ● "###); let error = router.delete("/foo/{a}").unwrap_err(); @@ -782,23 +772,23 @@ fn check_escaped_params() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ ba │ ├─ r/ │ │ ╰─ {user} │ │ ╰─ / - │ │ ╰─ {id} [*] - │ │ ╰─ /baz [*] + │ │ ╰─ {id} ● + │ │ ╰─ /baz ● │ ╰─ z/ │ ╰─ {product} │ ╰─ / │ ╰─ {user} │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ foo/ - ╰─ {id} [*] - ╰─ /bar [*] + ╰─ {id} ● + ╰─ /bar ● "###); let error = router.delete("/foo/{a}/bar").unwrap_err(); @@ -811,23 +801,23 @@ fn check_escaped_params() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ ba │ ├─ r/ │ │ ╰─ {user} │ │ ╰─ / - │ │ ╰─ {id} [*] - │ │ ╰─ /baz [*] + │ │ ╰─ {id} ● + │ │ ╰─ /baz ● │ ╰─ z/ │ ╰─ {product} │ ╰─ / │ ╰─ {user} │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ foo/ - ╰─ {id} [*] - ╰─ /bar [*] + ╰─ {id} ● + ╰─ /bar ● "###); let error = router.delete("/bar/{a}/{b}").unwrap_err(); @@ -840,23 +830,23 @@ fn check_escaped_params() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ ba │ ├─ r/ │ │ ╰─ {user} │ │ ╰─ / - │ │ ╰─ {id} [*] - │ │ ╰─ /baz [*] + │ │ ╰─ {id} ● + │ │ ╰─ /baz ● │ ╰─ z/ │ ╰─ {product} │ ╰─ / │ ╰─ {user} │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ foo/ - ╰─ {id} [*] - ╰─ /bar [*] + ╰─ {id} ● + ╰─ /bar ● "###); let error = router.delete("/bar/{a}/{b}/baz").unwrap_err(); @@ -869,23 +859,23 @@ fn check_escaped_params() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ ba │ ├─ r/ │ │ ╰─ {user} │ │ ╰─ / - │ │ ╰─ {id} [*] - │ │ ╰─ /baz [*] + │ │ ╰─ {id} ● + │ │ ╰─ /baz ● │ ╰─ z/ │ ╰─ {product} │ ╰─ / │ ╰─ {user} │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ foo/ - ╰─ {id} [*] - ╰─ /bar [*] + ╰─ {id} ● + ╰─ /bar ● "###); let error = router.delete("/baz/{a}/{b}/{c}").unwrap_err(); @@ -898,23 +888,23 @@ fn check_escaped_params() -> Result<(), Box> { "###); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ ba │ ├─ r/ │ │ ╰─ {user} │ │ ╰─ / - │ │ ╰─ {id} [*] - │ │ ╰─ /baz [*] + │ │ ╰─ {id} ● + │ │ ╰─ /baz ● │ ╰─ z/ │ ╰─ {product} │ ╰─ / │ ╰─ {user} │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ╰─ foo/ - ╰─ {id} [*] - ╰─ /bar [*] + ╰─ {id} ● + ╰─ /bar ● "###); Ok(()) diff --git a/tests/matchit_matches.rs b/tests/matchit_matches.rs index 4775091e..dbf2dbe3 100644 --- a/tests/matchit_matches.rs +++ b/tests/matchit_matches.rs @@ -17,10 +17,10 @@ fn partial_overlap() -> Result<(), Box> { router.insert("/foo/bar", "Welcome!")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /foo - ├─ /bar [*] - ╰─ _bar [*] + ├─ /bar ● + ╰─ _bar ● "###); assert_router_matches!(router, { @@ -32,9 +32,9 @@ fn partial_overlap() -> Result<(), Box> { router.insert("/foo/bar", "Welcome!")?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /foo [*] - ╰─ /bar [*] + ▼ + ╰─ /foo ● + ╰─ /bar ● "###); assert_router_matches!(router, { @@ -52,10 +52,10 @@ fn wildcard_overlap() -> Result<(), Box> { router.insert("/path/{*rest}", "wildcard")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /path/ - ├─ foo [*] - ╰─ {*rest} [*] + ├─ foo ● + ╰─ {*rest} ● "###); assert_router_matches!(router, { @@ -84,11 +84,11 @@ fn wildcard_overlap() -> Result<(), Box> { router.insert("/path/{*rest}", "wildcard")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /path/ ├─ foo/ - │ ╰─ {arg} [*] - ╰─ {*rest} [*] + │ ╰─ {arg} ● + ╰─ {*rest} ● "###); assert_router_matches!(router, { @@ -126,14 +126,14 @@ fn overlapping_param_backtracking() -> Result<(), Box> { router.insert("/secret/{id}/path", "secret with id and path")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ secret/ │ ╰─ {id} - │ ╰─ /path [*] + │ ╰─ /path ● ╰─ {object} ╰─ / - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, { @@ -173,10 +173,10 @@ fn bare_catchall() -> Result<(), Box> { router.insert("foo/{*bar}", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ├─ foo/ - │ ╰─ {*bar} [*] - ╰─ {*foo} [*] + │ ╰─ {*bar} ● + ╰─ {*foo} ● "###); assert_router_matches!(router, { @@ -232,40 +232,40 @@ fn normalized() -> Result<(), Box> { router.insert("/s/s/{y}/d", 14)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ s [*] - │ ╰─ /s [*] + ├─ s ● + │ ╰─ /s ● │ ╰─ / - │ ├─ s [*] - │ │ ╰─ /s [*] + │ ├─ s ● + │ │ ╰─ /s ● │ ├─ {s} - │ │ ╰─ /x [*] + │ │ ╰─ /x ● │ ╰─ {y} - │ ╰─ /d [*] + │ ╰─ /d ● ├─ x/ │ ├─ {bar} - │ │ ╰─ /baz [*] + │ │ ╰─ /baz ● │ ╰─ {foo} - │ ╰─ /bar [*] + │ ╰─ /bar ● ├─ {bar} │ ╰─ / │ ╰─ {bay} - │ ╰─ /bay [*] + │ ╰─ /bay ● ├─ {fod} │ ╰─ / - │ ├─ baz/bax/foo [*] + │ ├─ baz/bax/foo ● │ ╰─ {baz} │ ╰─ / │ ╰─ {bax} - │ ╰─ /foo [*] + │ ╰─ /foo ● ╰─ {foo} ╰─ / - ├─ baz/bax [*] + ├─ baz/bax ● ├─ {bar} - │ ╰─ /baz [*] + │ ╰─ /baz ● ╰─ {baz} - ╰─ /bax [*] + ╰─ /bax ● "###); assert_router_matches!(router, { @@ -384,20 +384,20 @@ fn blog() -> Result<(), Box> { router.insert("/favicon.ico", 6)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ favicon.ico [*] + ├─ favicon.ico ● ├─ posts/ │ ╰─ {year} │ ╰─ / - │ ├─ top [*] + │ ├─ top ● │ ╰─ {month} │ ╰─ / - │ ├─ index [*] - │ ╰─ {post} [*] + │ ├─ index ● + │ ╰─ {post} ● ├─ static/ - │ ╰─ {*path} [*] - ╰─ {page} [*] + │ ╰─ {*path} ● + ╰─ {page} ● "###); assert_router_matches!(router, { @@ -460,24 +460,24 @@ fn double_overlap() -> Result<(), Box> { router.insert("/other/long/static/path/", 7)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ other/ │ ├─ an_object/ - │ │ ╰─ {id} [*] - │ ├─ long/static/path/ [*] - │ ├─ static/path [*] + │ │ ╰─ {id} ● + │ ├─ long/static/path/ ● + │ ├─ static/path ● │ ╰─ {object} │ ╰─ / │ ╰─ {id} - │ ╰─ / [*] + │ ╰─ / ● ├─ secret/ - │ ├─ 978 [*] + │ ├─ 978 ● │ ╰─ {id} - │ ╰─ /path [*] + │ ╰─ /path ● ╰─ {object} ╰─ / - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, { @@ -539,13 +539,13 @@ fn catchall_off_by_one() -> Result<(), Box> { router.insert("/bar/{*catchall}", 4)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ bar [*] - │ ╰─ / [*] - │ ╰─ {*catchall} [*] + ├─ bar ● + │ ╰─ / ● + │ ╰─ {*catchall} ● ╰─ foo/ - ╰─ {*catchall} [*] + ╰─ {*catchall} ● "###); assert_router_matches!(router, { @@ -593,18 +593,18 @@ fn overlap() -> Result<(), Box> { router.insert("/xxx/", 10)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ ba - │ ├─ r [*] - │ ╰─ z [*] - │ ╰─ / [*] - │ ├─ x [*] - │ ╰─ {xxx} [*] - ├─ foo [*] - ├─ xxx/ [*] - │ ╰─ {*x} [*] - ╰─ {*bar} [*] + │ ├─ r ● + │ ╰─ z ● + │ ╰─ / ● + │ ├─ x ● + │ ╰─ {xxx} ● + ├─ foo ● + ├─ xxx/ ● + │ ╰─ {*x} ● + ╰─ {*bar} ● "###); assert_router_matches!(router, { @@ -671,13 +671,13 @@ fn missing_trailing_slash_param() -> Result<(), Box> { router.insert("/foo/secret/978/", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /foo/ - ├─ bar/baz [*] - ├─ secret/978/ [*] + ├─ bar/baz ● + ├─ secret/978/ ● ╰─ {object} ╰─ / - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, { @@ -706,13 +706,13 @@ fn extra_trailing_slash_param() -> Result<(), Box> { router.insert("/foo/secret/978", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /foo/ - ├─ bar/baz [*] - ├─ secret/978 [*] + ├─ bar/baz ● + ├─ secret/978 ● ╰─ {object} ╰─ / - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, { @@ -734,11 +734,11 @@ fn missing_trailing_slash_catch_all() -> Result<(), Box> { router.insert("/foo/secret/978/", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /foo/ - ├─ bar/baz [*] - ├─ secret/978/ [*] - ╰─ {*bar} [*] + ├─ bar/baz ● + ├─ secret/978/ ● + ╰─ {*bar} ● "###); assert_router_matches!(router, { @@ -766,11 +766,11 @@ fn extra_trailing_slash_catch_all() -> Result<(), Box> { router.insert("/foo/secret/978", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /foo/ - ├─ bar/baz [*] - ├─ secret/978 [*] - ╰─ {*bar} [*] + ├─ bar/baz ● + ├─ secret/978 ● + ╰─ {*bar} ● "###); assert_router_matches!(router, { @@ -802,24 +802,24 @@ fn double_overlap_trailing_slash() -> Result<(), Box> { router.insert("/other/long/static/path/", 7)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ other/ │ ├─ an_object/ - │ │ ╰─ {id} [*] - │ ├─ long/static/path/ [*] - │ ├─ static/path [*] + │ │ ╰─ {id} ● + │ ├─ long/static/path/ ● + │ ├─ static/path ● │ ╰─ {object} │ ╰─ / │ ╰─ {id} - │ ╰─ / [*] + │ ╰─ / ● ├─ secret/ - │ ├─ 978/ [*] + │ ├─ 978/ ● │ ╰─ {id} - │ ╰─ /path [*] + │ ╰─ /path ● ╰─ {object} ╰─ / - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, { @@ -859,12 +859,12 @@ fn trailing_slash_overlap() -> Result<(), Box> { router.insert("/foo/bar/bar", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /foo/ - ├─ bar/bar [*] + ├─ bar/bar ● ╰─ {x} - ╰─ /baz [*] - ╰─ / [*] + ╰─ /baz ● + ╰─ / ● "###); assert_router_matches!(router, { @@ -927,61 +927,61 @@ fn trailing_slash() -> Result<(), Box> { router.insert("/foo/{p}", 31)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ 0/ - │ ╰─ {id} [*] - │ ╰─ /1 [*] + │ ╰─ {id} ● + │ ╰─ /1 ● ├─ 1/ │ ╰─ {id} - │ ╰─ / [*] - │ ╰─ 2 [*] + │ ╰─ / ● + │ ╰─ 2 ● ├─ a - │ ├─ / [*] - │ ├─ a [*] - │ ├─ dmin [*] + │ ├─ / ● + │ ├─ a ● + │ ├─ dmin ● │ │ ╰─ / - │ │ ├─ static [*] - │ │ ╰─ {category} [*] + │ │ ├─ static ● + │ │ ╰─ {category} ● │ │ ╰─ / - │ │ ╰─ {page} [*] + │ │ ╰─ {page} ● │ ╰─ pi/ │ ├─ ba │ │ ├─ r/ - │ │ │ ╰─ {name} [*] - │ │ ╰─ z/foo [*] - │ │ ╰─ /bar [*] + │ │ │ ╰─ {name} ● + │ │ ╰─ z/foo ● + │ │ ╰─ /bar ● │ ├─ hello/ │ │ ╰─ {name} - │ │ ╰─ /bar/ [*] + │ │ ╰─ /bar/ ● │ ╰─ {page} │ ╰─ / - │ ╰─ {name} [*] - ├─ b/ [*] + │ ╰─ {name} ● + ├─ b/ ● ├─ cmd/ │ ╰─ {tool} - │ ╰─ / [*] - ├─ doc [*] + │ ╰─ / ● + ├─ doc ● │ ╰─ /rust - │ ├─ 1.26.html [*] - │ ╰─ _faq.html [*] + │ ├─ 1.26.html ● + │ ╰─ _faq.html ● ├─ foo/ - │ ╰─ {p} [*] - ├─ hi [*] + │ ╰─ {p} ● + ├─ hi ● ├─ no/ - │ ├─ a [*] + │ ├─ a ● │ │ ╰─ /b/ - │ │ ╰─ {*other} [*] - │ ╰─ b [*] + │ │ ╰─ {*other} ● + │ ╰─ b ● ├─ s │ ├─ earch/ - │ │ ╰─ {query} [*] + │ │ ╰─ {query} ● │ ╰─ rc/ - │ ╰─ {*filepath} [*] - ├─ x [*] - │ ╰─ /y [*] - ╰─ y/ [*] - ╰─ z [*] + │ ╰─ {*filepath} ● + ├─ x ● + │ ╰─ /y ● + ╰─ y/ ● + ╰─ z ● "###); assert_router_matches!(router, { @@ -1032,14 +1032,14 @@ fn backtracking_trailing_slash() -> Result<(), Box> { router.insert("/a/b/{c}/d/", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ ├─ b/ │ ╰─ {c} - │ ╰─ /d/ [*] + │ ╰─ /d/ ● ╰─ {b} ╰─ / - ╰─ {c} [*] + ╰─ {c} ● "###); assert_router_matches!(router, { @@ -1057,11 +1057,11 @@ fn root_trailing_slash() -> Result<(), Box> { router.insert("/{baz}", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ bar [*] - ├─ foo [*] - ╰─ {baz} [*] + ├─ bar ● + ├─ foo ● + ╰─ {baz} ● "###); assert_router_matches!(router, { @@ -1078,11 +1078,11 @@ fn catchall_overlap() -> Result<(), Box> { router.insert("/yyy{*x}", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /yyy ├─ / - │ ╰─ {*x} [*] - ╰─ {*x} [*] + │ ╰─ {*x} ● + ╰─ {*x} ● "###); assert_router_matches!(router, { @@ -1126,23 +1126,23 @@ fn escaped() -> Result<(), Box> { // router.insert("/xxx/{x}}{{}}}}{{}}{{{{}}y}", 16)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ baz/ - │ ╰─ {xxx} [*] + │ ╰─ {xxx} ● │ ╰─ / - │ ├─ xy{ [*] - │ ╰─ }xy{{ [*] + │ ├─ xy{ ● + │ ╰─ }xy{{ ● ├─ x - │ ├─ xx/ [*] - │ ╰─ y{ [*] - ├─ { [*] + │ ├─ xx/ ● + │ ╰─ y{ ● + ├─ { ● │ ├─ / - │ │ ├─ xyz [*] - │ │ ╰─ {x} [*] - │ ╰─ x [*] - ╰─ } [*] - ╰─ y{ [*] + │ │ ├─ xyz ● + │ │ ╰─ {x} ● + │ ╰─ x ● + ╰─ } ● + ╰─ y{ ● "###); assert_router_matches!(router, { @@ -1280,31 +1280,31 @@ fn basic() -> Result<(), Box> { router.insert("/sd=here", 21)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ├─ / - │ ├─ a [*] - │ │ ╰─ b [*] - │ ├─ c [*] - │ │ ╰─ o [*] - │ │ ╰─ ntact [*] - │ ├─ doc/ [*] + │ ├─ a ● + │ │ ╰─ b ● + │ ├─ c ● + │ │ ╰─ o ● + │ │ ╰─ ntact ● + │ ├─ doc/ ● │ │ ╰─ rust - │ │ ├─ 1.26.html [*] - │ │ ╰─ _faq.html [*] - │ ├─ hi [*] + │ │ ├─ 1.26.html ● + │ │ ╰─ _faq.html ● + │ ├─ hi ● │ ╰─ sd - │ ├─ !here [*] - │ ├─ $here [*] - │ ├─ &here [*] - │ ├─ 'here [*] - │ ├─ (here [*] - │ ├─ )here [*] - │ ├─ +here [*] - │ ├─ ,here [*] - │ ├─ ;here [*] - │ ╰─ =here [*] - ├─ ʯ [*] - ╰─ β [*] + │ ├─ !here ● + │ ├─ $here ● + │ ├─ &here ● + │ ├─ 'here ● + │ ├─ (here ● + │ ├─ )here ● + │ ├─ +here ● + │ ├─ ,here ● + │ ├─ ;here ● + │ ╰─ =here ● + ├─ ʯ ● + ╰─ β ● "###); assert_router_matches!(router, { @@ -1446,110 +1446,110 @@ fn wildcard() -> Result<(), Box> { router.insert("/get/abc/123abfff/{param}", 56)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ a │ ├─ a/ - │ │ ╰─ {*xx} [*] + │ │ ╰─ {*xx} ● │ ╰─ b/ │ ├─ hello - │ │ ╰─ {*xx} [*] - │ ╰─ {*xx} [*] + │ │ ╰─ {*xx} ● + │ ╰─ {*xx} ● ├─ c │ ├─ 1/ │ │ ╰─ {dd} - │ │ ╰─ /e [*] - │ │ ╰─ 1 [*] + │ │ ╰─ /e ● + │ │ ╰─ 1 ● │ ╰─ md/ - │ ├─ whoami [*] - │ │ ╰─ /root [*] - │ │ ╰─ / [*] + │ ├─ whoami ● + │ │ ╰─ /root ● + │ │ ╰─ / ● │ ├─ {tool} - │ │ ╰─ / [*] + │ │ ╰─ / ● │ ╰─ {tool2} │ ╰─ / - │ ╰─ {sub} [*] - ├─ doc/ [*] + │ ╰─ {sub} ● + ├─ doc/ ● │ ╰─ rust - │ ├─ 1.26.html [*] - │ ╰─ _faq.html [*] + │ ├─ 1.26.html ● + │ ╰─ _faq.html ● ├─ files/ │ ╰─ {dir} │ ╰─ / - │ ╰─ {*filepath} [*] + │ ╰─ {*filepath} ● ├─ get/ - │ ├─ abc [*] + │ ├─ abc ● │ │ ╰─ / │ │ ├─ 123 │ │ │ ├─ / - │ │ │ │ ╰─ {param} [*] + │ │ │ │ ╰─ {param} ● │ │ │ ╰─ ab - │ │ │ ├─ c [*] + │ │ │ ├─ c ● │ │ │ │ ╰─ / - │ │ │ │ ├─ xxx8 [*] + │ │ │ │ ├─ xxx8 ● │ │ │ │ │ ╰─ / - │ │ │ │ │ ├─ 1234 [*] + │ │ │ │ │ ├─ 1234 ● │ │ │ │ │ │ ╰─ / - │ │ │ │ │ │ ├─ ffas [*] + │ │ │ │ │ │ ├─ ffas ● │ │ │ │ │ │ ├─ kkdd/ - │ │ │ │ │ │ │ ├─ 12c [*] - │ │ │ │ │ │ │ ╰─ {param} [*] - │ │ │ │ │ │ ╰─ {param} [*] - │ │ │ │ │ ╰─ {param} [*] - │ │ │ │ ╰─ {param} [*] + │ │ │ │ │ │ │ ├─ 12c ● + │ │ │ │ │ │ │ ╰─ {param} ● + │ │ │ │ │ │ ╰─ {param} ● + │ │ │ │ │ ╰─ {param} ● + │ │ │ │ ╰─ {param} ● │ │ │ ├─ d │ │ │ │ ├─ / - │ │ │ │ │ ╰─ {param} [*] + │ │ │ │ │ ╰─ {param} ● │ │ │ │ ╰─ dd/ - │ │ │ │ ╰─ {param} [*] + │ │ │ │ ╰─ {param} ● │ │ │ ├─ f │ │ │ │ ├─ / - │ │ │ │ │ ╰─ {param} [*] + │ │ │ │ │ ╰─ {param} ● │ │ │ │ ╰─ ff/ - │ │ │ │ ╰─ {param} [*] + │ │ │ │ ╰─ {param} ● │ │ │ ╰─ g/ - │ │ │ ╰─ {param} [*] - │ │ ╰─ {param} [*] - │ │ ╰─ /test [*] - │ ├─ test/abc/ [*] - │ ╰─ {param} [*] - │ ╰─ /abc/ [*] + │ │ │ ╰─ {param} ● + │ │ ╰─ {param} ● + │ │ ╰─ /test ● + │ ├─ test/abc/ ● + │ ╰─ {param} ● + │ ╰─ /abc/ ● ├─ info/ │ ╰─ {user} │ ╰─ /p │ ├─ roject/ - │ │ ├─ rustlang [*] - │ │ ╰─ {project} [*] - │ ╰─ ublic [*] + │ │ ├─ rustlang ● + │ │ ╰─ {project} ● + │ ╰─ ublic ● ├─ s - │ ├─ earch/ [*] - │ │ ├─ actix-we [*] - │ │ ├─ google [*] - │ │ ╰─ {query} [*] + │ ├─ earch/ ● + │ │ ├─ actix-we ● + │ │ ├─ google ● + │ │ ╰─ {query} ● │ ├─ omething/ - │ │ ├─ secondthing/test [*] + │ │ ├─ secondthing/test ● │ │ ╰─ {paramname} - │ │ ╰─ /thirdthing [*] - │ ╰─ rc [*] - │ ╰─ / [*] - │ ╰─ {*filepath} [*] + │ │ ╰─ /thirdthing ● + │ ╰─ rc ● + │ ╰─ / ● + │ ╰─ {*filepath} ● ├─ user_ - │ ╰─ {name} [*] - │ ╰─ /about [*] - ╰─ {cc} [*] + │ ╰─ {name} ● + │ ╰─ /about ● + ╰─ {cc} ● ╰─ / - ├─ cc [*] + ├─ cc ● ╰─ {dd} ╰─ / - ├─ ee [*] + ├─ ee ● ╰─ {ee} ╰─ / - ├─ ff [*] + ├─ ff ● ╰─ {ff} ╰─ / - ├─ gg [*] + ├─ gg ● ╰─ {gg} - ╰─ /hh [*] + ╰─ /hh ● "###); assert_router_matches!(router, { diff --git a/tests/path_tree.rs b/tests/path_tree.rs index 63a4f9a1..fff1ce56 100644 --- a/tests/path_tree.rs +++ b/tests/path_tree.rs @@ -26,21 +26,21 @@ fn statics() -> Result<(), Box> { router.insert("/β", 11)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] - ├─ a [*] - │ ╰─ b [*] - ├─ c [*] - │ ╰─ o [*] - │ ╰─ ntact [*] - ├─ doc/ [*] + ▼ + ╰─ / ● + ├─ a ● + │ ╰─ b ● + ├─ c ● + │ ╰─ o ● + │ ╰─ ntact ● + ├─ doc/ ● │ ╰─ go - │ ├─ 1.html [*] - │ ╰─ _faq.html [*] - ├─ hi [*] + │ ├─ 1.html ● + │ ╰─ _faq.html ● + ├─ hi ● ╰─ � - ├─ � [*] - ╰─ � [*] + ├─ � ● + ╰─ � ● "###); assert_router_matches!(router, { @@ -123,40 +123,40 @@ fn wildcards() -> Result<(), Box> { router.insert("/info/{user}/project/{project}", 19)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ cmd/ - │ ├─ vet [*] + │ ├─ vet ● │ ╰─ {tool} - │ ╰─ / [*] - │ ╰─ {sub} [*] - ├─ doc/ [*] + │ ╰─ / ● + │ ╰─ {sub} ● + ├─ doc/ ● │ ╰─ rust - │ ├─ 1.html [*] - │ ╰─ _faq.html [*] + │ ├─ 1.html ● + │ ╰─ _faq.html ● ├─ files/ │ ╰─ {dir} │ ╰─ / - │ ╰─ {*filepath} [*] + │ ╰─ {*filepath} ● ├─ info/ │ ╰─ {user} │ ╰─ /p │ ├─ roject/ - │ │ ╰─ {project} [*] - │ ╰─ ublic [*] + │ │ ╰─ {project} ● + │ ╰─ ublic ● ├─ s - │ ├─ earch/ [*] - │ │ ├─ invalid [*] - │ │ ╰─ {query} [*] + │ ├─ earch/ ● + │ │ ├─ invalid ● + │ │ ╰─ {query} ● │ ╰─ rc │ ├─ / - │ │ ╰─ {*filepath} [*] - │ ╰─ 1/ [*] - │ ╰─ {*filepath} [*] + │ │ ╰─ {*filepath} ● + │ ╰─ 1/ ● + │ ╰─ {*filepath} ● ╰─ user_ - ├─ x [*] - ╰─ {name} [*] - ╰─ /about [*] + ├─ x ● + ╰─ {name} ● + ╰─ /about ● "###); assert_router_matches!(router, { @@ -243,9 +243,9 @@ fn single_named_parameter() -> Result<(), Box> { router.insert("/users/{id}", 0)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /users/ - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, { @@ -305,15 +305,15 @@ fn static_and_named_parameter() -> Result<(), Box> { router.insert("/{id}/c/e", "/{id}/c/e")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ a/ - │ ├─ b/c [*] + │ ├─ b/c ● │ ╰─ c/ - │ ├─ a [*] - │ ╰─ d [*] + │ ├─ a ● + │ ╰─ d ● ╰─ {id} - ╰─ /c/e [*] + ╰─ /c/e ● "###); assert_router_matches!(router, { @@ -349,12 +349,12 @@ fn multi_named_parameters() -> Result<(), Box> { router.insert("/{id}", true)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ├─ {id} [*] + ├─ {id} ● ╰─ {lang} ╰─ / - ╰─ {keyword} [*] + ╰─ {keyword} ● "###); assert_router_matches!(router, { @@ -388,9 +388,9 @@ fn catch_all_parameter() -> Result<(), Box> { router.insert("/src/{*filepath}", "* files")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /src/ - ╰─ {*filepath} [*] + ╰─ {*filepath} ● "###); assert_router_matches!(router, { @@ -418,9 +418,9 @@ fn catch_all_parameter() -> Result<(), Box> { router.insert("/src/", "dir")?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /src/ [*] - ╰─ {*filepath} [*] + ▼ + ╰─ /src/ ● + ╰─ {*filepath} ● "###); assert_router_matches!(router, { @@ -522,13 +522,13 @@ fn static_and_catch_all_parameter() -> Result<(), Box> { router.insert("/a/{*c}", "/a/*c")?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ├─ b/c [*] + ├─ b/c ● ├─ c/ - │ ├─ a [*] - │ ╰─ d [*] - ╰─ {*c} [*] + │ ├─ a ● + │ ╰─ d ● + ╰─ {*c} ● "###); assert_router_matches!(router, { @@ -565,11 +565,11 @@ fn root_catch_all_parameter() -> Result<(), Box> { router.insert("/users/{*wildcard}", 3)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ users/ - │ ╰─ {*wildcard} [*] - ╰─ {*wildcard} [*] + │ ╰─ {*wildcard} ● + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -602,9 +602,9 @@ fn root_catch_all_parameter_1() -> Result<(), Box> { router.insert("/{*wildcard}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ╰─ {*wildcard} [*] + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -629,9 +629,9 @@ fn root_catch_all_parameter_1() -> Result<(), Box> { router.insert("/", 0)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] - ╰─ {*wildcard} [*] + ▼ + ╰─ / ● + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -652,12 +652,12 @@ fn test_named_routes_with_non_ascii_paths() -> Result<(), Box> { router.insert("/matchme/{slug}/", 2)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ matchme/ │ ╰─ {slug} - │ ╰─ / [*] - ╰─ {*wildcard} [*] + │ ╰─ / ● + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -701,12 +701,12 @@ fn test_named_wildcard_collide() -> Result<(), Box> { router.insert("/git/{*wildcard}", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /git/ ├─ {org} │ ╰─ / - │ ╰─ {repo} [*] - ╰─ {*wildcard} [*] + │ ╰─ {repo} ● + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -736,11 +736,11 @@ fn match_params() -> Result<(), Box> { router.insert("/api/v1/{param}/{*wildcard}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /api/v1/ ╰─ {param} ╰─ / - ╰─ {*wildcard} [*] + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -799,8 +799,8 @@ fn match_params() -> Result<(), Box> { router.insert("/v1/some/resource/name:customVerb", 1)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /v1/some/resource/name:customVerb [*] + ▼ + ╰─ /v1/some/resource/name:customVerb ● "###); assert_router_matches!(router, { @@ -815,10 +815,10 @@ fn match_params() -> Result<(), Box> { router.insert("/v1/some/resource/{name}:customVerb", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /v1/some/resource/ ╰─ {name} - ╰─ :customVerb [*] + ╰─ :customVerb ● "###); assert_router_matches!(router, { @@ -836,9 +836,9 @@ fn match_params() -> Result<(), Box> { router.insert("/api/v1/{*wildcard}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /api/v1/ - ╰─ {*wildcard} [*] + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -872,9 +872,9 @@ fn match_params() -> Result<(), Box> { router.insert("/api/v1/{param}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /api/v1/ - ╰─ {param} [*] + ╰─ {param} ● "###); assert_router_matches!(router, { @@ -900,21 +900,21 @@ fn match_params() -> Result<(), Box> { router.insert("/api/v1/{param}:{param2}", 6)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /api/v1/ ╰─ {param} ├─ - - │ ╰─ {param2} [*] + │ ╰─ {param2} ● ├─ . - │ ╰─ {param2} [*] + │ ╰─ {param2} ● ├─ / - │ ╰─ {param2} [*] + │ ╰─ {param2} ● ├─ : - │ ╰─ {param2} [*] + │ ╰─ {param2} ● ├─ _ - │ ╰─ {param2} [*] + │ ╰─ {param2} ● ╰─ ~ - ╰─ {param2} [*] + ╰─ {param2} ● "###); assert_router_matches!(router, { @@ -982,8 +982,8 @@ fn match_params() -> Result<(), Box> { router.insert("/api/v1/const", 1)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /api/v1/const [*] + ▼ + ╰─ /api/v1/const ● "###); assert_router_matches!(router, { @@ -1002,10 +1002,10 @@ fn match_params() -> Result<(), Box> { router.insert("/api/{param}/fixedEnd", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /api/ ╰─ {param} - ╰─ /fixedEnd [*] + ╰─ /fixedEnd ● "###); assert_router_matches!(router, { @@ -1023,13 +1023,13 @@ fn match_params() -> Result<(), Box> { router.insert("/shop/product/:{filter}/color:{color}/size:{size}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /shop/product/: ╰─ {filter} ╰─ /color: ╰─ {color} ╰─ /size: - ╰─ {size} [*] + ╰─ {size} ● "###); assert_router_matches!(router, { @@ -1049,10 +1049,10 @@ fn match_params() -> Result<(), Box> { router.insert("/test{sign}{param}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /test ╰─ {sign} - ╰─ {param} [*] + ╰─ {param} ● "###); assert_router_matches!(router, { @@ -1070,21 +1070,21 @@ fn match_params() -> Result<(), Box> { router.insert("/{name}", 7)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ - - │ ╰─ {name} [*] + │ ╰─ {name} ● ├─ . - │ ╰─ {name} [*] + │ ╰─ {name} ● ├─ @ - │ ╰─ {name} [*] + │ ╰─ {name} ● ├─ _ - │ ╰─ {name} [*] + │ ╰─ {name} ● ├─ name - │ ╰─ {name} [*] + │ ╰─ {name} ● ├─ ~ - │ ╰─ {name} [*] - ╰─ {name} [*] + │ ╰─ {name} ● + ╰─ {name} ● "###); assert_router_matches!(router, { @@ -1143,11 +1143,11 @@ fn match_params() -> Result<(), Box> { router.insert("/api/v1/{param}/abc/{*wildcard}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /api/v1/ ╰─ {param} ╰─ /abc/ - ╰─ {*wildcard} [*] + ╰─ {*wildcard} ● "###); assert_router_matches!(router, { @@ -1276,18 +1276,18 @@ fn basic() -> Result<(), Box> { router.insert("/api/{*plus}", 13)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] + ▼ + ╰─ / ● ├─ api/ - │ ╰─ {*plus} [*] - ├─ login [*] + │ ╰─ {*plus} ● + ├─ login ● ├─ public/ - │ ╰─ {*any} [*] + │ ╰─ {*any} ● ├─ s - │ ├─ ettings [*] + │ ├─ ettings ● │ │ ╰─ / - │ │ ╰─ {page} [*] - │ ╰─ ignup [*] + │ │ ╰─ {page} ● + │ ╰─ ignup ● ├─ {org} │ ╰─ / │ ╰─ {repo} @@ -1295,24 +1295,24 @@ fn basic() -> Result<(), Box> { │ ├─ actions/ │ │ ╰─ {name} │ │ ╰─ : - │ │ ╰─ {verb} [*] + │ │ ╰─ {verb} ● │ ├─ releases/download/ │ │ ╰─ {tag} │ │ ╰─ / │ │ ╰─ {filename} │ │ ╰─ . - │ │ ╰─ {ext} [*] + │ │ ╰─ {ext} ● │ ├─ tags/ │ │ ╰─ {day} │ │ ╰─ - │ │ ╰─ {month} │ │ ╰─ - - │ │ ╰─ {year} [*] - │ ├─ {page} [*] - │ ╰─ {*path} [*] - ╰─ {user} [*] + │ │ ╰─ {year} ● + │ ├─ {page} ● + │ ╰─ {*path} ● + ╰─ {user} ● ╰─ / - ╰─ {repo} [*] + ╰─ {repo} ● "###); assert_router_matches!(router, { @@ -1552,180 +1552,180 @@ fn github_tree() -> Result<(), Box> { )?; insta::assert_snapshot!(router, @r###" - $ - ╰─ / [*] - ├─ 404 [*] + ▼ + ╰─ / ● + ├─ 404 ● ├─ 50 - │ ├─ 0 [*] - │ ╰─ 3 [*] + │ ├─ 0 ● + │ ╰─ 3 ● ├─ a - │ ├─ bout [*] + │ ├─ bout ● │ │ ╰─ / - │ │ ├─ careers [*] - │ │ ├─ diversity [*] - │ │ ╰─ press [*] - │ ╰─ pi [*] + │ │ ├─ careers ● + │ │ ├─ diversity ● + │ │ ╰─ press ● + │ ╰─ pi ● ├─ c - │ ├─ ollections [*] - │ ╰─ ustomer-stories [*] + │ ├─ ollections ● + │ ╰─ ustomer-stories ● ├─ e - │ ├─ nterprise [*] - │ ╰─ xplore [*] - ├─ features [*] + │ ├─ nterprise ● + │ ╰─ xplore ● + ├─ features ● │ ╰─ / - │ ├─ actions [*] + │ ├─ actions ● │ ├─ co │ │ ├─ de - │ │ │ ├─ -review [*] - │ │ │ ╰─ spaces [*] - │ │ ╰─ pilot [*] - │ ├─ discussions [*] - │ ├─ issues [*] - │ ├─ packages [*] - │ ╰─ security [*] - ├─ issues [*] - ├─ login [*] - ├─ marketplace [*] - ├─ new [*] - │ ╰─ /import [*] + │ │ │ ├─ -review ● + │ │ │ ╰─ spaces ● + │ │ ╰─ pilot ● + │ ├─ discussions ● + │ ├─ issues ● + │ ├─ packages ● + │ ╰─ security ● + ├─ issues ● + ├─ login ● + ├─ marketplace ● + ├─ new ● + │ ╰─ /import ● ├─ organizations/ - │ ├─ new [*] - │ ╰─ plan [*] + │ ├─ new ● + │ ╰─ plan ● ├─ p - │ ├─ ricing [*] - │ ╰─ ulls [*] - ├─ readme [*] + │ ├─ ricing ● + │ ╰─ ulls ● + ├─ readme ● ├─ s │ ├─ e - │ │ ├─ arch [*] - │ │ ╰─ ttings [*] + │ │ ├─ arch ● + │ │ ╰─ ttings ● │ │ ╰─ / │ │ ├─ a - │ │ │ ├─ ccessibility [*] - │ │ │ ├─ dmin [*] + │ │ │ ├─ ccessibility ● + │ │ │ ├─ dmin ● │ │ │ ╰─ pp - │ │ │ ├─ earance [*] - │ │ │ ╰─ s [*] + │ │ │ ├─ earance ● + │ │ │ ╰─ s ● │ │ ├─ b - │ │ │ ├─ illing [*] - │ │ │ │ ╰─ /plans [*] - │ │ │ ╰─ locked_users [*] + │ │ │ ├─ illing ● + │ │ │ │ ╰─ /plans ● + │ │ │ ╰─ locked_users ● │ │ ├─ co │ │ │ ├─ de - │ │ │ │ ├─ _review_limits [*] - │ │ │ │ ╰─ spaces [*] - │ │ │ ╰─ pilot [*] + │ │ │ │ ├─ _review_limits ● + │ │ │ │ ╰─ spaces ● + │ │ │ ╰─ pilot ● │ │ ├─ de - │ │ │ ├─ leted_packages [*] - │ │ │ ╰─ velopers [*] + │ │ │ ├─ leted_packages ● + │ │ │ ╰─ velopers ● │ │ ├─ in - │ │ │ ├─ stallations [*] - │ │ │ ╰─ teraction_limits [*] - │ │ ├─ keys [*] - │ │ ├─ notifications [*] - │ │ ├─ organizations [*] - │ │ ├─ pages [*] + │ │ │ ├─ stallations ● + │ │ │ ╰─ teraction_limits ● + │ │ ├─ keys ● + │ │ ├─ notifications ● + │ │ ├─ organizations ● + │ │ ├─ pages ● │ │ ├─ re - │ │ │ ├─ minders [*] + │ │ │ ├─ minders ● │ │ │ ╰─ p - │ │ │ ├─ lies [*] - │ │ │ ╰─ ositories [*] + │ │ │ ├─ lies ● + │ │ │ ╰─ ositories ● │ │ ├─ s - │ │ │ ├─ ecurity [*] - │ │ │ │ ├─ -log [*] - │ │ │ │ ╰─ _analysis [*] - │ │ │ ╰─ ponsors-log [*] - │ │ ╰─ tokens [*] - │ ├─ ignup [*] - │ ╰─ ponsors [*] + │ │ │ ├─ ecurity ● + │ │ │ │ ├─ -log ● + │ │ │ │ ╰─ _analysis ● + │ │ │ ╰─ ponsors-log ● + │ │ ╰─ tokens ● + │ ├─ ignup ● + │ ╰─ ponsors ● │ ╰─ / - │ ├─ accounts [*] - │ ├─ explore [*] - │ ╰─ {repo} [*] + │ ├─ accounts ● + │ ├─ explore ● + │ ╰─ {repo} ● │ ╰─ / │ ├─ issues/ - │ │ ╰─ {*path} [*] - │ ├─ {user} [*] + │ │ ╰─ {*path} ● + │ ├─ {user} ● │ ├─ {*plus} │ │ ╰─ / - │ │ ├─ {file} [*] + │ │ ├─ {file} ● │ │ ╰─ {filename} │ │ ╰─ . - │ │ ╰─ {ext} [*] - │ ╰─ {*plus} [*] + │ │ ╰─ {ext} ● + │ ╰─ {*plus} ● ├─ t - │ ├─ eam [*] - │ ├─ opics [*] - │ ╰─ rending [*] - ╰─ {org} [*] + │ ├─ eam ● + │ ├─ opics ● + │ ╰─ rending ● + ╰─ {org} ● ╰─ / - ╰─ {repo} [*] + ╰─ {repo} ● ╰─ / - ├─ actions [*] + ├─ actions ● │ ╰─ / │ ├─ runs/ - │ │ ╰─ {id} [*] + │ │ ╰─ {id} ● │ ╰─ workflows/ - │ ╰─ {id} [*] + │ ╰─ {id} ● ├─ com │ ├─ m │ │ ├─ it/ - │ │ │ ╰─ {id} [*] - │ │ ╰─ unity [*] - │ ╰─ pare [*] - ├─ discussions [*] + │ │ │ ╰─ {id} ● + │ │ ╰─ unity ● + │ ╰─ pare ● + ├─ discussions ● │ ╰─ / - │ ╰─ {id} [*] + │ ╰─ {id} ● ├─ graphs/co - │ ├─ de-frequency [*] - │ ├─ mmit-activity [*] - │ ╰─ ntributors [*] - ├─ issues [*] + │ ├─ de-frequency ● + │ ├─ mmit-activity ● + │ ╰─ ntributors ● + ├─ issues ● │ ╰─ / - │ ├─ new [*] - │ ╰─ {id} [*] - ├─ network [*] + │ ├─ new ● + │ ╰─ {id} ● + ├─ network ● │ ╰─ / │ ├─ dependen - │ │ ├─ cies [*] - │ │ ╰─ ts [*] - │ ╰─ members [*] + │ │ ├─ cies ● + │ │ ╰─ ts ● + │ ╰─ members ● ├─ pul │ ├─ l │ │ ├─ / - │ │ │ ╰─ {id} [*] - │ │ ╰─ s [*] - │ ╰─ se [*] - ├─ releases [*] + │ │ │ ╰─ {id} ● + │ │ ╰─ s ● + │ ╰─ se ● + ├─ releases ● │ ╰─ / │ ├─ download/ │ │ ╰─ {tag} │ │ ╰─ / │ │ ╰─ {filename} │ │ ╰─ . - │ │ ╰─ {ext} [*] + │ │ ╰─ {ext} ● │ ├─ tag/ - │ │ ╰─ {id} [*] - │ ╰─ {*path} [*] + │ │ ╰─ {id} ● + │ ╰─ {*path} ● ├─ s - │ ├─ ecurity [*] + │ ├─ ecurity ● │ │ ╰─ / - │ │ ├─ advisories [*] - │ │ ╰─ policy [*] - │ ╰─ targazers [*] - │ ╰─ /yoou_know [*] + │ │ ├─ advisories ● + │ │ ╰─ policy ● + │ ╰─ targazers ● + │ ╰─ /yoou_know ● ├─ t - │ ├─ ags [*] + │ ├─ ags ● │ │ ╰─ / - │ │ ╰─ {id} [*] + │ │ ╰─ {id} ● │ ╰─ ree/ - │ ╰─ {id} [*] + │ ╰─ {id} ● ├─ w - │ ├─ atchers [*] - │ ╰─ iki [*] + │ ├─ atchers ● + │ ╰─ iki ● │ ╰─ / - │ ╰─ {id} [*] - ╰─ {*path} [*] + │ ╰─ {id} ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -1802,9 +1802,9 @@ fn test_dots_no_ext() -> Result<(), Box> { router.insert("/{name}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / - ╰─ {name} [*] + ╰─ {name} ● "###); assert_router_matches!(router, { @@ -1856,11 +1856,11 @@ fn test_dots_ext_no_qualifier() -> Result<(), Box> { router.insert("/{name}.js.gz", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ╰─ {name} - ╰─ .js [*] - ╰─ .gz [*] + ╰─ .js ● + ╰─ .gz ● "###); assert_router_matches!(router, { diff --git a/tests/poem.rs b/tests/poem.rs index feed337d..bdc53f86 100644 --- a/tests/poem.rs +++ b/tests/poem.rs @@ -36,10 +36,10 @@ fn test_insert_static_child_1() -> Result<(), Box> { router.insert("/abcdefgh", 3)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /abc [*] - ╰─ def [*] - ╰─ gh [*] + ▼ + ╰─ /abc ● + ╰─ def ● + ╰─ gh ● "###); Ok(()) @@ -54,13 +54,13 @@ fn test_insert_static_child_2() -> Result<(), Box> { router.insert("/ab125678", 4)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /ab ├─ 12 - │ ├─ 34 [*] - │ ╰─ 56 [*] - │ ╰─ 78 [*] - ╰─ cd [*] + │ ├─ 34 ● + │ ╰─ 56 ● + │ ╰─ 78 ● + ╰─ cd ● "###); Ok(()) @@ -73,9 +73,9 @@ fn test_insert_static_child_3() -> Result<(), Box> { router.insert("/ab", 2)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ /ab [*] - ╰─ c [*] + ▼ + ╰─ /ab ● + ╰─ c ● "###); Ok(()) @@ -89,12 +89,12 @@ fn test_insert_param_child() -> Result<(), Box> { router.insert("/abc/{p1}/{p3}", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /abc/ - ╰─ {p1} [*] + ╰─ {p1} ● ╰─ / - ├─ p2 [*] - ╰─ {p3} [*] + ├─ p2 ● + ╰─ {p3} ● "###); Ok(()) @@ -107,11 +107,11 @@ fn test_catch_all_child_1() -> Result<(), Box> { router.insert("/ab/de", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /ab - ├─ /de [*] + ├─ /de ● ╰─ c/ - ╰─ {*p1} [*] + ╰─ {*p1} ● "###); Ok(()) @@ -123,8 +123,8 @@ fn test_catch_all_child_2() -> Result<(), Box> { router.insert("{*p1}", 1)?; insta::assert_snapshot!(router, @r###" - $ - ╰─ {*p1} [*] + ▼ + ╰─ {*p1} ● "###); Ok(()) @@ -140,12 +140,12 @@ fn test_insert_regex_child() -> Result<(), Box> { router.insert("/abc/def/{name:digit_string}", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /abc/ ├─ def/ - │ ╰─ {name:digit_string} [*] + │ ╰─ {name:digit_string} ● ╰─ {name:digit_string} - ╰─ /def [*] + ╰─ /def ● "###); Ok(()) @@ -184,19 +184,19 @@ fn test_add_result() -> Result<(), Box> { // assert!(router.insert("/a/b/{*p2}", 2).is_err()); insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ a/ - │ ├─ b [*] + │ ├─ b ● │ │ ╰─ / - │ │ ├─ c/d [*] + │ │ ├─ c/d ● │ │ ├─ {p} - │ │ │ ╰─ /d [*] + │ │ │ ╰─ /d ● │ │ ╰─ {p2} - │ │ ╰─ /d [*] - │ ╰─ {*p} [*] + │ │ ╰─ /d ● + │ ╰─ {*p} ● ╰─ k/h/ - ╰─ {name:digit_string} [*] + ╰─ {name:digit_string} ● "###); Ok(()) @@ -222,33 +222,33 @@ fn test_matches() -> Result<(), Box> { router.insert("/{package}/-/{package_tgz:ends_with_tgz}", 12)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ a │ ├─ / - │ │ ├─ b/c/d [*] + │ │ ├─ b/c/d ● │ │ ╰─ {p1} │ │ ╰─ / │ │ ╰─ {p2} - │ │ ╰─ /c [*] + │ │ ╰─ /c ● │ ╰─ b - │ ├─ /def [*] + │ ├─ /def ● │ ╰─ c/ - │ ├─ def [*] + │ ├─ def ● │ │ ╰─ / - │ │ ╰─ {*p1} [*] + │ │ ╰─ {*p1} ● │ ├─ {param:digit_string} - │ │ ╰─ /def [*] - │ ╰─ {p1} [*] + │ │ ╰─ /def ● + │ ╰─ {p1} ● │ ╰─ / - │ ├─ def [*] - │ ╰─ {p2} [*] + │ ├─ def ● + │ ╰─ {p2} ● ├─ kcd/ - │ ╰─ {p1:digit_string} [*] + │ ╰─ {p1:digit_string} ● ├─ {package} │ ╰─ /-/ - │ ╰─ {package_tgz:ends_with_tgz} [*] - ╰─ {*p1} [*] + │ ╰─ {package_tgz:ends_with_tgz} ● + ╰─ {*p1} ● "###); assert_router_matches!(router, { @@ -340,10 +340,10 @@ fn test_match_priority() -> Result<(), Box> { router.insert("/a/{*path}", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ├─ bc [*] - ╰─ {*path} [*] + ├─ bc ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -359,11 +359,11 @@ fn test_match_priority() -> Result<(), Box> { router.insert("/a/{id}", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ├─ bc [*] - ├─ {id} [*] - ╰─ {*path} [*] + ├─ bc ● + ├─ {id} ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -380,12 +380,12 @@ fn test_match_priority() -> Result<(), Box> { router.insert("/a/{id:digit_string}", 4)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ├─ bc [*] - ├─ {id:digit_string} [*] - ├─ {id} [*] - ╰─ {*path} [*] + ├─ bc ● + ├─ {id:digit_string} ● + ├─ {id} ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -401,13 +401,13 @@ fn test_match_priority() -> Result<(), Box> { router.insert("/a/123", 5)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ├─ 123 [*] - ├─ bc [*] - ├─ {id:digit_string} [*] - ├─ {id} [*] - ╰─ {*path} [*] + ├─ 123 ● + ├─ bc ● + ├─ {id:digit_string} ● + ├─ {id} ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -426,9 +426,9 @@ fn test_catch_all_priority_in_sub_path() -> Result<(), Box> { router.insert("/a/{*path}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ╰─ {*path} [*] + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -444,11 +444,11 @@ fn test_catch_all_priority_in_sub_path() -> Result<(), Box> { router.insert("/a/b/{*path}", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ ├─ b/ - │ ╰─ {*path} [*] - ╰─ {*path} [*] + │ ╰─ {*path} ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -464,13 +464,13 @@ fn test_catch_all_priority_in_sub_path() -> Result<(), Box> { router.insert("/a/b/c/{*path}", 3)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ ├─ b/ │ ├─ c/ - │ │ ╰─ {*path} [*] - │ ╰─ {*path} [*] - ╰─ {*path} [*] + │ │ ╰─ {*path} ● + │ ╰─ {*path} ● + ╰─ {*path} ● "###); assert_router_matches!(router, { @@ -493,12 +493,12 @@ fn test_issue_275() -> Result<(), Box> { router.insert("/{id2}/b", 2)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ / ├─ {id1} - │ ╰─ /a [*] + │ ╰─ /a ● ╰─ {id2} - ╰─ /b [*] + ╰─ /b ● "###); assert_router_matches!(router, { @@ -527,9 +527,9 @@ fn test_percent_decoded() -> Result<(), Box> { router.insert("/a/{id}", 1)?; insta::assert_snapshot!(router, @r###" - $ + ▼ ╰─ /a/ - ╰─ {id} [*] + ╰─ {id} ● "###); assert_router_matches!(router, {