<commit_before>#![cfg(feature = "serde-1")]
extern crate arrayvec;
extern crate serde_test;

mod array_vec {
    use arrayvec::ArrayVec;

    use serde_test::{Token, assert_tokens};

    #[test]
    fn test_ser_de_empty() {
        let vec = ArrayVec::<[u32; 0]>::new();

        assert_tokens(&vec, &[
            Token::Seq { len: Some(0) },
            Token::SeqEnd,
        ]);
    }


    #[test]
    fn test_ser_de() {
        let mut vec = ArrayVec::<[u32; 3]>::new();
        vec.push(20);
        vec.push(55);
        vec.push(123);

        assert_tokens(&vec, &[
            Token::Seq { len: Some(3) },
            Token::U32(20),
            Token::U32(55),
            Token::U32(123),
            Token::SeqEnd,
        ]);
    }
}

mod array_string {
    use arrayvec::ArrayString;

    use serde_test::{Token, assert_tokens};

    #[test]
    fn test_ser_de_empty() {
        let string = ArrayString::<[u8; 0]>::new();

        assert_tokens(&string, &[
            Token::Str(""),
        ]);
    }


    #[test]
    fn test_ser_de() {
        let string = ArrayString::<[u8; 9]>::from("1234 abcd")
            .expect("expected exact specified capacity to be enough");

        assert_tokens(&string, &[
            Token::Str("1234 abcd"),
        ]);
    }
}<commit_msg>Add failure tests for serde implementations<commit_after>#![cfg(feature = "serde-1")]
extern crate arrayvec;
extern crate serde_test;

mod array_vec {
    use arrayvec::ArrayVec;

    use serde_test::{Token, assert_tokens, assert_de_tokens_error};

    #[test]
    fn test_ser_de_empty() {
        let vec = ArrayVec::<[u32; 0]>::new();

        assert_tokens(&vec, &[
            Token::Seq { len: Some(0) },
            Token::SeqEnd,
        ]);
    }


    #[test]
    fn test_ser_de() {
        let mut vec = ArrayVec::<[u32; 3]>::new();
        vec.push(20);
        vec.push(55);
        vec.push(123);

        assert_tokens(&vec, &[
            Token::Seq { len: Some(3) },
            Token::U32(20),
            Token::U32(55),
            Token::U32(123),
            Token::SeqEnd,
        ]);
    }

    #[test]
    fn test_de_too_large() {
        assert_de_tokens_error::<ArrayVec<[u32; 2]>>(&[
            Token::Seq { len: Some(3) },
            Token::U32(13),
            Token::U32(42),
            Token::U32(68),
        ], "invalid length 3, expected an array with no more than 2 items");
    }
}

mod array_string {
    use arrayvec::ArrayString;

    use serde_test::{Token, assert_tokens, assert_de_tokens_error};

    #[test]
    fn test_ser_de_empty() {
        let string = ArrayString::<[u8; 0]>::new();

        assert_tokens(&string, &[
            Token::Str(""),
        ]);
    }


    #[test]
    fn test_ser_de() {
        let string = ArrayString::<[u8; 9]>::from("1234 abcd")
            .expect("expected exact specified capacity to be enough");

        assert_tokens(&string, &[
            Token::Str("1234 abcd"),
        ]);
    }

    #[test]
    fn test_de_too_large() {
        assert_de_tokens_error::<ArrayString<[u8; 2]>>(&[
            Token::Str("afd")
        ], "invalid length 3, expected a string no more than 2 bytes long");
    }
}
{'fraction_non_alphanumeric': 0.16357927786499216, 'fraction_numerical': 0.0326530612244898, 'mean_word_length': 2.0723240115718418, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4773942', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1054, 'n_words': 208}