Write some tests to handle date parsing with a range of days

This commit is contained in:
Savanni D'Gerinel 2024-03-31 18:08:19 -04:00
parent 5cdcf0499c
commit 474d648ae4
3 changed files with 56 additions and 0 deletions

View File

@ -911,4 +911,40 @@ mod file_test {
}, },
); );
} }
#[ignore]
#[test]
fn it_handles_shuwa_genan_file() {
with_file(
std::path::Path::new("test_data/2019.02.15_shuwa_genan_annotated.sgf"),
|trees| {
assert_eq!(trees.len(), 1);
let game = &trees[0];
assert_eq!(game.game_type, GameType::Go);
assert_eq!(
game.board_size,
Size {
width: 19,
height: 19
}
);
assert_eq!(
game.black_player,
Player {
name: Some("Honinbo Shuwa".to_owned()),
rank: Some("7P".to_owned()),
team: None
}
);
assert_eq!(
game.white_player,
Player {
name: Some("Inoue(Genan)Inseki".to_owned()),
rank: Some("8P".to_owned()),
team: None
}
);
},
)
}
} }

View File

@ -463,4 +463,15 @@ mod tests {
}, },
); );
} }
// This is a file
#[test]
fn it_handles_shuwa_genan_file() {
with_file(
std::path::Path::new("test_data/2020 USGO DDK, Round 1.sgf"),
|trees| {
assert_eq!(trees.len(), 2);
},
)
}
} }

View File

@ -1252,6 +1252,15 @@ mod date_test {
Date::Date(NaiveDate::from_ymd_opt(1996, 12, 28).unwrap()) Date::Date(NaiveDate::from_ymd_opt(1996, 12, 28).unwrap())
]) ])
); );
assert_matches!(
parse_date_field::<nom::error::VerboseError<&str>>().parse("1842-5-16-18"),
Ok((_, date)) => assert_eq!(date, vec![
Date::Date(NaiveDate::from_ymd_opt(1842, 5, 16).unwrap()),
Date::Date(NaiveDate::from_ymd_opt(1842, 5, 17).unwrap()),
Date::Date(NaiveDate::from_ymd_opt(1842, 5, 18).unwrap()),
])
);
} }
#[test] #[test]