summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2023-04-17 01:20:40 -0400
committerJohn Turner <jturner.usa@gmail.com>2023-04-17 01:20:40 -0400
commit26e662f5629da3683549594cf8551e018f49309c (patch)
tree94e53ea239d493b3e0076668f51dcf70065677a6
parent0d799686d0a1c4a64bbc03a734be0d3271dfca06 (diff)
downloadget-26e662f5629da3683549594cf8551e018f49309c.tar.gz
added test case invalid-attribute.rs
-rw-r--r--tests/get.rs1
-rw-r--r--tests/trybuild/invalid-attribute.rs21
-rw-r--r--tests/trybuild/invalid-attribute.stderr23
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"