DIR : /home/kozerus/public_html/dgs/scripts/tests/DeprecatedGameSetupTest.php

/home/kozerus/public_html/dgs/scripts/tests

<?php
/*
Dragon Go Server
Copyright (C) 2001-  Erik Ouchterlony, Jens-Uwe Gaspar

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

require_once 'DgsUnitTest.php';
require_once 'include/quick_common.php';
require_once 'scripts/tests/UnitTestHelper.php';
require_once 'include/game_functions.php';
require_once 'include/deprecated_functions.php';
require_once 'scripts/tests/GameSetupTest.php';

recover_language( array('Lang' => LANG_DEF_LOAD) ); // want default english


/**
 * Test class for helpers to handle deprecated game-setup-data.
 * Generated by PHPUnit_Util_Skeleton on 2009-12-06 at 10:55:49.
 */
class DeprecatedGameSetupTest extends DgsUnitTest {

   protected function setUp() {
      UnitTestHelper::clearErrors(ERROR_MODE_PRINT);
   }

   public function test_build_and_parse_invitation_game_setup() {
      $gs1 = GameSetupTest::create_gs_inv();
      $gs1->Komi = 5.5;
      $gs1->uid = 11;
      $gs1->Message = 'bla';
      $gs2 = GameSetupTest::create_gs_inv();
      $gs2->uid = 22;
      $gs2->Size = 13;
      $str = DeprecatedGameSetup::build_invitation_game_setup( $gs1, $gs2 );
      $this->assertEquals( $gs1->encode_game_setup(GSENC_FULL_GAME) . GS_SEP_INVITATION . $gs2->encode_game_setup(GSENC_FULL_GAME), $str );
      $this->assertEquals( 'T7:U11:H2:-1:3:9:K5.5:70.0:J1:FK:R1:-800:2600:998:H%:-102:C:I17:1:r2:0:tJ:61:17:4:1 T7:U22:H2:-1:3:9:K-199.5:70.0:J1:FK:R1:-800:2600:998:H%:-102:C:I13:1:r2:0:tJ:61:17:4:1', $str );

      $arr_gs = DeprecatedGameSetup::parse_invitation_game_setup( 22, '' );
      $this->assertEquals( 2, count($arr_gs));
      $this->assertTrue( is_null($arr_gs[0]) );
      $this->assertTrue( is_null($arr_gs[1]) );

      $arr_gs = DeprecatedGameSetup::parse_invitation_game_setup( 22, $str );
      $this->assertEquals( 2, count($arr_gs));
      $this->assertEquals( 22, $arr_gs[0]->uid );
      $this->assertEquals( 11, $arr_gs[1]->uid );
      $this->assertEquals( -199.5, $arr_gs[0]->Komi );
      $this->assertEquals( 5.5, $arr_gs[1]->Komi );
      $this->assertEquals( 13, $arr_gs[0]->Size );
      $this->assertEquals( 17, $arr_gs[1]->Size );
   }

}

?>
//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer