move fully_sumed to test_util

This commit is contained in:
Edward Shen 2021-02-24 18:00:15 -05:00
parent 19e18df973
commit 42a48efe9d
Signed by: edward
GPG key ID: 19182661E818369F
2 changed files with 12 additions and 11 deletions

View file

@ -774,15 +774,10 @@ fn take_common<F: Fn(u8) -> bool>(i: &[u8], f: F) -> IResult<&[u8], &[u8]> {
} }
} }
#[cfg(test)]
fn fully_consumed<T>(t: T) -> (&'static [u8], T) {
(&[], t)
}
#[cfg(test)] #[cfg(test)]
mod comments { mod comments {
use super::*; use super::*;
use crate::test_util::comment as parsed_comment; use crate::test_util::{comment as parsed_comment, fully_consumed};
#[test] #[test]
fn semicolon() { fn semicolon() {
@ -812,7 +807,7 @@ mod comments {
#[cfg(test)] #[cfg(test)]
mod section_headers { mod section_headers {
use super::*; use super::*;
use crate::test_util::section_header as parsed_section_header; use crate::test_util::{fully_consumed, section_header as parsed_section_header};
#[test] #[test]
fn no_subsection() { fn no_subsection() {
@ -884,6 +879,7 @@ mod section_headers {
#[cfg(test)] #[cfg(test)]
mod config_name { mod config_name {
use super::*; use super::*;
use crate::test_util::fully_consumed;
#[test] #[test]
fn just_name() { fn just_name() {
@ -940,7 +936,7 @@ mod section_body {
#[cfg(test)] #[cfg(test)]
mod value_no_continuation { mod value_no_continuation {
use super::*; use super::*;
use crate::test_util::value_event; use crate::test_util::{fully_consumed, value_event};
#[test] #[test]
fn no_comment() { fn no_comment() {
@ -1019,7 +1015,7 @@ mod value_no_continuation {
#[cfg(test)] #[cfg(test)]
mod value_continuation { mod value_continuation {
use super::*; use super::*;
use crate::test_util::{newline_event, value_done_event, value_not_done_event}; use crate::test_util::{fully_consumed, newline_event, value_done_event, value_not_done_event};
#[test] #[test]
fn simple_continuation() { fn simple_continuation() {
@ -1082,8 +1078,9 @@ mod value_continuation {
mod section { mod section {
use super::*; use super::*;
use crate::test_util::{ use crate::test_util::{
comment_event, name_event, newline_event, section_header as parsed_section_header, comment_event, fully_consumed, name_event, newline_event,
value_done_event, value_event, value_not_done_event, whitespace_event, section_header as parsed_section_header, value_done_event, value_event,
value_not_done_event, whitespace_event,
}; };
#[test] #[test]

View file

@ -67,3 +67,7 @@ pub(crate) fn comment(comment_tag: char, comment: &'static str) -> ParsedComment
comment: Cow::Borrowed(comment.into()), comment: Cow::Borrowed(comment.into()),
} }
} }
pub(crate) fn fully_consumed<T>(t: T) -> (&'static [u8], T) {
(&[], t)
}