~ubuntu-branches/debian/sid/gnome-chess/sid

« back to all changes in this revision

Viewing changes to src/test-chess-pgn.c

  • Committer: Package Import Robot
  • Author(s): Luca Falavigna, Jeremy Bicha, Jackson Doak, Luca Falavigna
  • Date: 2014-07-15 21:50:20 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140715215020-rhk7hmpjf5xlntb9
Tags: 1:3.12.3-1
* Team upload.

[ Jeremy Bicha ]
* debian/control.in:
  - Depend on hoichess and demote other chess engines to Suggests
    per upstream recommendation (LP: #138570)
  - Bump minimum intoltool and vala
  - Drop sqlite dependency
* debian/gnome-chess.install:
  - AI configuration file moved to /etc/chess-engines.conf

[ Jackson Doak ]
* New upstream release (3.12.3)

[ Luca Falavigna ]
* debian/control.in:
  - Bump Standards-Version to 3.9.5.
  - Refresh build-dependencies required minimum versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* test-chess-pgn.c generated by valac 0.18.1, the Vala compiler
 
1
/* test-chess-pgn.c generated by valac 0.24.0.112-bbf5, the Vala compiler
2
2
 * generated from test-chess-pgn.vala, do not modify */
3
3
 
 
4
/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
5
 *
 
6
 * Copyright (C) 2010-2013 Robert Ancell
 
7
 *
 
8
 * This program is free software: you can redistribute it and/or modify it under
 
9
 * the terms of the GNU General Public License as published by the Free Software
 
10
 * Foundation, either version 2 of the License, or (at your option) any later
 
11
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 
12
 * license.
 
13
 */
4
14
 
5
15
#include <glib.h>
6
16
#include <glib-object.h>
32
42
typedef struct _PGNClass PGNClass;
33
43
#define _pgn_unref0(var) ((var == NULL) ? NULL : (var = (pgn_unref (var), NULL)))
34
44
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
35
 
typedef struct _PGNPrivate PGNPrivate;
36
45
 
37
46
#define TYPE_PGN_GAME (pgn_game_get_type ())
38
47
#define PGN_GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PGN_GAME, PGNGame))
43
52
 
44
53
typedef struct _PGNGame PGNGame;
45
54
typedef struct _PGNGameClass PGNGameClass;
 
55
typedef struct _PGNPrivate PGNPrivate;
46
56
typedef struct _PGNGamePrivate PGNGamePrivate;
47
57
#define _g_free0(var) (var = (g_free (var), NULL))
48
58
#define _pgn_game_unref0(var) ((var == NULL) ? NULL : (var = (pgn_game_unref (var), NULL)))
140
150
 
141
151
static gchar* string_strip (const gchar* self) {
142
152
        gchar* result = NULL;
 
153
        gchar* _result_ = NULL;
143
154
        gchar* _tmp0_ = NULL;
144
 
        gchar* _result_;
145
 
        const gchar* _tmp1_;
 
155
        const gchar* _tmp1_ = NULL;
146
156
        g_return_val_if_fail (self != NULL, NULL);
147
157
        _tmp0_ = g_strdup (self);
148
158
        _result_ = _tmp0_;
154
164
 
155
165
 
156
166
static void gl_chess_test_pgn_file (const gchar* data, const gchar* moves) {
157
 
        gint _tmp0_;
 
167
        gint _tmp0_ = 0;
158
168
        PGN* file = NULL;
159
 
        PGN* _tmp9_;
160
 
        GList* _tmp10_;
161
 
        gconstpointer _tmp11_ = NULL;
162
 
        PGNGame* _tmp12_;
163
 
        PGNGame* game;
164
 
        gchar* _tmp13_;
165
 
        gchar* move_string;
166
 
        PGNGame* _tmp14_;
167
 
        GList* _tmp15_;
168
 
        const gchar* _tmp22_;
169
 
        gchar* _tmp23_ = NULL;
170
 
        const gchar* _tmp24_;
171
 
        const gchar* _tmp25_;
 
169
        PGNGame* game = NULL;
 
170
        PGN* _tmp10_ = NULL;
 
171
        GList* _tmp11_ = NULL;
 
172
        gconstpointer _tmp12_ = NULL;
 
173
        PGNGame* _tmp13_ = NULL;
 
174
        gchar* move_string = NULL;
 
175
        gchar* _tmp14_ = NULL;
 
176
        PGNGame* _tmp15_ = NULL;
 
177
        GList* _tmp16_ = NULL;
 
178
        const gchar* _tmp23_ = NULL;
 
179
        gchar* _tmp24_ = NULL;
 
180
        const gchar* _tmp25_ = NULL;
 
181
        const gchar* _tmp26_ = NULL;
172
182
        GError * _inner_error_ = NULL;
173
183
        g_return_if_fail (data != NULL);
174
184
        g_return_if_fail (moves != NULL);
175
185
        _tmp0_ = gl_chess_test_count;
176
186
        gl_chess_test_count = _tmp0_ + 1;
177
187
        {
178
 
                const gchar* _tmp1_;
179
 
                PGN* _tmp2_;
180
 
                PGN* _tmp3_;
181
 
                _tmp1_ = data;
182
 
                _tmp2_ = pgn_new_from_string (_tmp1_, &_inner_error_);
183
 
                _tmp3_ = _tmp2_;
184
 
                if (_inner_error_ != NULL) {
 
188
                PGN* _tmp1_ = NULL;
 
189
                const gchar* _tmp2_ = NULL;
 
190
                PGN* _tmp3_ = NULL;
 
191
                PGN* _tmp4_ = NULL;
 
192
                _tmp2_ = data;
 
193
                _tmp3_ = pgn_new_from_string (_tmp2_, &_inner_error_);
 
194
                _tmp1_ = _tmp3_;
 
195
                if (G_UNLIKELY (_inner_error_ != NULL)) {
185
196
                        if (_inner_error_->domain == PGN_ERROR) {
186
197
                                goto __catch1_pgn_error;
187
198
                        }
190
201
                        g_clear_error (&_inner_error_);
191
202
                        return;
192
203
                }
 
204
                _tmp4_ = _tmp1_;
 
205
                _tmp1_ = NULL;
193
206
                _pgn_unref0 (file);
194
 
                file = _tmp3_;
 
207
                file = _tmp4_;
 
208
                _pgn_unref0 (_tmp1_);
195
209
        }
196
210
        goto __finally1;
197
211
        __catch1_pgn_error:
198
212
        {
199
213
                GError* e = NULL;
200
 
                FILE* _tmp4_;
201
 
                gint _tmp5_;
202
 
                GError* _tmp6_;
203
 
                const gchar* _tmp7_;
204
 
                gint _tmp8_;
 
214
                FILE* _tmp5_ = NULL;
 
215
                gint _tmp6_ = 0;
 
216
                GError* _tmp7_ = NULL;
 
217
                const gchar* _tmp8_ = NULL;
 
218
                gint _tmp9_ = 0;
205
219
                e = _inner_error_;
206
220
                _inner_error_ = NULL;
207
 
                _tmp4_ = stderr;
208
 
                _tmp5_ = gl_chess_test_count;
209
 
                _tmp6_ = e;
210
 
                _tmp7_ = _tmp6_->message;
211
 
                fprintf (_tmp4_, "%d. FAIL %s\n", _tmp5_, _tmp7_);
212
 
                _tmp8_ = gl_chess_failure_count;
213
 
                gl_chess_failure_count = _tmp8_ + 1;
 
221
                _tmp5_ = stderr;
 
222
                _tmp6_ = gl_chess_test_count;
 
223
                _tmp7_ = e;
 
224
                _tmp8_ = _tmp7_->message;
 
225
                fprintf (_tmp5_, "%d. FAIL %s\n", _tmp6_, _tmp8_);
 
226
                _tmp9_ = gl_chess_failure_count;
 
227
                gl_chess_failure_count = _tmp9_ + 1;
214
228
                _g_error_free0 (e);
215
229
                _pgn_unref0 (file);
216
230
                return;
217
231
        }
218
232
        __finally1:
219
 
        if (_inner_error_ != NULL) {
 
233
        if (G_UNLIKELY (_inner_error_ != NULL)) {
220
234
                _pgn_unref0 (file);
221
235
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
222
236
                g_clear_error (&_inner_error_);
223
237
                return;
224
238
        }
225
 
        _tmp9_ = file;
226
 
        _tmp10_ = _tmp9_->games;
227
 
        _tmp11_ = g_list_nth_data (_tmp10_, (guint) 0);
228
 
        _tmp12_ = _pgn_game_ref0 ((PGNGame*) _tmp11_);
229
 
        game = _tmp12_;
230
 
        _tmp13_ = g_strdup ("");
231
 
        move_string = _tmp13_;
232
 
        _tmp14_ = game;
233
 
        _tmp15_ = _tmp14_->moves;
 
239
        _tmp10_ = file;
 
240
        _tmp11_ = _tmp10_->games;
 
241
        _tmp12_ = g_list_nth_data (_tmp11_, (guint) 0);
 
242
        _tmp13_ = _pgn_game_ref0 ((PGNGame*) _tmp12_);
 
243
        game = _tmp13_;
 
244
        _tmp14_ = g_strdup ("");
 
245
        move_string = _tmp14_;
 
246
        _tmp15_ = game;
 
247
        _tmp16_ = _tmp15_->moves;
234
248
        {
235
249
                GList* move_collection = NULL;
236
250
                GList* move_it = NULL;
237
 
                move_collection = _tmp15_;
 
251
                move_collection = _tmp16_;
238
252
                for (move_it = move_collection; move_it != NULL; move_it = move_it->next) {
239
 
                        gchar* _tmp16_;
 
253
                        gchar* _tmp17_ = NULL;
240
254
                        gchar* move = NULL;
241
 
                        _tmp16_ = g_strdup ((const gchar*) move_it->data);
242
 
                        move = _tmp16_;
 
255
                        _tmp17_ = g_strdup ((const gchar*) move_it->data);
 
256
                        move = _tmp17_;
243
257
                        {
244
 
                                const gchar* _tmp17_;
245
 
                                const gchar* _tmp18_;
246
 
                                gchar* _tmp19_ = NULL;
247
 
                                gchar* _tmp20_;
248
 
                                gchar* _tmp21_;
249
 
                                _tmp17_ = move_string;
250
 
                                _tmp18_ = move;
251
 
                                _tmp19_ = g_strdup_printf ("%s ", _tmp18_);
252
 
                                _tmp20_ = _tmp19_;
253
 
                                _tmp21_ = g_strconcat (_tmp17_, _tmp20_, NULL);
 
258
                                const gchar* _tmp18_ = NULL;
 
259
                                const gchar* _tmp19_ = NULL;
 
260
                                gchar* _tmp20_ = NULL;
 
261
                                gchar* _tmp21_ = NULL;
 
262
                                gchar* _tmp22_ = NULL;
 
263
                                _tmp18_ = move_string;
 
264
                                _tmp19_ = move;
 
265
                                _tmp20_ = g_strdup_printf ("%s ", _tmp19_);
 
266
                                _tmp21_ = _tmp20_;
 
267
                                _tmp22_ = g_strconcat (_tmp18_, _tmp21_, NULL);
254
268
                                _g_free0 (move_string);
255
 
                                move_string = _tmp21_;
256
 
                                _g_free0 (_tmp20_);
 
269
                                move_string = _tmp22_;
 
270
                                _g_free0 (_tmp21_);
257
271
                                _g_free0 (move);
258
272
                        }
259
273
                }
260
274
        }
261
 
        _tmp22_ = move_string;
262
 
        _tmp23_ = string_strip (_tmp22_);
 
275
        _tmp23_ = move_string;
 
276
        _tmp24_ = string_strip (_tmp23_);
263
277
        _g_free0 (move_string);
264
 
        move_string = _tmp23_;
265
 
        _tmp24_ = move_string;
266
 
        _tmp25_ = moves;
267
 
        if (g_strcmp0 (_tmp24_, _tmp25_) == 0) {
268
 
                FILE* _tmp26_;
269
 
                gint _tmp27_;
270
 
                _tmp26_ = stderr;
271
 
                _tmp27_ = gl_chess_test_count;
272
 
                fprintf (_tmp26_, "%d. PASS\n", _tmp27_);
 
278
        move_string = _tmp24_;
 
279
        _tmp25_ = move_string;
 
280
        _tmp26_ = moves;
 
281
        if (g_strcmp0 (_tmp25_, _tmp26_) == 0) {
 
282
                FILE* _tmp27_ = NULL;
 
283
                gint _tmp28_ = 0;
 
284
                _tmp27_ = stderr;
 
285
                _tmp28_ = gl_chess_test_count;
 
286
                fprintf (_tmp27_, "%d. PASS\n", _tmp28_);
273
287
        } else {
274
 
                gint _tmp28_;
275
 
                FILE* _tmp29_;
276
 
                gint _tmp30_;
277
 
                const gchar* _tmp31_;
278
 
                const gchar* _tmp32_;
279
 
                _tmp28_ = gl_chess_failure_count;
280
 
                gl_chess_failure_count = _tmp28_ + 1;
281
 
                _tmp29_ = stderr;
282
 
                _tmp30_ = gl_chess_test_count;
283
 
                _tmp31_ = move_string;
284
 
                _tmp32_ = moves;
285
 
                fprintf (_tmp29_, "%d. FAIL got moves '%s', expected '%s'\n", _tmp30_, _tmp31_, _tmp32_);
 
288
                gint _tmp29_ = 0;
 
289
                FILE* _tmp30_ = NULL;
 
290
                gint _tmp31_ = 0;
 
291
                const gchar* _tmp32_ = NULL;
 
292
                const gchar* _tmp33_ = NULL;
 
293
                _tmp29_ = gl_chess_failure_count;
 
294
                gl_chess_failure_count = _tmp29_ + 1;
 
295
                _tmp30_ = stderr;
 
296
                _tmp31_ = gl_chess_test_count;
 
297
                _tmp32_ = move_string;
 
298
                _tmp33_ = moves;
 
299
                fprintf (_tmp30_, "%d. FAIL got moves '%s', expected '%s'\n", _tmp31_, _tmp32_, _tmp33_);
286
300
        }
287
301
        _g_free0 (move_string);
288
302
        _pgn_game_unref0 (game);
292
306
 
293
307
gint gl_chess_main (gchar** args, int args_length1) {
294
308
        gint result = 0;
295
 
        FILE* _tmp0_;
296
 
        gint _tmp1_;
297
 
        gint _tmp2_;
298
 
        gint _tmp3_;
299
 
        gint _tmp4_;
 
309
        FILE* _tmp0_ = NULL;
 
310
        gint _tmp1_ = 0;
 
311
        gint _tmp2_ = 0;
 
312
        gint _tmp3_ = 0;
 
313
        gint _tmp4_ = 0;
300
314
        gl_chess_test_pgn_file ("[Event \"?\"]\n" "[Site \"?\"]\n" "[Date \"????.??.??\"]\n" "[Round \"?\"]\n" "[White \"\"]\n" "[Black \"\"]\n" "[Result \"*\"]\n" "\n" "1. *\n", "");
301
315
        gl_chess_test_pgn_file ("1. e1 *\n", "e1");
302
316
        gl_chess_test_pgn_file ("e1 *\n", "e1");
320
334
 
321
335
 
322
336
int main (int argc, char ** argv) {
 
337
#if !GLIB_CHECK_VERSION (2,35,0)
323
338
        g_type_init ();
 
339
#endif
324
340
        return gl_chess_main (argv, argc);
325
341
}
326
342