stdlib: add a test to check size of integer and floating-point types

This dictates the behavior of strtoll, strtoull, strtold mainly.
This commit is contained in:
Lephenixnoir 2021-05-19 21:45:04 +02:00
parent ae242222b3
commit a487b64fb3
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,7 @@ set(SOURCES
src/inttypes/sizes.c
# stdlib
src/stdlib/arith.c
src/stdlib/sizes.c
# string
src/string/memarray.c
src/string/core.c

View File

@ -19,6 +19,7 @@ extern ft_test ft_inttypes_functions;
/* stdlib */
extern ft_test ft_stdlib_arith;
extern ft_test ft_stdlib_sizes;
/* string */
extern ft_test ft_string_memset;

View File

@ -35,6 +35,7 @@ ft_list headers_libc[] = {
}}, */
{ "<stdlib.h>", (ft_test*[]){
&ft_stdlib_arith,
&ft_stdlib_sizes,
NULL,
}},
{ "<string.h>", (ft_test*[]){

22
src/stdlib/sizes.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdlib.h>
#include <ft/test.h>
#include <ft/all-tests.h>
static void _stdlib_sizes(ft_test *t)
{
/* TODO: Use %zu once available in *printf */
ft_log(t, "Size of types for conversion:\n\n");
ft_log(t, " %d float\n", (int)sizeof(float));
ft_log(t, " %d double\n", (int)sizeof(double));
ft_log(t, " %d long double\n", (int)sizeof(long double));
ft_log(t, " %d int\n", (int)sizeof(int));
ft_log(t, " %d long int\n", (int)sizeof(long int));
ft_log(t, " %d long long int\n", (int)sizeof(long long int));
}
ft_test ft_stdlib_sizes = {
.name = "Size of numeric types",
.function = _stdlib_sizes,
};