mirror of
https://github.com/curl/curl.git
synced 2026-08-25 06:03:32 +03:00
code: style updates
This commit is contained in:
parent
9d194a1143
commit
a71012c03e
85 changed files with 249 additions and 248 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -23,32 +23,32 @@
|
|||
|
||||
#include "strequal.h"
|
||||
|
||||
static CURLcode unit_setup( void ) {return CURLE_OK;}
|
||||
static void unit_stop( void ) {}
|
||||
static CURLcode unit_setup(void) {return CURLE_OK;}
|
||||
static void unit_stop(void) {}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
int rc;
|
||||
|
||||
rc = curl_strequal("iii", "III");
|
||||
fail_unless( rc != 0 , "return code should be zero" );
|
||||
fail_unless(rc != 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iiia", "III");
|
||||
fail_unless( rc == 0 , "return code should be zero" );
|
||||
fail_unless(rc == 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iii", "IIIa");
|
||||
fail_unless( rc == 0 , "return code should be zero" );
|
||||
fail_unless(rc == 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iiiA", "IIIa");
|
||||
fail_unless( rc != 0 , "return code should be non-zero" );
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("iii", "III", 3);
|
||||
fail_unless( rc != 0 , "return code should be non-zero" );
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("iiiABC", "IIIcba", 3);
|
||||
fail_unless( rc != 0 , "return code should be non-zero" );
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("ii", "II", 3);
|
||||
fail_unless( rc != 0 , "return code should be non-zero" );
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
UNITTEST_STOP
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
static struct SessionHandle *data;
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
data = curl_easy_init();
|
||||
if(!data)
|
||||
|
|
@ -36,7 +36,7 @@ static CURLcode unit_setup( void )
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(data);
|
||||
}
|
||||
|
|
@ -52,50 +52,50 @@ CURLcode rc;
|
|||
rc = Curl_base64_encode(data, "i", 1, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory( output, "aQ==", 4);
|
||||
verify_memory(output, "aQ==", 4);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode(data, "ii", 2, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory( output, "aWk=", 4);
|
||||
verify_memory(output, "aWk=", 4);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode(data, "iii", 3, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 4, "size should be 4");
|
||||
verify_memory( output, "aWlp", 4);
|
||||
verify_memory(output, "aWlp", 4);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode(data, "iiii", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory( output, "aWlpaQ==", 8);
|
||||
verify_memory(output, "aWlpaQ==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_encode(data, "\xff\x01\xfe\x02", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory( output, "/wH+Ag==", 8);
|
||||
verify_memory(output, "/wH+Ag==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64url_encode(data, "\xff\x01\xfe\x02", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory( output, "_wH-Ag==", 8);
|
||||
verify_memory(output, "_wH-Ag==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64url_encode(data, "iiii", 4, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory( output, "aWlpaQ==", 8);
|
||||
verify_memory(output, "aWlpaQ==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
/* 0 length makes it do strlen() */
|
||||
rc = Curl_base64_encode(data, "iiii", 0, &output, &size);
|
||||
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
|
||||
fail_unless(size == 8, "size should be 8");
|
||||
verify_memory( output, "aWlpaQ==", 8);
|
||||
verify_memory(output, "aWlpaQ==", 8);
|
||||
Curl_safefree(output);
|
||||
|
||||
rc = Curl_base64_decode("aWlpaQ==", &decoded, &size);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
static struct SessionHandle *data;
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
data = curl_easy_init();
|
||||
if(!data)
|
||||
|
|
@ -35,7 +35,7 @@ static CURLcode unit_setup( void )
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
curl_easy_cleanup(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static struct curl_hash hp;
|
|||
static char *data_key;
|
||||
static struct Curl_dns_entry *data_node;
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
int rc;
|
||||
data = curl_easy_init();
|
||||
|
|
@ -60,7 +60,7 @@ static CURLcode unit_setup( void )
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
if(data_node) {
|
||||
Curl_freeaddrinfo(data_node->addr);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -160,7 +160,7 @@ static const struct testcase tests[] = {
|
|||
{ "****.txt", ".txt", MATCH },
|
||||
|
||||
/* empty string or pattern */
|
||||
{ "", "", MATCH } ,
|
||||
{ "", "", MATCH },
|
||||
{ "", "hello", NOMATCH },
|
||||
{ "file", "", NOMATCH },
|
||||
{ "?", "", NOMATCH },
|
||||
|
|
@ -208,12 +208,12 @@ static const struct testcase tests[] = {
|
|||
{ "", "", MATCH }
|
||||
};
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ static CURLcode unit_setup(void)
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
/* done before shutting down and exiting */
|
||||
}
|
||||
|
|
@ -51,14 +51,14 @@ fail_unless(Curl_cert_hostcheck("f*.example.com", "foo.example.com"),
|
|||
fail_unless(Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"),
|
||||
"good 5");
|
||||
|
||||
fail_if(Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1" );
|
||||
fail_if(Curl_cert_hostcheck("*", "www.example.com"), "bad 2" );
|
||||
fail_if(Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3" );
|
||||
fail_if(Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4" );
|
||||
fail_if(Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5" );
|
||||
fail_if(Curl_cert_hostcheck("*.com", "example.com"), "bad 6" );
|
||||
fail_if(Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7" );
|
||||
fail_if(Curl_cert_hostcheck("*.example.", "www.example."), "bad 8" );
|
||||
fail_if(Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1");
|
||||
fail_if(Curl_cert_hostcheck("*", "www.example.com"), "bad 2");
|
||||
fail_if(Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3");
|
||||
fail_if(Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4");
|
||||
fail_if(Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5");
|
||||
fail_if(Curl_cert_hostcheck("*.com", "example.com"), "bad 6");
|
||||
fail_if(Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7");
|
||||
fail_if(Curl_cert_hostcheck("*.example.", "www.example."), "bad 8");
|
||||
fail_if(Curl_cert_hostcheck("*.example.", "www.example"), "bad 9");
|
||||
fail_if(Curl_cert_hostcheck("", "www"), "bad 10");
|
||||
fail_if(Curl_cert_hostcheck("*", "www"), "bad 11");
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
#include "curl/mprintf.h"
|
||||
|
||||
static CURLcode unit_setup( void ) {return CURLE_OK;}
|
||||
static void unit_stop( void ) {}
|
||||
static CURLcode unit_setup(void) {return CURLE_OK;}
|
||||
static void unit_stop(void) {}
|
||||
|
||||
UNITTEST_START
|
||||
|
||||
|
|
@ -38,54 +38,54 @@ char output[24];
|
|||
|
||||
/* without a trailing zero */
|
||||
rc = curl_msnprintf(output, 4, "%.*s", width, buf);
|
||||
fail_unless( rc == 3 , "return code should be 3" );
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "bug"), "wrong output");
|
||||
|
||||
/* with a trailing zero */
|
||||
rc = curl_msnprintf(output, 4, "%.*s", width, str);
|
||||
fail_unless( rc == 3 , "return code should be 3" );
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "bug"), "wrong output");
|
||||
|
||||
width = 2;
|
||||
/* one byte less */
|
||||
rc = curl_msnprintf(output, 4, "%.*s", width, buf);
|
||||
fail_unless( rc == 2 , "return code should be 2" );
|
||||
fail_unless(rc == 2, "return code should be 2");
|
||||
fail_unless(!strcmp(output, "bu"), "wrong output");
|
||||
|
||||
/* string with larger precision */
|
||||
rc = curl_msnprintf(output, 8, "%.8s", str);
|
||||
fail_unless( rc == 3 , "return code should be 3" );
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "bug"), "wrong output");
|
||||
|
||||
/* longer string with precision */
|
||||
rc = curl_msnprintf(output, 8, "%.3s", "0123456789");
|
||||
fail_unless( rc == 3 , "return code should be 3" );
|
||||
fail_unless(rc == 3, "return code should be 3");
|
||||
fail_unless(!strcmp(output, "012"), "wrong output");
|
||||
|
||||
/* negative width */
|
||||
rc = curl_msnprintf(output, 8, "%-8s", str);
|
||||
fail_unless( rc == 8 , "return code should be 8" );
|
||||
fail_unless(rc == 8, "return code should be 8");
|
||||
fail_unless(!strcmp(output, "bug "), "wrong output");
|
||||
|
||||
/* larger width that string length */
|
||||
rc = curl_msnprintf(output, 8, "%8s", str);
|
||||
fail_unless( rc == 8 , "return code should be 8" );
|
||||
fail_unless(rc == 8, "return code should be 8");
|
||||
fail_unless(!strcmp(output, " bu"), "wrong output");
|
||||
|
||||
/* output a number in a limited output */
|
||||
rc = curl_msnprintf(output, 4, "%d", 10240);
|
||||
/* TODO: this should return 5 to be POSIX/snprintf compliant! */
|
||||
fail_unless( rc == 4 , "return code should be 4" );
|
||||
fail_unless(rc == 4, "return code should be 4");
|
||||
fail_unless(!strcmp(output, "102"), "wrong output");
|
||||
|
||||
/* padded strings */
|
||||
rc = curl_msnprintf(output, 16, "%8s%8s", str, str);
|
||||
fail_unless( rc == 16 , "return code should be 16" );
|
||||
fail_unless(rc == 16, "return code should be 16");
|
||||
fail_unless(!strcmp(output, " bug bu"), "wrong output");
|
||||
|
||||
/* padded numbers */
|
||||
rc = curl_msnprintf(output, 16, "%8d%8d", 1234, 5678);
|
||||
fail_unless( rc == 16 , "return code should be 16" );
|
||||
fail_unless(rc == 16, "return code should be 16");
|
||||
fail_unless(!strcmp(output, " 1234 567"), "wrong output");
|
||||
|
||||
UNITTEST_STOP
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ static void mydtor(void *p)
|
|||
free(ptr);
|
||||
}
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return Curl_hash_init(&hash_static, 7, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
Curl_hash_destroy(&hash_static);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2015 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -37,13 +37,13 @@ static void mydtor(void *p)
|
|||
(void)p; /* unused */
|
||||
}
|
||||
|
||||
static CURLcode unit_setup( void )
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return Curl_hash_init(&hash_static, slots, Curl_hash_str,
|
||||
Curl_str_key_compare, mydtor);
|
||||
}
|
||||
|
||||
static void unit_stop( void )
|
||||
static void unit_stop(void)
|
||||
{
|
||||
Curl_hash_destroy(&hash_static);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue