File: pvFile.t.cc

package info (click to toggle)
gpsshogi 0.7.0-3.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 111,280 kB
  • sloc: cpp: 80,962; perl: 12,610; ruby: 3,929; javascript: 1,631; makefile: 1,202; sh: 473; tcl: 166; ansic: 67
file content (59 lines) | stat: -rw-r--r-- 1,323 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* pvFile.t.cc
 */
#include "pvFile.h"

#include <boost/test/unit_test.hpp>

using namespace gpsshogi;
using namespace osl;

BOOST_AUTO_TEST_CASE(PvFileTestConstruct)
{
  {
    gpsshogi::PVFileWriter pw("pvFile-test.gz");
  }
  {
    gpsshogi::PVFileReader pr("pvFile-test.gz");
  }
}

BOOST_AUTO_TEST_CASE(PvFileTestRW)
{
  PVVector pv;
  pv.push_back(Move(Square(7,7),Square(7,6),PAWN,PTYPE_EMPTY,false,BLACK));
  pv.push_back(Move(Square(3,3),Square(3,4),PAWN,PTYPE_EMPTY,false,WHITE));
  {
    gpsshogi::PVFileWriter pw("pvFile-test.gz");
  }
  {
    int c = gpsshogi::PVFileReader::countPosition("pvFile-test.gz");
    BOOST_CHECK_EQUAL(0, c);
  }
  {
    gpsshogi::PVFileWriter pw("pvFile-test.gz");
    pw.newPosition(3, 4);
    pw.addPv(pv);
  }
  {
    gpsshogi::PVFileReader pr("pvFile-test.gz");
    int r, p;
    pr.newPosition(r, p);
    BOOST_CHECK_EQUAL(3, r);
    BOOST_CHECK_EQUAL(4, p);

    PVVector pv2;
    pr.readPv(pv2);
    BOOST_CHECK_EQUAL(pv.size(), pv2.size());
    BOOST_CHECK(std::equal(pv.begin(), pv.end(), pv2.begin()));
  }
  {
    int c = gpsshogi::PVFileReader::countPosition("pvFile-test.gz");
    BOOST_CHECK_EQUAL(1, c);
  }
}

/* ------------------------------------------------------------------------- */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End: