<commit_before>#![no_main]

use arbitrary::Arbitrary;
use libfuzzer_sys::fuzz_target;
use std::mem;

#[derive(Arbitrary, Debug)]
enum IntegerInput {
    I8(i8),
    U8(u8),
    I16(i16),
    U16(u16),
    I32(i32),
    U32(u32),
    I64(i64),
    U64(u64),
    I128(i128),
    U128(u128),
    Isize(isize),
    Usize(usize),
}

fuzz_target!(|input: IntegerInput| {
    let mut buffer = itoa::Buffer::new();
    let string = match input {
        IntegerInput::I8(val) => buffer.format(val),
        IntegerInput::U8(val) => buffer.format(val),
        IntegerInput::I16(val) => buffer.format(val),
        IntegerInput::U16(val) => buffer.format(val),
        IntegerInput::I32(val) => buffer.format(val),
        IntegerInput::U32(val) => buffer.format(val),
        IntegerInput::I64(val) => buffer.format(val),
        IntegerInput::U64(val) => buffer.format(val),
        IntegerInput::I128(val) => buffer.format(val),
        IntegerInput::U128(val) => buffer.format(val),
        IntegerInput::Isize(val) => buffer.format(val),
        IntegerInput::Usize(val) => buffer.format(val),
    };
    assert!(string.len() <= mem::size_of::<itoa::Buffer>());
});<commit_msg>Assert formatted integer parses back to the same value<commit_after>#![no_main]

use arbitrary::Arbitrary;
use libfuzzer_sys::fuzz_target;
use std::mem;

#[derive(Arbitrary, Debug)]
enum IntegerInput {
    I8(i8),
    U8(u8),
    I16(i16),
    U16(u16),
    I32(i32),
    U32(u32),
    I64(i64),
    U64(u64),
    I128(i128),
    U128(u128),
    Isize(isize),
    Usize(usize),
}

macro_rules! test_itoa {
    ($val:expr) => {
        match $val {
            val => {
                let mut buffer = itoa::Buffer::new();
                let string = buffer.format(val);
                assert!(string.len() <= mem::size_of::<itoa::Buffer>());
                assert_eq!(val, string.parse().unwrap());
            }
        }
    };
}

fuzz_target!(|input: IntegerInput| {
    match input {
        IntegerInput::I8(val) => test_itoa!(val),
        IntegerInput::U8(val) => test_itoa!(val),
        IntegerInput::I16(val) => test_itoa!(val),
        IntegerInput::U16(val) => test_itoa!(val),
        IntegerInput::I32(val) => test_itoa!(val),
        IntegerInput::U32(val) => test_itoa!(val),
        IntegerInput::I64(val) => test_itoa!(val),
        IntegerInput::U64(val) => test_itoa!(val),
        IntegerInput::I128(val) => test_itoa!(val),
        IntegerInput::U128(val) => test_itoa!(val),
        IntegerInput::Isize(val) => test_itoa!(val),
        IntegerInput::Usize(val) => test_itoa!(val),
    }
});
{'fraction_non_alphanumeric': 0.18262548262548262, 'fraction_numerical': 0.04633204633204633, 'mean_word_length': 3.086750788643533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '752330', 'n_tokens_mistral': 996, 'n_tokens_neox': 936, 'n_words': 135}