Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
#[rustversion::attr(not(nightly), ignore = "requires nightly")]
#[cfg_attr(miri, ignore = "incompatible with miri")]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}
+20
View File
@@ -0,0 +1,20 @@
use indoc::concatdoc;
macro_rules! env {
($var:literal) => {
"test"
};
}
static HELP: &str = concatdoc! {"
Usage: ", env!("CARGO_BIN_NAME"), " [options]
Options:
-h, --help
"};
#[test]
fn test_help() {
let expected = "Usage: test [options]\n\nOptions:\n -h, --help\n";
assert_eq!(HELP, expected);
}
+25
View File
@@ -0,0 +1,25 @@
use indoc::indoc;
#[test]
fn c_string() {
let indoc = indoc! {c"
a
\\b
c"
};
let expected = c"a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn raw_c_string() {
let indoc = indoc! {cr#"
"a"
\\b
c"#
};
let expected = c"\"a\"\n\n \\\\b\nc";
assert_eq!(indoc, expected);
}
+117
View File
@@ -0,0 +1,117 @@
use indoc::formatdoc;
#[test]
fn carriage_return() {
// Every line in the string ends with \r\n
let indoc = formatdoc! {"
{}
\\{}
{}",
'a', 'b', 'c'
};
let expected = "a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn empty_string() {
let indoc = formatdoc! {""};
let expected = "";
assert_eq!(indoc, expected);
}
#[test]
fn joined_first_line() {
let indoc = formatdoc! {"\
{}", 'a'
};
let expected = "a";
assert_eq!(indoc, expected);
}
#[test]
fn joined_lines() {
let indoc = formatdoc! {"
{}\
{}
{}\
{}
{}",
'a', 'b', 'c', 'd', 'e'
};
let expected = "ab\ncd\ne";
assert_eq!(indoc, expected);
}
#[test]
fn no_leading_newline() {
let indoc = formatdoc! {"{}
{}
{}", 'a', 'b', 'c'};
let expected = "a\nb\nc";
assert_eq!(indoc, expected);
}
#[test]
fn one_line() {
let indoc = formatdoc! {"a"};
let expected = "a";
assert_eq!(indoc, expected);
}
#[test]
fn raw_string() {
let indoc = formatdoc! {r#"
{:?}"
\\{}
{}"#,
"a", 'b', 'c'
};
let expected = "\"a\"\"\n\n \\\\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn string() {
let indoc = formatdoc! {"
{}
\\{}
{}",
'a', 'b', 'c'
};
let expected = "a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn string_trailing_newline() {
let indoc = formatdoc! {"
{}
\\{}
{}
",
'a', 'b', 'c'
};
let expected = "a\n\n \\b\nc\n";
assert_eq!(indoc, expected);
}
#[test]
fn trailing_whitespace() {
let indoc = formatdoc! {"
{} {below}
{} {below}
{} {below}
end",
2, 0, -2, below = "below"
};
let expected = "2 below\n \n0 below\n\n-2 below\n\nend";
assert_eq!(indoc, expected);
}
+179
View File
@@ -0,0 +1,179 @@
#[cfg(indoc_test_cstr)]
mod test_cstr;
use indoc::indoc;
const HELP: &str = indoc! {"
Usage: ./foo
"};
#[test]
fn byte_string() {
let indoc = indoc! {b"
a
\\b
c"
};
let expected = b"a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn carriage_return() {
// Every line in the string ends with \r\n
let indoc = indoc! {"
a
\\b
c"
};
let expected = "a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn empty_string() {
let indoc = indoc! {""};
let expected = "";
assert_eq!(indoc, expected);
}
#[test]
fn global() {
let expected = "Usage: ./foo\n";
assert_eq!(HELP, expected);
}
#[test]
fn indoc_as_format_string() {
let s = format!(indoc! {"{}"}, true);
assert_eq!(s, "true");
}
#[test]
fn joined_first_line() {
let indoc = indoc! {"\
a"
};
let expected = "a";
assert_eq!(indoc, expected);
}
#[test]
fn joined_lines() {
let indoc = indoc! {"
a\
b
c\
d
e"
};
let expected = "ab\ncd\ne";
assert_eq!(indoc, expected);
}
#[test]
fn metavariable() {
macro_rules! indoc_wrapper {
($e:expr) => {
indoc!($e)
};
}
let indoc = indoc_wrapper! {"
macros, how do they work
"};
let expected = "macros, how do they work\n";
assert_eq!(indoc, expected);
}
#[test]
fn no_leading_newline() {
let indoc = indoc! {"a
b
c"};
let expected = "a\nb\nc";
assert_eq!(indoc, expected);
}
#[test]
fn one_line() {
let indoc = indoc! {"a"};
let expected = "a";
assert_eq!(indoc, expected);
}
#[test]
fn raw_byte_string() {
let indoc = indoc! {br#"
"a"
\\b
c"#
};
let expected = b"\"a\"\n\n \\\\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn raw_string() {
let indoc = indoc! {r#"
"a"
\\b
c"#
};
let expected = "\"a\"\n\n \\\\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn string() {
let indoc = indoc! {"
a
\\b
c"
};
let expected = "a\n\n \\b\nc";
assert_eq!(indoc, expected);
}
#[test]
fn string_trailing_newline() {
let indoc = indoc! {"
a
\\b
c
"};
let expected = "a\n\n \\b\nc\n";
assert_eq!(indoc, expected);
}
#[test]
fn trailing_comma() {
let indoc = indoc! {
"
test
",
};
let expected = "test\n";
assert_eq!(indoc, expected);
}
#[test]
fn trailing_whitespace() {
let indoc = indoc! {"
2 below
0 below
-2 below
end"
};
let expected = "2 below\n \n0 below\n\n-2 below\n\nend";
assert_eq!(indoc, expected);
}
+53
View File
@@ -0,0 +1,53 @@
#![allow(clippy::shadow_unrelated)]
use unindent::{unindent, unindent_bytes, Unindent};
#[test]
fn fn_unindent_str() {
let s = "
line one
line two";
assert_eq!(unindent(s), "line one\nline two");
let s = "\n\t\t\tline one\n\t\t\tline two";
assert_eq!(unindent(s), "line one\nline two");
}
#[test]
fn fn_unindent_bytes() {
let b = b"
line one
line two";
assert_eq!(unindent_bytes(b), b"line one\nline two");
let b = b"\n\t\t\tline one\n\t\t\tline two";
assert_eq!(unindent_bytes(b), b"line one\nline two");
}
#[test]
fn trait_unindent_str() {
let s = "
line one
line two";
assert_eq!(s.unindent(), "line one\nline two");
let s = "\n\t\t\tline one\n\t\t\tline two";
assert_eq!(s.unindent(), "line one\nline two");
}
#[test]
fn trait_unindent_bytes() {
let b = b"
line one
line two";
assert_eq!(b.unindent(), b"line one\nline two");
let b = b"\n\t\t\tline one\n\t\t\tline two";
assert_eq!(b.unindent(), b"line one\nline two");
}
#[test]
fn carriage_returns() {
let s = "\r\n\tline one\r\n\tline two";
assert_eq!(unindent(s), "line one\r\nline two");
}
+57
View File
@@ -0,0 +1,57 @@
#![allow(clippy::if_same_then_else, clippy::let_underscore_untyped)]
use indoc::writedoc;
use std::fmt::Write as _;
#[test]
fn test_write_to_string() {
let mut s = String::new();
writedoc!(
s,
"
one
two
",
)
.unwrap();
let expected = "one\ntwo\n";
assert_eq!(s, expected);
}
#[test]
fn test_format_args() {
let mut s = String::new();
writedoc!(
s,
"
{}
{}
",
0,
0,
)
.unwrap();
let expected = "0\n0\n";
assert_eq!(s, expected);
}
#[test]
fn test_angle_bracket_parsing() {
const ZERO: usize = 0;
struct Pair<A, B>(A, B);
impl<A, B> Pair<A, B> {
const ONE: usize = 1;
}
let mut s = String::new();
let _ = writedoc! {
if ZERO < Pair::<fn() -> (), ()>::ONE { &mut s } else { &mut s },
"writedoc",
};
let expected = "writedoc";
assert_eq!(s, expected);
}
@@ -0,0 +1,6 @@
use indoc::indoc;
fn main() {
let world = "world";
println!(indoc!("Hello {world}"));
}
@@ -0,0 +1,8 @@
error: there is no argument named `world`
--> tests/ui/capture-var-nested.rs:5:21
|
5 | println!(indoc!("Hello {world}"));
| ^^^^^^^^^^^^^^^
|
= note: did you intend to capture a variable `world` from the surrounding scope?
= note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
+5
View File
@@ -0,0 +1,5 @@
use indoc::indoc;
fn main() {
indoc!();
}
@@ -0,0 +1,7 @@
error: unexpected end of macro invocation, expected format string
--> tests/ui/no-arguments.rs:4:5
|
4 | indoc!();
| ^^^^^^^^
|
= note: this error originates in the macro `indoc` (in Nightly builds, run with -Z macro-backtrace for more info)
+5
View File
@@ -0,0 +1,5 @@
use indoc::indoc;
fn main() {
indoc!(fail);
}
+5
View File
@@ -0,0 +1,5 @@
error: argument must be a single string literal
--> tests/ui/non-lit.rs:4:12
|
4 | indoc!(fail);
| ^^^^
+5
View File
@@ -0,0 +1,5 @@
use indoc::indoc;
fn main() {
indoc!(64);
}
+5
View File
@@ -0,0 +1,5 @@
error: argument must be a single string literal
--> tests/ui/non-string.rs:4:12
|
4 | indoc!(64);
| ^^
@@ -0,0 +1,5 @@
use indoc::printdoc;
fn main() {
printdoc!(b"");
}
@@ -0,0 +1,5 @@
error: byte strings are not supported in formatting macros
--> tests/ui/printdoc-binary.rs:4:15
|
4 | printdoc!(b"");
| ^^^
@@ -0,0 +1,5 @@
use indoc::printdoc;
fn main() {
printdoc!("", 0);
}
@@ -0,0 +1,12 @@
error: argument never used
--> tests/ui/printdoc-extra-arg.rs:4:19
|
4 | printdoc!("", 0);
| -- ^ argument never used
| |
| formatting specifier missing
|
help: format specifiers use curly braces, consider adding a format specifier
|
4 | printdoc!("{}", 0);
| ++
@@ -0,0 +1,5 @@
use indoc::printdoc;
fn main() {
printdoc!("{}");
}
@@ -0,0 +1,5 @@
error: 1 positional argument in format string, but no arguments were given
--> tests/ui/printdoc-no-arg.rs:4:16
|
4 | printdoc!("{}");
| ^^
@@ -0,0 +1,7 @@
use indoc::printdoc;
struct NoDisplay;
fn main() {
printdoc!("{}", NoDisplay);
}
@@ -0,0 +1,15 @@
error[E0277]: `NoDisplay` doesn't implement `std::fmt::Display`
--> tests/ui/printdoc-no-display.rs:6:21
|
6 | printdoc!("{}", NoDisplay);
| -- ^^^^^^^^^ `NoDisplay` cannot be formatted with the default formatter
| |
| required by this formatting parameter
|
help: the trait `std::fmt::Display` is not implemented for `NoDisplay`
--> tests/ui/printdoc-no-display.rs:3:1
|
3 | struct NoDisplay;
| ^^^^^^^^^^^^^^^^
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
= note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `printdoc` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -0,0 +1,5 @@
use indoc::printdoc;
fn main() {
printdoc!("{named}");
}
@@ -0,0 +1,5 @@
error[E0425]: cannot find value `named` in this scope
--> tests/ui/printdoc-no-named-arg.rs:4:17
|
4 | printdoc!("{named}");
| ^^^^^ not found in this scope
@@ -0,0 +1,9 @@
use indoc::indoc;
fn main() {
indoc!("
a
b
c
" 64 128);
}
@@ -0,0 +1,5 @@
error: unexpected tokens in macro invocation; indoc argument must be a single string literal
--> tests/ui/three-arguments.rs:8:11
|
8 | " 64 128);
| ^^^^^^
+9
View File
@@ -0,0 +1,9 @@
use indoc::indoc;
fn main() {
indoc!("
a
b
c
" 64);
}
@@ -0,0 +1,5 @@
error: unexpected token in macro invocation; indoc argument must be a single string literal
--> tests/ui/two-arguments.rs:8:11
|
8 | " 64);
| ^^