]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
unit1979, unit1980: fix indent, formatting, scope
authorViktor Szakats <commit@vsz.me>
Wed, 21 May 2025 07:44:19 +0000 (09:44 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 21 May 2025 08:43:47 +0000 (10:43 +0200)
Closes #17403

tests/unit/unit1979.c
tests/unit/unit1980.c

index e5f044dd6343983c2e612792055df74df5b353ac..89af6c66054df91590b38c73e675fcaa86205f21 100644 (file)
@@ -23,7 +23,6 @@
  ***************************************************************************/
 #include "curlcheck.h"
 
-
 #include "http_aws_sigv4.h"
 #include "dynbuf.h"
 
@@ -37,109 +36,109 @@ static void unit_stop(void)
 }
 
 UNITTEST_START
-
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS)
-
-struct testcase
 {
-  const char *testname;
-  const bool normalize;
-  const char *url_part;
-  const char *canonical_url;
-};
-
-static const struct testcase testcases[] = {
-  {
-    "test-equals-encode",
-    true,
-    "/a=b",
-    "/a%3Db",
-  },
-  {
-    "test-equals-noencode",
-    false,
-    "/a=b",
-    "/a=b",
-  },
-  {
-    "test-s3-tables",
-    true,
-    "/tables/arn%3Aaws%3As3tables%3Aus-east-1%3A022954301426%3Abucket%2Fja"
-    "soehartablebucket/jasoeharnamespace/jasoehartable/encryption",
-    "/tables/arn%253Aaws%253As3tables%253Aus-east-1%253A022954301426%253Ab"
-    "ucket%252Fjasoehartablebucket/jasoeharnamespace/jasoehartable/encrypt"
-    "ion",
-  },
-  {
-    "get-vanilla",
-    true,
-    "/",
-    "/",
-  },
-  {
-    "get-unreserved",
-    true,
-    "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
-    "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
-  },
-  {
-    "get-slashes-unnormalized",
-    false,
-    "//example//",
-    "//example//",
-  },
-  {
-    "get-space-normalized",
-    true,
-    "/example space/",
-    "/example%20space/",
-  },
-  {
-    "get-slash-dot-slash-unnormalized",
-    false,
-    "/./",
-    "/./",
-  },
-  {
-    "get-slash-unnormalized",
-    false,
-    "//",
-    "//",
-  },
-  {
-    "get-relative-relative-unnormalized",
-    false,
-    "/example1/example2/../..",
-    "/example1/example2/../..",
-  }
-};
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS)
+  struct testcase {
+    const char *testname;
+    const bool normalize;
+    const char *url_part;
+    const char *canonical_url;
+  };
 
-  struct dynbuf canonical_path;
+  static const struct testcase testcases[] = {
+    {
+      "test-equals-encode",
+      true,
+      "/a=b",
+      "/a%3Db"
+    },
+    {
+      "test-equals-noencode",
+      false,
+      "/a=b",
+      "/a=b"
+    },
+    {
+      "test-s3-tables",
+      true,
+      "/tables/arn%3Aaws%3As3tables%3Aus-east-1%3A022954301426%3Abucket%2Fja"
+      "soehartablebucket/jasoeharnamespace/jasoehartable/encryption",
+      "/tables/arn%253Aaws%253As3tables%253Aus-east-1%253A022954301426%253Ab"
+      "ucket%252Fjasoehartablebucket/jasoeharnamespace/jasoehartable/encrypt"
+      "ion"
+    },
+    {
+      "get-vanilla",
+      true,
+      "/",
+      "/"
+    },
+    {
+      "get-unreserved",
+      true,
+      "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+      "/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+    },
+    {
+      "get-slashes-unnormalized",
+      false,
+      "//example//",
+      "//example//"
+    },
+    {
+      "get-space-normalized",
+      true,
+      "/example space/",
+      "/example%20space/"
+    },
+    {
+      "get-slash-dot-slash-unnormalized",
+      false,
+      "/./",
+      "/./"
+    },
+    {
+      "get-slash-unnormalized",
+      false,
+      "//",
+      "//"
+    },
+    {
+      "get-relative-relative-unnormalized",
+      false,
+      "/example1/example2/../..",
+      "/example1/example2/../.."
+    }
+  };
 
-  char buffer[1024];
-  char *canonical_path_string;
   size_t i;
-  int result;
-  int msnprintf_result;
 
   for(i = 0; i < CURL_ARRAYSIZE(testcases); i++) {
+    struct dynbuf canonical_path;
+
+    char buffer[1024];
+    char *canonical_path_string;
+    int result;
+    int msnprintf_result;
+
     curlx_dyn_init(&canonical_path, CURL_MAX_HTTP_HEADER);
 
     result = canon_path(testcases[i].url_part, strlen(testcases[i].url_part),
-      &canonical_path,
-      testcases[i].normalize);
+                        &canonical_path, testcases[i].normalize);
     canonical_path_string = curlx_dyn_ptr(&canonical_path);
     msnprintf_result = curl_msnprintf(buffer, sizeof(buffer),
-    "%s: Received \"%s\" and should be \"%s\", normalize (%d)",
-      testcases[i].testname, curlx_dyn_ptr(&canonical_path),
-      testcases[i].canonical_url, testcases[i].normalize);
+                                      "%s: Received \"%s\" "
+                                      "and should be \"%s\", normalize (%d)",
+                                      testcases[i].testname,
+                                      curlx_dyn_ptr(&canonical_path),
+                                      testcases[i].canonical_url,
+                                      testcases[i].normalize);
     fail_unless(msnprintf_result >= 0, "curl_msnprintf fails");
     fail_unless(!result && canonical_path_string &&
-      !strcmp(canonical_path_string,
-      testcases[i].canonical_url), buffer);
+                !strcmp(canonical_path_string, testcases[i].canonical_url),
+                buffer);
     curlx_dyn_free(&canonical_path);
   }
-
 #endif /* !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS) */
-
+}
 UNITTEST_STOP
index 69cd2dd8c07491a1a25e6ac5c8a9b1945114c6b3..dcc415dca5124bb064b1dcc7fba8dd413b76ffe0 100644 (file)
  ***************************************************************************/
 #include "curlcheck.h"
 
-
 #include "http_aws_sigv4.h"
 #include "dynbuf.h"
 
-
 static CURLcode unit_setup(void)
 {
   return CURLE_OK;
@@ -38,77 +36,80 @@ static void unit_stop(void)
 }
 
 UNITTEST_START
+{
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS)
+  struct testcase {
+    const char *testname;
+    const char *query_part;
+    const char *canonical_query;
+  };
 
-struct testcase {
-  const char *testname;
-  const char *query_part;
-  const char *canonical_query;
-};
-
-static const struct testcase testcases[] = {
-      {
-          "no-value",
-          "Param1=",
-          "Param1="
-      },
-      {
-        "test-439",
-        "name=me&noval&aim=b%aad&weirdo=*.//-",
-        "aim=b%AAd&name=me&noval=&weirdo=%2A.%2F%2F-"
+  static const struct testcase testcases[] = {
+    {
+      "no-value",
+      "Param1=",
+      "Param1="
     },
     {
-        "blank-query-params",
-        "hello=a&b&c=&d",
-        "b=&c=&d=&hello=a"
-      },
-      {
-          "get-vanilla-query-order-key-case",
-          "Param2=value2&Param1=value1",
-          "Param1=value1&Param2=value2"
-      },
-      {
-          "get-vanilla-query-unreserved",
-          "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz="
-          "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
-          "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz="
-          "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
-      },
-      {
-          "get-vanilla-empty-query-key",
-          "Param1=value1",
-          "Param1=value1"
-      },
-      {
-          "get-vanilla-query-order-encoded",
-          "Param-3=Value3&Param=Value2&%E1%88%B4=Value1",
-          "%E1%88%B4=Value1&Param=Value2&Param-3=Value3"
-      },
-};
-
-  struct dynbuf canonical_query;
+      "test-439",
+      "name=me&noval&aim=b%aad&weirdo=*.//-",
+      "aim=b%AAd&name=me&noval=&weirdo=%2A.%2F%2F-"
+    },
+    {
+      "blank-query-params",
+      "hello=a&b&c=&d",
+      "b=&c=&d=&hello=a"
+    },
+    {
+      "get-vanilla-query-order-key-case",
+      "Param2=value2&Param1=value1",
+      "Param1=value1&Param2=value2"
+    },
+    {
+      "get-vanilla-query-unreserved",
+      "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz="
+      "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+      "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz="
+      "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+    },
+    {
+      "get-vanilla-empty-query-key",
+      "Param1=value1",
+      "Param1=value1"
+    },
+    {
+      "get-vanilla-query-order-encoded",
+      "Param-3=Value3&Param=Value2&%E1%88%B4=Value1",
+      "%E1%88%B4=Value1&Param=Value2&Param-3=Value3"
+    },
+  };
 
-  char buffer[1024];
-  char *canonical_query_ptr;
   size_t i;
-  int result;
-  int msnprintf_result;
 
-  for(i = 0;  i < CURL_ARRAYSIZE(testcases); i++) {
+  for(i = 0; i < CURL_ARRAYSIZE(testcases); i++) {
+    struct dynbuf canonical_query;
+
+    char buffer[1024];
+    char *canonical_query_ptr;
+    int result;
+    int msnprintf_result;
+
     curlx_dyn_init(&canonical_query, CURL_MAX_HTTP_HEADER);
 
     result = canon_query(testcases[i].query_part, &canonical_query);
     canonical_query_ptr = curlx_dyn_ptr(&canonical_query);
     msnprintf_result = curl_msnprintf(buffer, sizeof(buffer),
-      "%s: Received \"%s\" and should be \"%s\"",
-      testcases[i].testname, canonical_query_ptr,
-      testcases[i].canonical_query);
+                                      "%s: Received \"%s\" "
+                                      "and should be \"%s\"",
+                                      testcases[i].testname,
+                                      canonical_query_ptr,
+                                      testcases[i].canonical_query);
     fail_unless(msnprintf_result >= 0, "curl_msnprintf fails");
-    fail_unless(!result && canonical_query_ptr && !strcmp(canonical_query_ptr,
-      testcases[i].canonical_query),
-    buffer);
+    fail_unless(!result && canonical_query_ptr &&
+                !strcmp(canonical_query_ptr, testcases[i].canonical_query),
+                buffer);
     curlx_dyn_free(&canonical_query);
- }
-
- #endif /* !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS) */
- UNITTEST_STOP
 }
+#endif /* !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_AWS) */
+}
+UNITTEST_STOP