Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / fuzzing / stdlib / atof_differential_fuzz.cpp
blobeeb96aef9abe520e56fbe879ad885e26f5387ac3
1 //===-- atof_fuzz.cpp -----------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// Fuzzing test for llvm-libc atof implementation.
10 ///
11 //===----------------------------------------------------------------------===//
12 #include "src/stdlib/atof.h"
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <stdlib.h>
17 #include "fuzzing/stdlib/StringParserOutputDiff.h"
19 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
20 uint8_t *container = new uint8_t[size + 1];
21 if (!container)
22 __builtin_trap();
23 size_t i;
25 for (i = 0; i < size; ++i)
26 container[i] = data[i];
27 container[size] = '\0'; // Add null terminator to container.
29 StringParserOutputDiff<double>(&LIBC_NAMESPACE::atof, &::atof, container,
30 size);
31 delete[] container;
32 return 0;