// [TestMethod, Description("")] TEST_F(MoveCheckTest, testIsCheck) { Position pos; Sfen::LoadPosition(pos, sfen); Move movedata = Sfen::ParseMove(pos, "7b8b+"); ASSERT_EQ(MoveCheck::IsCheck(pos), false); pos.DoMove(movedata); ASSERT_EQ(MoveCheck::IsCheck(pos), true); Sfen::LoadPosition(pos, sfen2); movedata = Sfen::ParseMove(pos, "S*6h"); ASSERT_EQ(MoveCheck::IsCheck(pos), false); pos.DoMove(movedata); ASSERT_EQ(MoveCheck::IsCheck(pos), true); }
// [TestMethod, Description("")] TEST_F(MoveCheckTest, testCanPromota) { Position pos; Sfen::LoadPosition(pos, sfen2); int i = 0; for (auto str : moves) { Move movedata = Sfen::ParseMove(pos, str); ASSERT_EQ(MoveCheck::CanPromota(movedata), promotions[i]); if (is_move(movedata.move_type())) { pos.DoMove(movedata); } i++; } }
// [TestMethod, Description("IsValidのテスト")] TEST_F(MoveCheckTest, testIsValid) { Position pos; Sfen::LoadPosition(pos, sfen2); int i = 0; for (auto& str: moves) { Move movedata2 = Sfen::ParseMove(pos, str); if (is_move(movedata2.move_type())) { ASSERT_EQ(MoveCheck::IsValid(pos, movedata2), true); pos.DoMove(movedata2); } i++; } Sfen::LoadPosition(pos, sfen2); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::PASS)), true); Move movedata(MoveType::NORMAL); ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false); movedata.set_to(Square::SQ_68); ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false); movedata.set_piece(Piece::W_SILVER); movedata.set_side(WHITE); ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false); movedata.set_move_type(MoveType::DROP); ASSERT_EQ(MoveCheck::IsValid(pos, movedata), true); movedata.set_piece(Piece::B_SILVER); ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_36, Piece::W_GOLD, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_37, Piece::W_SILVER, Piece::NO_PIECE)), true); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::NORMAL, Square::SQ_81, Square::SQ_73, Piece::W_KNIGHT, Piece::NO_PIECE)), false); // Drop可否判定 Sfen::LoadPosition(pos, sfen3); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_99, Piece::W_PAWN, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_28, Piece::W_PAWN, Piece::NO_PIECE)), true); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_69, Piece::W_LANCE, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_38, Piece::W_LANCE, Piece::NO_PIECE)), true); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_89, Piece::W_KNIGHT, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_48, Piece::W_KNIGHT, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_77, Piece::W_KNIGHT, Piece::NO_PIECE)), true); // 打ち歩詰め判定 ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_77, Piece::W_PAWN, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_77, Piece::W_LANCE, Piece::NO_PIECE)), true); // Drop可否判定 Sfen::LoadPosition(pos, sfen4); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_11, Piece::B_PAWN, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_82, Piece::B_PAWN, Piece::NO_PIECE)), true); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_41, Piece::B_LANCE, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_72, Piece::B_LANCE, Piece::NO_PIECE)), true); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_21, Piece::B_KNIGHT, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_62, Piece::B_KNIGHT, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_33, Piece::B_KNIGHT, Piece::NO_PIECE)), true); // 打ち歩詰め判定 ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_33, Piece::B_PAWN, Piece::NO_PIECE)), false); ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_33, Piece::B_LANCE, Piece::NO_PIECE)), true); }