Skip to content

Commit ec66409

Browse files
committed
adding tests/strtod_test.c
1 parent 6eb3dcd commit ec66409

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/strtod_test.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "fast_float/fast_float_strtod.h"
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <errno.h>
5+
6+
int main() {
7+
// Test successful conversion
8+
const char *str1 = "3.14159";
9+
char *end1;
10+
errno = 0;
11+
double d1 = fast_float_strtod(str1, &end1);
12+
printf("Input: %s\n", str1);
13+
printf("Converted: %f\n", d1);
14+
printf("End pointer: %s\n", end1);
15+
printf("errno: %d\n", errno);
16+
17+
// Test invalid input
18+
const char *str2 = "invalid";
19+
char *end2;
20+
errno = 0;
21+
double d2 = fast_float_strtod(str2, &end2);
22+
printf("\nInput: %s\n", str2);
23+
printf("Converted: %f\n", d2);
24+
printf("End pointer: %s\n", end2);
25+
printf("errno: %d\n", errno);
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)