From 16e8913f658d9b66278bd662f9007854c8db6758 Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Wed, 20 Aug 2025 04:12:50 +0800 Subject: [PATCH] Add tests --- src/lib.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 202e288..6fbaaf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -734,6 +734,50 @@ mod tests { assert_eq!(format(input, &QueryParams::None, &options), input); } + #[test] + fn it_does_not_indent_next_statement_when_max_inline_arguments_is_some_nat() { + let args = [None, Some(0), Some(999)]; + + for arg in args { + let input = indoc!( + " + DROP INDEX IF EXISTS idx_a; + + DROP INDEX IF EXISTS idx_b; + " + ); + let options = FormatOptions { + max_inline_arguments: arg, + ..Default::default() + }; + let expected = indoc!( + " + DROP INDEX IF EXISTS idx_a; + + DROP INDEX IF EXISTS idx_b; + " + ); + + assert_eq!(format(input, &QueryParams::None, &options), expected); + + let input = indoc!( + r#" + -- comment + DROP TABLE IF EXISTS "public"."table_name"; + "# + ); + + let expected = indoc!( + r#" + -- comment + DROP TABLE IF EXISTS "public"."table_name"; + "# + ); + + assert_eq!(format(input, &QueryParams::None, &options), expected); + } + } + #[test] fn it_formats_incomplete_query() { let input = "SELECT count(";