; -*- Scheme -*- ; ; $Id: testHgGame.scm,v 1.1 2003/05/26 13:31:39 chlussea Exp $ ; ; Copyright (C) 2003 Free Software Foundation, Inc. ; ; This file is part of GNU Hégémonie. ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; 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 General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. (define game ([] "HgGame" alloc)) (greg-testcase "HgGame initialisation test" #t (lambda () (equal? game ([] game initWithName: ($$ "jeu"))))) (define player1 ([] ([] "HgPlayer" alloc) initWithName: ($$ "yoo") user: ($$ "nul") host: ($$ "ser"))) (define player2 ([] ([] "HgPlayer" alloc) initWithName: ($$ "saalut") user: ($$ "Christ") host: ($$ "Serveu"))) (define player3 ([] ([] "HgPlayer" alloc) initWithName: ($$ "rap") user: ($$ "r'n'b") host: ($$ "rock"))) (greg-testcase "HgPlayer add players" #t (lambda () ([] game addPlayer: player1) (and (equal? 1 ([] ([] game players) count)) (gstep-bool ([] ([] game players) containsObject: player1))))) (greg-testcase "HgPlayer remove players" #t (lambda () ([] game removePlayer: player1) (and (equal? 0 ([] ([] game players) count)) (not(gstep-bool ([] ([] game players) containsObject: player1)))))) (define team1 ([] ([] "HgTeam" alloc) initWithName: ($$ "team 17"))) (greg-testcase "HgGame add teams" #t (lambda () ([] game addTeam: team1) (and (equal? 1 ([] ([] game teams) count)) (gstep-bool ([] ([] game teams) containsObject: team1))))) (greg-testcase "HgGame remove teams" #t (lambda () ([] game removeTeam: team1) (and (equal? 0 ([] ([] game teams) count)) (not(gstep-bool ([] ([] game teams) containsObject: team1)))))) (define object1 ([] ([] "HgObject" alloc) initWithGame: game position: '(1.0 2.0 6.0))) (greg-testcase "HgGame add objects" #t (lambda () ([] game addObject: object1) (and (equal? 1 ([] ([] game objects) count)) (gstep-bool ([] ([] game objects) containsObject: object1))))) (greg-testcase "HgGame remove objects" #t (lambda () ([] game removeObject: object1) (and (equal? 0 ([] ([] game objects) count)) (not(gstep-bool ([] ([] game objects) containsObject: object1))))))