Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
08a77025
Commit
08a77025
authored
14 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
unit1300: code style cleanup
parent
7a4b5079
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/unit1300.c
+52
-53
52 additions, 53 deletions
tests/unit/unit1300.c
with
52 additions
and
53 deletions
tests/unit/unit1300.c
+
52
−
53
View file @
08a77025
...
...
@@ -7,24 +7,24 @@
struct
curl_llist
*
llist
;
static
void
test_curl_llist_dtor
(
void
*
key
,
void
*
value
)
static
void
test_curl_llist_dtor
(
void
*
key
,
void
*
value
)
{
/* used by the llist API, does nothing here */
(
void
)
key
;
(
void
)
value
;
}
static
CURLcode
unit_setup
(
void
)
static
CURLcode
unit_setup
(
void
)
{
llist
=
Curl_llist_alloc
(
test_curl_llist_dtor
);
llist
=
Curl_llist_alloc
(
test_curl_llist_dtor
);
if
(
!
llist
)
return
CURLE_OUT_OF_MEMORY
;
return
CURLE_OK
;
}
static
void
unit_stop
(
void
)
static
void
unit_stop
(
void
)
{
Curl_llist_destroy
(
llist
,
NULL
);
Curl_llist_destroy
(
llist
,
NULL
);
}
UNITTEST_START
...
...
@@ -35,14 +35,14 @@ UNITTEST_START
struct
curl_llist_element
*
element_next
;
struct
curl_llist_element
*
element_prev
;
struct
curl_llist_element
*
to_remove
;
size_t
llist_size
=
Curl_llist_count
(
llist
);
size_t
llist_size
=
Curl_llist_count
(
llist
);
int
curlErrCode
=
0
;
fail_unless
(
llist
->
size
==
0
,
"list initial size should be zero"
);
fail_unless
(
llist
->
head
==
NULL
,
"list head should initiate to NULL"
);
fail_unless
(
llist
->
tail
==
NULL
,
"list tail should intiate to NULL"
);
fail_unless
(
llist
->
dtor
==
test_curl_llist_dtor
,
"list dtor shold initiate to test_curl_llist_dtor"
);
fail_unless
(
llist
->
size
==
0
,
"list initial size should be zero"
);
fail_unless
(
llist
->
head
==
NULL
,
"list head should initiate to NULL"
);
fail_unless
(
llist
->
tail
==
NULL
,
"list tail should intiate to NULL"
);
fail_unless
(
llist
->
dtor
==
test_curl_llist_dtor
,
"list dtor shold initiate to test_curl_llist_dtor"
);
/**
* testing Curl_llist_insert_next
...
...
@@ -55,15 +55,15 @@ UNITTEST_START
*/
curlErrCode
=
Curl_llist_insert_next
(
llist
,
llist
->
head
,
&
unusedData_case1
);
if
(
curlErrCode
==
1
)
{
fail_unless
(
Curl_llist_count
(
llist
)
==
1
,
"List size should be 1 after adding a new element"
);
if
(
curlErrCode
==
1
)
{
fail_unless
(
Curl_llist_count
(
llist
)
==
1
,
"List size should be 1 after adding a new element"
);
/*test that the list head data holds my unusedData */
fail_unless
(
llist
->
head
->
ptr
==
&
unusedData_case1
,
"List size should be 1 after adding a new element"
);
fail_unless
(
llist
->
head
->
ptr
==
&
unusedData_case1
,
"List size should be 1 after adding a new element"
);
/*same goes for the list tail */
fail_unless
(
llist
->
tail
==
llist
->
head
,
"List size should be 1 after adding a new element"
);
fail_unless
(
llist
->
tail
==
llist
->
head
,
"List size should be 1 after adding a new element"
);
/**
* testing Curl_llist_insert_next
...
...
@@ -74,17 +74,17 @@ UNITTEST_START
* 2: the list tail should be our newly created element
*/
curlErrCode
=
Curl_llist_insert_next
(
llist
,
llist
->
head
,
&
unusedData_case3
);
if
(
curlErrCode
==
1
)
{
fail_unless
(
llist
->
head
->
next
->
ptr
==
&
unusedData_case3
,
"the node next to head is not getting set correctly"
);
curlErrCode
=
Curl_llist_insert_next
(
llist
,
llist
->
head
,
&
unusedData_case3
);
if
(
curlErrCode
==
1
)
{
fail_unless
(
llist
->
head
->
next
->
ptr
==
&
unusedData_case3
,
"the node next to head is not getting set correctly"
);
fail_unless
(
llist
->
tail
->
ptr
==
&
unusedData_case3
,
"the list tail is not getting set correctly"
);
}
else
{
printf
(
"skipping Curl_llist_insert_next as a non "
"success error code was returned
\n
"
);
"success error code was returned
\n
"
);
}
/**
...
...
@@ -98,22 +98,22 @@ UNITTEST_START
curlErrCode
=
Curl_llist_insert_next
(
llist
,
llist
->
head
,
&
unusedData_case2
);
if
(
curlErrCode
==
1
)
{
if
(
curlErrCode
==
1
)
{
fail_unless
(
llist
->
head
->
next
->
ptr
==
&
unusedData_case2
,
"the node next to head is not getting set correctly"
);
"the node next to head is not getting set correctly"
);
/* better safe than sorry, check that the tail isn't corrupted */
fail_unless
(
llist
->
tail
->
ptr
!=
&
unusedData_case2
,
"the list tail is not getting set correctly"
);
"the list tail is not getting set correctly"
);
}
else
{
printf
(
"skipping Curl_llist_insert_next as a non "
"success error code was returned
\n
"
);
"success error code was returned
\n
"
);
}
}
else
{
printf
(
"skipping Curl_llist_insert_next as a non "
"success error code was returned
\n
"
);
"success error code was returned
\n
"
);
}
/* unit tests for Curl_llist_remove */
...
...
@@ -129,16 +129,16 @@ UNITTEST_START
head
=
llist
->
head
;
element_next
=
head
->
next
;
llist_size
=
Curl_llist_count
(
llist
);
llist_size
=
Curl_llist_count
(
llist
);
Curl_llist_remove
(
llist
,
llist
->
head
,
NULL
);
Curl_llist_remove
(
llist
,
llist
->
head
,
NULL
);
fail_unless
(
Curl_llist_count
(
llist
)
==
(
llist_size
-
1
)
,
"llist size not decremented as expected"
);
fail_unless
(
llist
->
head
==
element_next
,
"llist new head not modified properly"
);
fail_unless
(
llist
->
head
->
prev
==
NULL
,
"new head previous not set to null"
);
fail_unless
(
Curl_llist_count
(
llist
)
==
(
llist_size
-
1
),
"llist size not decremented as expected"
);
fail_unless
(
llist
->
head
==
element_next
,
"llist new head not modified properly"
);
fail_unless
(
llist
->
head
->
prev
==
NULL
,
"new head previous not set to null"
);
/**
* case 2:
...
...
@@ -150,16 +150,16 @@ UNITTEST_START
* 2: element->previous->next will be element->next
* 3: element->next->previous will be element->previous
*/
Curl_llist_insert_next
(
llist
,
llist
->
head
,
&
unusedData_case3
);
llist_size
=
Curl_llist_count
(
llist
);
Curl_llist_insert_next
(
llist
,
llist
->
head
,
&
unusedData_case3
);
llist_size
=
Curl_llist_count
(
llist
);
to_remove
=
llist
->
head
->
next
;
element_next
=
to_remove
->
next
;
element_prev
=
to_remove
->
prev
;
Curl_llist_remove
(
llist
,
to_remove
,
NULL
);
fail_unless
(
element_prev
->
next
==
element_next
,
"element previous->next is not being adjusted"
);
fail_unless
(
element_next
->
prev
==
element_prev
,
"element next->previous is not being adjusted"
);
Curl_llist_remove
(
llist
,
to_remove
,
NULL
);
fail_unless
(
element_prev
->
next
==
element_next
,
"element previous->next is not being adjusted"
);
fail_unless
(
element_next
->
prev
==
element_prev
,
"element next->previous is not being adjusted"
);
/**
* case 3:
...
...
@@ -173,10 +173,9 @@ UNITTEST_START
to_remove
=
llist
->
tail
;
element_prev
=
to_remove
->
prev
;
Curl_llist_remove
(
llist
,
to_remove
,
NULL
);
fail_unless
(
llist
->
tail
==
element_prev
,
"llist tail is not being adjusted when removing tail"
);
fail_unless
(
1
==
0
,
"making sure i'm compiling"
);
Curl_llist_remove
(
llist
,
to_remove
,
NULL
);
fail_unless
(
llist
->
tail
==
element_prev
,
"llist tail is not being adjusted when removing tail"
);
/**
* case 4:
...
...
@@ -188,10 +187,10 @@ UNITTEST_START
*/
to_remove
=
llist
->
head
;
Curl_llist_remove
(
llist
,
to_remove
,
NULL
);
fail_unless
(
llist
->
head
==
NULL
,
"llist head is not NULL while the llist is empty"
);
fail_unless
(
llist
->
tail
==
NULL
,
"llist tail is not NULL while the llist is empty"
);
Curl_llist_remove
(
llist
,
to_remove
,
NULL
);
fail_unless
(
llist
->
head
==
NULL
,
"llist head is not NULL while the llist is empty"
);
fail_unless
(
llist
->
tail
==
NULL
,
"llist tail is not NULL while the llist is empty"
);
UNITTEST_STOP
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment