unit1305: Fixed the test to match our coding style.
This commit is contained in:
parent
0f07142509
commit
8702ebff74
@ -81,66 +81,66 @@ static void unit_stop( void )
|
|||||||
|
|
||||||
static Curl_addrinfo *fake_ai(void)
|
static Curl_addrinfo *fake_ai(void)
|
||||||
{
|
{
|
||||||
static Curl_addrinfo *ai;
|
static Curl_addrinfo *ai;
|
||||||
int ss_size;
|
int ss_size;
|
||||||
|
|
||||||
ss_size = sizeof (struct sockaddr_in);
|
ss_size = sizeof (struct sockaddr_in);
|
||||||
|
|
||||||
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
|
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if((ai->ai_canonname = strdup("dummy")) == NULL) {
|
if((ai->ai_canonname = strdup("dummy")) == NULL) {
|
||||||
free(ai);
|
free(ai);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
|
if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
|
||||||
free(ai->ai_canonname);
|
free(ai->ai_canonname);
|
||||||
free(ai);
|
free(ai);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ai->ai_family = AF_INET;
|
ai->ai_family = AF_INET;
|
||||||
ai->ai_addrlen = ss_size;
|
ai->ai_addrlen = ss_size;
|
||||||
|
|
||||||
return ai;
|
return ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode create_node(void)
|
static CURLcode create_node(void)
|
||||||
{
|
{
|
||||||
data_key = aprintf("%s:%d", "dummy", 0);
|
data_key = aprintf("%s:%d", "dummy", 0);
|
||||||
if (!data_key)
|
if (!data_key)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
data_node = calloc(1, sizeof(struct Curl_dns_entry));
|
data_node = calloc(1, sizeof(struct Curl_dns_entry));
|
||||||
if (!data_node)
|
if (!data_node)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
data_node->addr = fake_ai();
|
data_node->addr = fake_ai();
|
||||||
if (!data_node->addr)
|
if (!data_node->addr)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UNITTEST_START
|
UNITTEST_START
|
||||||
|
|
||||||
struct Curl_dns_entry *nodep;
|
struct Curl_dns_entry *nodep;
|
||||||
size_t key_len;
|
size_t key_len;
|
||||||
|
|
||||||
/* Test 1305 exits without adding anything to the hash */
|
/* Test 1305 exits without adding anything to the hash */
|
||||||
if (strcmp(arg, "1305") != 0) {
|
if (strcmp(arg, "1305") != 0) {
|
||||||
CURLcode rc = create_node();
|
CURLcode rc = create_node();
|
||||||
abort_unless(rc == CURLE_OK, "data node creation failed");
|
abort_unless(rc == CURLE_OK, "data node creation failed");
|
||||||
key_len = strlen(data_key);
|
key_len = strlen(data_key);
|
||||||
|
|
||||||
nodep = Curl_hash_add(hp, data_key, key_len+1, data_node);
|
nodep = Curl_hash_add(hp, data_key, key_len+1, data_node);
|
||||||
abort_unless(nodep, "insertion into hash failed");
|
abort_unless(nodep, "insertion into hash failed");
|
||||||
/* Freeing will now be done by Curl_hash_destroy */
|
/* Freeing will now be done by Curl_hash_destroy */
|
||||||
data_node = NULL;
|
data_node = NULL;
|
||||||
|
|
||||||
/* To do: test retrieval, deletion, edge conditions */
|
/* To do: test retrieval, deletion, edge conditions */
|
||||||
}
|
}
|
||||||
|
|
||||||
UNITTEST_STOP
|
UNITTEST_STOP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user