parent
dd3709eb1b
commit
5725803920
@ -1,11 +1,19 @@
|
||||
#include "constants.h"
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
|
||||
// Convert pair of x y coordinates to Position enum member.
|
||||
// If pr contains values above 7, or below 0 it will fail with an InvalidArgument exception.
|
||||
Position pair_to_pos(pair<int, int> pr);
|
||||
Position pair_to_pos(std::pair<int, int> pr);
|
||||
|
||||
// Convert a Position number into a pair of x y coordiinates
|
||||
pair<int, int> pos_to_pair(Position pn);
|
||||
std::pair<int, int> pos_to_pair(Position pn);
|
||||
|
||||
// Get all positions of pieces which can move to this square
|
||||
// This may require helper functions for each individual peice.
|
||||
// TODO rename to something less stupid.
|
||||
std::vector<Position> get_possible_movers(Position pn, std::vector<PieceType> pt);
|
||||
|
||||
// Get all possible moved for piece in Position pn.
|
||||
// This may require helper functions for each individual piece.
|
||||
std::vector<Position> get_possible_moves(Position pn, std::vector<PieceType> pt);
|
||||
|
@ -1,24 +0,0 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
#include <functions.h>
|
||||
|
||||
// For some retarted reason, I need to implement the printing of pairs, otherwise in the test outputs they show up as {?}
|
||||
// TODO implement that functionality.
|
||||
|
||||
TEST_CASE("Test convert method to go from X and Y to board position", "[pair_to_pos]"){
|
||||
CHECK(pair_to_pos(make_pair(3, 5)) == Position::C3);
|
||||
CHECK(pair_to_pos(make_pair(7, 0)) == Position::H8);
|
||||
CHECK(pair_to_pos(make_pair(0, 0)) == Position::A8);
|
||||
CHECK(pair_to_pos(make_pair(7, 7)) == Position::H1);
|
||||
CHECK_THROWS(pair_to_pos(make_pair(8, 2)));
|
||||
CHECK_THROWS(pair_to_pos(make_pair(-1, 1)));
|
||||
}
|
||||
|
||||
TEST_CASE("Test convert method to go from a board position to an x and y", "[pos_to_pair]"){
|
||||
CHECK(pos_to_pair(Position::A3) == make_pair(0, 5));
|
||||
CHECK(pos_to_pair(Position::B2) == make_pair(1, 1));
|
||||
CHECK(pos_to_pair(Position::H8) == make_pair(0, 7));
|
||||
}
|
Loading…
Reference in new issue