| 1 | use fluent_urirust-analyzer cargo fluent-uri 0.4.1 crate/::{ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#, Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#, IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef#, Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#, UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#}; |
| 2 | |
| 3 | #[cfg(feature = "alloc")] |
| 4 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 5 | fn iri_to_urirust-analyzer cargo fluent-uri 0.4.1 iri_to_uri().() { |
| 6 | let iri = Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]parse().("http://résumé.example.org").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 7 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iri.to_urirust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`]to_uri().(), "http://r%C3%A9sum%C3%A9.example.org"); |
| 8 | |
| 9 | let iri = Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]parse().("http://www.example.org/red%09rosé#red").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 10 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iri.to_urirust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`]to_uri().(), "http://www.example.org/red%09ros%C3%A9#red"); |
| 11 | |
| 12 | let iri = Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]parse().("foo://[email protected]:8042/over/there?name=ferret#nose").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 13 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iri.to_urirust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`]to_uri().(), iri.as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]as_str().()); |
| 14 | |
| 15 | let iri = Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]parse().("http://example.com/\u{10300}\u{10301}\u{10302}").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 16 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 17 | iri.to_urirust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`]to_uri().(), |
| 18 | "http://example.com/%F0%90%8C%80%F0%90%8C%81%F0%90%8C%82" |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | #[cfg(feature = "alloc")] |
| 23 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 24 | fn uri_to_irirust-analyzer cargo fluent-uri 0.4.1 uri_to_iri().() { |
| 25 | let uri = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://www.example.org/r%E9sum%E9.html").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 26 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 27 | Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`][`From<Uri<T>>`]from().(uri).normalizerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]normalize().(), |
| 28 | "http://www.example.org/r%E9sum%E9.html" |
| 29 | ); |
| 30 | |
| 31 | let uri = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://www.example.org/D%C3%BCrst").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 32 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`][`From<Uri<T>>`]from().(uri).normalizerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]normalize().(), "http://www.example.org/Dürst"); |
| 33 | |
| 34 | let uri = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://www.example.org/D%FCrst").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 35 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`][`From<Uri<T>>`]from().(uri).normalizerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]normalize().(), "http://www.example.org/D%FCrst"); |
| 36 | |
| 37 | let uri = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://xn--99zt52a.example.org/%e2%80%ae").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 38 | // TODO: Determine if we should implement the MUST in Section 4.1 of RFC 3987. |
| 39 | // assert_eq!( |
| 40 | // uri.as_iri().normalize(), |
| 41 | // "http://xn--99zt52a.example.org/%E2%80%AE" |
| 42 | // ); |
| 43 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 44 | Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`][`From<Uri<T>>`]from().(uri).normalizerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]normalize().(), |
| 45 | "http://xn--99zt52a.example.org/\u{202e}" |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 50 | fn convert_errorrust-analyzer cargo fluent-uri 0.4.1 convert_error().() { |
| 51 | let uri_ref = UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`UriRef<T>`]parse().("rel/ref").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 52 | let e = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Uri<&'a str>`][`TryFrom<UriRef<&'a str>>`]try_from().(uri_ref).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 53 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e, ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#::NoSchemerust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NoScheme#); |
| 54 | |
| 55 | let uri_ref = UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`UriRef<T>`]parse().("").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 56 | let e = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Uri<&'a str>`][`TryFrom<UriRef<&'a str>>`]try_from().(uri_ref).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 57 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e, ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#::NoSchemerust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NoScheme#); |
| 58 | |
| 59 | let iri = Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]parse().("http://你好.example.com/").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 60 | let e = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Uri<&'a str>`][`TryFrom<Iri<&'a str>>`]try_from().(iri).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 61 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e, ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#::NotAsciirust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NotAscii# { indexrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NotAscii#index.: 7 }); |
| 62 | |
| 63 | let iri_ref = IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`IriRef<T>`]parse().("réf/rel").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 64 | |
| 65 | let e = Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Uri<&'a str>`][`TryFrom<IriRef<&'a str>>`]try_from().(iri_ref).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 66 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e, ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#::NoSchemerust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NoScheme#); |
| 67 | |
| 68 | let e = UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#::try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`UriRef<&'a str>`][`TryFrom<IriRef<&'a str>>`]try_from().(iri_ref).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 69 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e, ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#::NotAsciirust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NotAscii# { indexrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NotAscii#index.: 1 }); |
| 70 | |
| 71 | let e = Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<&'a str>`][`TryFrom<IriRef<&'a str>>`]try_from().(iri_ref).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 72 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e, ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#::NoSchemerust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NoScheme#); |
| 73 | } |