From 18be481926f442a3ac0c79f6c682430d14b1ff2b Mon Sep 17 00:00:00 2001 From: terkwood <38859656+Terkwood@users.noreply.github.com> Date: Sat, 14 Mar 2020 09:43:13 -0400 Subject: [PATCH] Add test --- tinybrain/src/lib.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tinybrain/src/lib.rs b/tinybrain/src/lib.rs index 5eb1e40c8..2680edd24 100644 --- a/tinybrain/src/lib.rs +++ b/tinybrain/src/lib.rs @@ -25,7 +25,7 @@ pub struct ComputeMove { game_id: GameId, game_state: GameState, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct MoveComputed(MakeMoveCommand); impl MoveComputed { @@ -47,10 +47,25 @@ impl MoveComputed { mod tests { use super::*; use katago::json::*; + use micro_model_moves::*; use uuid::Uuid; #[test] fn move_computed_from() { - let actual = MoveComputed::from(todo!()); - todo!() + let actual = MoveComputed::from(KataGoResponse { + id: Id(format!("{}_1_WHITE", Uuid::nil().to_string())), + turn_number: 1, + move_infos: vec![MoveInfo { + r#move: "B3".to_string(), + order: 0, + }], + }) + .expect("fail"); + let expected = MoveComputed(MakeMoveCommand { + game_id: GameId(Uuid::nil()), + coord: Some(Coord { x: 1, y: 2 }), + player: Player::WHITE, + req_id: actual.0.req_id.clone(), + }); + assert_eq!(actual, expected) } }