123456789101112131415161718192021222324252627282930 |
- require 'chess-data'
- require 'minitest/autorun'
- describe ChessData::PositionDefinition do
- it "must correctly identify a simple 3P+2p ending" do
- defn = ChessData::PositionDefinition.new do
- exactly 3, "P"
- exactly 2, "p"
- end
- _(defn.check(ChessData::Board.from_fen("6k1/pp6/8/8/8/8/PPP5/4K3"))).must_equal true
- _(defn.check(ChessData::Board.from_fen("6k1/p7/8/7p/8/PP6/2P5/4K3"))).must_equal true
- _(defn.check(ChessData::Board.from_fen("6k1/pp6/b/8/8/Q/PPP5/4K3"))).must_equal false
- end
- it "must use at-least and at-most correctly" do
- defn = ChessData::PositionDefinition.new do
- at_most 4, "p"
- at_least 3, "P"
- at_most 1, "R"
- at_least 1, "n"
- end
- _(defn.check(ChessData::Board.from_fen("6k1/5n2/pp6/8/8/R7/KPPP4/8"))).must_equal true
- _(defn.check(ChessData::Board.from_fen("6k1/n4n2/pp6/8/8/R7/KPPPPPPP/8"))).must_equal true
- _(defn.check(ChessData::Board.from_fen("6k1/5n2/pp6/8/8/R6R/KPPP/8"))).must_equal false
- _(defn.check(ChessData::Board.from_fen("6k1/8/pp6/8/8/R7/KPPP4/8"))).must_equal false
- end
- end
|