Skip to content

Commit

Permalink
test byte conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Jul 26, 2024
1 parent 2560d5c commit b277aa1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/number/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
error::{make_error, ErrorKind, ParseError},
sequence::pair,
AsBytes, AsChar, Compare, Either, Emit, Err, Input, IsStreaming, Mode, Needed, Offset, OutputM,
Parser,
OutputMode, Parser,
};

pub mod complete;
Expand Down Expand Up @@ -1397,8 +1397,23 @@ where
&mut self,
input: I,
) -> crate::PResult<OM, I, Self::Output, Self::Error> {
let (i, s) =
recognize_float_or_exceptions().process::<OutputM<Emit, OM::Error, OM::Incomplete>>(input)?;
let inp = input.clone();
let (_, s) = recognize_float_or_exceptions()
.process::<OutputM<Emit, OM::Error, OM::Incomplete>>(inp.as_bytes())

Check warning on line 1402 in src/number/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/number/mod.rs#L1402

Added line #L1402 was not covered by tests
.map_err(
|e: crate::Err<(), <<OM as OutputMode>::Error as Mode>::Output<()>>| match e {
Err::Incomplete(i) => Err::Incomplete(i),
Err::Error(_) => Err::Error(OM::Error::bind(|| {
E::from_error_kind(input.clone(), crate::error::ErrorKind::Float)

Check warning on line 1407 in src/number/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/number/mod.rs#L1404-L1407

Added lines #L1404 - L1407 were not covered by tests
})),
Err::Failure(_) => Err::Failure(E::from_error_kind(
input.clone(),
crate::error::ErrorKind::Float,

Check warning on line 1411 in src/number/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/number/mod.rs#L1409-L1411

Added lines #L1409 - L1411 were not covered by tests
)),
},
)?;
let recognized_length = s.len();
let (i, s) = input.take_split(recognized_length);

match s.parse_to() {
Some(f) => Ok((i, OM::Output::bind(|| f))),
Expand Down

0 comments on commit b277aa1

Please sign in to comment.