<commit_before>#[cfg(feature = "alloc")]
use crate::branch::alt;
#[cfg(feature = "alloc")]
use crate::bytes::complete::tag;
#[cfg(feature = "alloc")]
use crate::bytes::complete::{escaped, escaped_transform};
use crate::character::is_alphabetic;
use crate::character::streaming::{
  alpha1 as alpha, alphanumeric1 as alphanumeric, digit1 as digit, hex_digit1 as hex_digit,
  multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
};
#[cfg(feature = "alloc")]
use crate::combinator::{map, value};
use crate::error::ErrorKind;
use crate::internal::{Err, IResult, Needed};
#[cfg(feature = "alloc")]
use crate::lib::std::string::String;
#[cfg(feature = "alloc")]
use crate::lib::std::vec::Vec;

#[test]
fn is_a() {
  use crate::bytes::streaming::is_a;

  fn a_or_b(i: &[u8]) -> IResult<&[u8], &[u8]> {
    is_a("ab")(i)
  }

  let a = &b"abcd"[..];
  assert_eq!(a_or_b(a), Ok((&b"cd"[..], &b"ab"[..])));

  let b = &b"bcde"[..];
  assert_eq!(a_or_b(b), Ok((&b"cde"[..], &b"b"[..])));

  let c = &b"cdef"[..];
  assert_eq!(
    a_or_b(c),<commit_msg>organize imports by feature<commit_after>use crate::character::is_alphabetic;
use crate::character::streaming::{
  alpha1 as alpha, alphanumeric1 as alphanumeric, digit1 as digit, hex_digit1 as hex_digit,
  multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
};
use crate::error::ErrorKind;
use crate::internal::{Err, IResult, Needed};
#[cfg(feature = "alloc")]
use crate::{
  branch::alt,
  bytes::complete::{escaped, escaped_transform, tag},
  combinator::{map, value},
  lib::std::string::String,
  lib::std::vec::Vec,
};

#[test]
fn is_a() {
  use crate::bytes::streaming::is_a;

  fn a_or_b(i: &[u8]) -> IResult<&[u8], &[u8]> {
    is_a("ab")(i)
  }

  let a = &b"abcd"[..];
  assert_eq!(a_or_b(a), Ok((&b"cd"[..], &b"ab"[..])));

  let b = &b"bcde"[..];
  assert_eq!(a_or_b(b), Ok((&b"cde"[..], &b"b"[..])));

  let c = &b"cdef"[..];
  assert_eq!(
    a_or_b(c),
{'fraction_non_alphanumeric': 0.2372619660319094, 'fraction_numerical': 0.010293360782295419, 'mean_word_length': 5.657534246575342, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '188609', 'n_tokens_mistral': 821, 'n_tokens_neox': 807, 'n_words': 158}