use crate::ErrorList;
use crate::FullContext;
use crate::Output;
#[derive(Debug)]
pub struct StoryTitle {
pub title: String,
}
impl StoryTitle {
pub fn parse(context: FullContext) -> Output<Result<Self, ErrorList>> {
Output::new(Ok(StoryTitle {
title: context.get_contents().to_string(),
}))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn basic() {
let input = r#"foo
bar
baz"#
.to_string();
let out = StoryTitle::parse(FullContext::from(None, input.clone()));
assert!(!out.has_warnings());
let (res, _) = out.take();
assert!(res.is_ok());
let content = res.ok().unwrap();
assert_eq!(content.title, input);
}
}