Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
94b3528f
Commit
94b3528f
authored
22 years ago
by
Mark Grondona
Browse files
Options
Downloads
Patches
Plain Diff
o define TEST macro to clean up body of main render tests clearer
parent
00f975dd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/pack-test.c
+28
-31
28 additions, 31 deletions
src/test/pack-test.c
with
28 additions
and
31 deletions
src/test/pack-test.c
+
28
−
31
View file @
94b3528f
...
@@ -14,6 +14,17 @@
...
@@ -14,6 +14,17 @@
#include
<src/common/pack.h>
#include
<src/common/pack.h>
#include
<src/common/xmalloc.h>
#include
<src/common/xmalloc.h>
/* Test for failure:
*/
#define TEST(_tst, _msg) do { \
if (_tst) { \
printf("%s\n", _msg); \
failed++; \
} else \
passed++; \
} while (0)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
passed
=
0
;
int
passed
=
0
;
...
@@ -35,51 +46,37 @@ int main (int argc, char *argv[])
...
@@ -35,51 +46,37 @@ int main (int argc, char *argv[])
packstr
(
testbytes
,
&
bufp
,
&
len_buf
);
packstr
(
testbytes
,
&
bufp
,
&
len_buf
);
packstr
(
teststring
,
&
bufp
,
&
len_buf
);
packstr
(
teststring
,
&
bufp
,
&
len_buf
);
packstr
(
nullstr
,
&
bufp
,
&
len_buf
);
packstr
(
nullstr
,
&
bufp
,
&
len_buf
);
packstr
(
"literal"
,
&
bufp
,
&
len_buf
);
packstr
(
""
,
&
bufp
,
&
len_buf
);
printf
(
"wrote %d bytes
\n
"
,
len_buf
);
printf
(
"wrote %d bytes
\n
"
,
len_buf
);
bufp
=
buffer
;
bufp
=
buffer
;
len_buf
=
sizeof
(
buffer
);
len_buf
=
sizeof
(
buffer
);
unpack16
(
&
out16
,
&
bufp
,
&
len_buf
);
unpack16
(
&
out16
,
&
bufp
,
&
len_buf
);
TEST
(
out16
!=
test16
,
"un/pack16 failed"
);
if
(
out16
!=
test16
)
{
printf
(
"un/pack16 failed
\n
"
);
failed
++
;
}
else
passed
++
;
unpack32
(
&
out32
,
&
bufp
,
&
len_buf
);
unpack32
(
&
out32
,
&
bufp
,
&
len_buf
);
TEST
(
out32
!=
test32
,
"un/pack32 failed"
);
if
(
out32
!=
test32
)
{
printf
(
"un/pack32 failed
\n
"
);
failed
++
;
}
else
passed
++
;
unpackstr_ptr
(
&
outbytes
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
unpackstr_ptr
(
&
outbytes
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
TEST
(
strcmp
(
testbytes
,
outbytes
)
!=
0
,
"un/packstr_ptr failed"
);
if
(
strcmp
(
testbytes
,
outbytes
)
!=
0
)
{
printf
(
"un/packstr_ptr failed
\n
"
);
failed
++
;
}
else
passed
++
;
unpackstr_xmalloc
(
&
outstring
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
unpackstr_xmalloc
(
&
outstring
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
TEST
(
strcmp
(
teststring
,
outstring
)
!=
0
,
"un/packstr_xmalloc failed"
);
if
(
strcmp
(
teststring
,
outstring
)
!=
0
)
{
xfree
(
outstring
);
printf
(
"un/packstr_xmalloc failed
\n
"
);
failed
++
;
}
else
{
passed
++
;
xfree
(
outstring
);
}
unpackstr_xmalloc
(
&
nullstr
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
unpackstr_xmalloc
(
&
nullstr
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
TEST
(
nullstr
!=
NULL
,
"un/packstr of null string failed."
);
unpackstr_xmalloc
(
&
outstring
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
TEST
(
strcmp
(
"literal"
,
outstring
)
!=
0
,
"un/packstr of string literal failed"
);
xfree
(
outstring
);
unpackstr_xmalloc
(
&
outstring
,
&
byte_cnt
,
&
bufp
,
&
len_buf
);
TEST
(
strcmp
(
""
,
outstring
)
!=
0
,
"un/packstr of string
\"\"
failed"
);
xfree
(
outstring
);
if
(
nullstr
!=
NULL
)
{
printf
(
"un/packstr of null string failed
\n
"
);
failed
++
;
}
else
passed
++
;
printf
(
"%d tests passed, %d failed.
\n
"
,
passed
,
failed
);
printf
(
"%d tests passed, %d failed.
\n
"
,
passed
,
failed
);
...
...
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