File: shogideserializationtest.cpp

package info (click to toggle)
tagua 1.0~alpha2-15
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 8,028 kB
  • ctags: 7,178
  • sloc: cpp: 26,149; ansic: 13,039; makefile: 182; ruby: 87; sh: 39
file content (30 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "shogideserializationtest.h"

CPPUNIT_TEST_SUITE_REGISTRATION(ShogiDeserializationTest);

void ShogiDeserializationTest::setUp() {
  m_state = new ShogiGameState;
}

void ShogiDeserializationTest::tearDown() {
  delete m_state;
}

void ShogiDeserializationTest::regression_P_drop_2c() {
  ShogiSerializer s(ShogiSerializer::SIMPLE);
  
  m_state->pools().pool(ShogiPiece::BLACK).add(ShogiPiece::PAWN);
  
  ShogiMove m = s.deserialize("P*2c", *m_state);
  CPPUNIT_ASSERT(m.drop() == ShogiPiece(ShogiPiece::BLACK, ShogiPiece::PAWN));
  CPPUNIT_ASSERT(m.to() == Point(7, 2));
  
  m_state->setup();
  m_state->board().set(Point(7, 2), ShogiPiece());
  m_state->board().set(Point(7, 6), ShogiPiece());
  
  m = s.deserialize("P*2c", *m_state);
  CPPUNIT_ASSERT(m.drop() == ShogiPiece(ShogiPiece::BLACK, ShogiPiece::PAWN));
  CPPUNIT_ASSERT(m.to() == Point(7, 2));  
}