diff options
| author | John Turner <jturner.usa@gmail.com> | 2023-04-17 01:20:40 -0400 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2023-04-17 01:20:40 -0400 |
| commit | 26e662f5629da3683549594cf8551e018f49309c (patch) | |
| tree | 94e53ea239d493b3e0076668f51dcf70065677a6 | |
| parent | 0d799686d0a1c4a64bbc03a734be0d3271dfca06 (diff) | |
| download | get-26e662f5629da3683549594cf8551e018f49309c.tar.gz | |
added test case invalid-attribute.rs
| -rw-r--r-- | tests/get.rs | 1 | ||||
| -rw-r--r-- | tests/trybuild/invalid-attribute.rs | 21 | ||||
| -rw-r--r-- | tests/trybuild/invalid-attribute.stderr | 23 |
3 files changed, 45 insertions, 0 deletions
diff --git a/tests/get.rs b/tests/get.rs index 76827ca..efa4198 100644 --- a/tests/get.rs +++ b/tests/get.rs @@ -45,4 +45,5 @@ fn trybuild() { let tests = trybuild::TestCases::new(); tests.compile_fail(testcase!("unit-struct.rs")); tests.compile_fail(testcase!("tuple-struct-without-attribute.rs")); + tests.compile_fail(testcase!("invalid-attribute.rs")); } diff --git a/tests/trybuild/invalid-attribute.rs b/tests/trybuild/invalid-attribute.rs new file mode 100644 index 0000000..01f081e --- /dev/null +++ b/tests/trybuild/invalid-attribute.rs @@ -0,0 +1,21 @@ +use get::Get; + +#[derive(Get)] +pub struct Cat { + #[get()] + name: String, +} + +#[derive(Get)] +pub struct Dog { + #[get] + name: String, +} + +#[derive(Get)] +pub struct Crab { + #[get(invalid_name = "invalid_value")] + name: String, +} + +pub fn main() {} diff --git a/tests/trybuild/invalid-attribute.stderr b/tests/trybuild/invalid-attribute.stderr new file mode 100644 index 0000000..426cc06 --- /dev/null +++ b/tests/trybuild/invalid-attribute.stderr @@ -0,0 +1,23 @@ +error: proc-macro derive panicked + --> tests/trybuild/invalid-attribute.rs:3:10 + | +3 | #[derive(Get)] + | ^^^ + | + = help: message: called `Result::unwrap()` on an `Err` value: "failed to parse attribute" + +error: proc-macro derive panicked + --> tests/trybuild/invalid-attribute.rs:9:10 + | +9 | #[derive(Get)] + | ^^^ + | + = help: message: called `Result::unwrap()` on an `Err` value: "failed to parse attribute" + +error: proc-macro derive panicked + --> tests/trybuild/invalid-attribute.rs:15:10 + | +15 | #[derive(Get)] + | ^^^ + | + = help: message: called `Result::unwrap()` on an `Err` value: "invalid name value list in attribute" |
