Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
9b343678
Commit
9b343678
authored
Nov 20, 2014
by
Matt Stancliff
Browse files
Add simple ll2string() tests
parent
8febcffd
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/util.c
View file @
9b343678
...
@@ -636,6 +636,47 @@ static void test_string2l(void) {
...
@@ -636,6 +636,47 @@ static void test_string2l(void) {
#endif
#endif
}
}
static
void
test_ll2string
(
void
)
{
char
buf
[
32
];
long
long
v
;
int
sz
;
v
=
0
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
1
);
assert
(
!
strcmp
(
buf
,
"0"
));
v
=
-
1
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
2
);
assert
(
!
strcmp
(
buf
,
"-1"
));
v
=
99
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
2
);
assert
(
!
strcmp
(
buf
,
"99"
));
v
=
-
99
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
3
);
assert
(
!
strcmp
(
buf
,
"-99"
));
v
=
-
2147483648
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
11
);
assert
(
!
strcmp
(
buf
,
"-2147483648"
));
v
=
LLONG_MIN
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
20
);
assert
(
!
strcmp
(
buf
,
"-9223372036854775808"
));
v
=
LLONG_MAX
;
sz
=
ll2string
(
buf
,
sizeof
buf
,
v
);
assert
(
sz
==
19
);
assert
(
!
strcmp
(
buf
,
"9223372036854775807"
));
}
#define UNUSED(x) (void)(x)
#define UNUSED(x) (void)(x)
int
utilTest
(
int
argc
,
char
**
argv
)
{
int
utilTest
(
int
argc
,
char
**
argv
)
{
UNUSED
(
argc
);
UNUSED
(
argc
);
...
@@ -643,6 +684,7 @@ int utilTest(int argc, char **argv) {
...
@@ -643,6 +684,7 @@ int utilTest(int argc, char **argv) {
test_string2ll
();
test_string2ll
();
test_string2l
();
test_string2l
();
test_ll2string
();
return
0
;
return
0
;
}
}
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment