From 0bf7485124854de325a957c9335a9d9b0c25c02d Mon Sep 17 00:00:00 2001 From: Durairaj Subramaniam Date: Wed, 2 Oct 2024 01:48:59 +0100 Subject: [PATCH] test: service macro comments #3472 --- actix-web/CHANGES.md | 1 + actix-web/tests/test_service.rs | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 actix-web/tests/test_service.rs diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index aca4ccfae..ccc90da1e 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,6 +4,7 @@ - Minimum supported Rust version (MSRV) is now 1.75. - On Windows platforms, produce an error when invoking `HttpServer::bind` on a socket that's already in use. See [issue 2958](https://github.com/actix/actix-web/issues/2958). +- Service macro comments are now filtered out see [issue 3472](https://github.com/actix/actix-web/issues/3472). ## 4.9.0 diff --git a/actix-web/tests/test_service.rs b/actix-web/tests/test_service.rs new file mode 100644 index 000000000..e194509e9 --- /dev/null +++ b/actix-web/tests/test_service.rs @@ -0,0 +1,40 @@ +#[cfg(test)] +mod tests { + use actix_web::services; + + #[test] + fn test_define_services_macro_with_multiple_arguments() { + let result = services!(1, 2, 3); + assert_eq!(result, (1, 2, 3)); + } + + #[test] + fn test_define_services_macro_with_single_argument() { + let result = services!(1); + assert_eq!(result, (1,)); + } + + #[test] + fn test_define_services_macro_with_no_arguments() { + let result = services!(); + result + } + + #[test] + fn test_define_services_macro_with_trailing_comma() { + let result = services!(1, 2, 3,); + assert_eq!(result, (1, 2, 3)); + } + + #[test] + fn test_define_services_macro_with_comments_in_arguments() { + let result = services!( + 1, // First comment + 2, // Second comment + 3 // Third comment + ); + + // Assert that comments are ignored and it correctly returns a tuple. + assert_eq!(result, (1, 2, 3)); + } +}