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 */
4
/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
6
* Copyright (C) 2010-2013 Robert Ancell
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
6
16
#include <glib-object.h>
156
166
static void gl_chess_test_pgn_file (const gchar* data, const gchar* moves) {
158
168
PGN* file = NULL;
161
gconstpointer _tmp11_ = NULL;
168
const gchar* _tmp22_;
169
gchar* _tmp23_ = NULL;
170
const gchar* _tmp24_;
171
const gchar* _tmp25_;
169
PGNGame* game = 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;
182
_tmp2_ = pgn_new_from_string (_tmp1_, &_inner_error_);
184
if (_inner_error_ != NULL) {
189
const gchar* _tmp2_ = NULL;
193
_tmp3_ = pgn_new_from_string (_tmp2_, &_inner_error_);
195
if (G_UNLIKELY (_inner_error_ != NULL)) {
185
196
if (_inner_error_->domain == PGN_ERROR) {
186
197
goto __catch1_pgn_error;
190
201
g_clear_error (&_inner_error_);
193
206
_pgn_unref0 (file);
208
_pgn_unref0 (_tmp1_);
197
211
__catch1_pgn_error:
199
213
GError* e = NULL;
216
GError* _tmp7_ = NULL;
217
const gchar* _tmp8_ = NULL;
205
219
e = _inner_error_;
206
220
_inner_error_ = NULL;
208
_tmp5_ = gl_chess_test_count;
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;
222
_tmp6_ = gl_chess_test_count;
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);
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_);
226
_tmp10_ = _tmp9_->games;
227
_tmp11_ = g_list_nth_data (_tmp10_, (guint) 0);
228
_tmp12_ = _pgn_game_ref0 ((PGNGame*) _tmp11_);
230
_tmp13_ = g_strdup ("");
231
move_string = _tmp13_;
233
_tmp15_ = _tmp14_->moves;
240
_tmp11_ = _tmp10_->games;
241
_tmp12_ = g_list_nth_data (_tmp11_, (guint) 0);
242
_tmp13_ = _pgn_game_ref0 ((PGNGame*) _tmp12_);
244
_tmp14_ = g_strdup ("");
245
move_string = _tmp14_;
247
_tmp16_ = _tmp15_->moves;
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) {
253
gchar* _tmp17_ = NULL;
240
254
gchar* move = NULL;
241
_tmp16_ = g_strdup ((const gchar*) move_it->data);
255
_tmp17_ = g_strdup ((const gchar*) move_it->data);
244
const gchar* _tmp17_;
245
const gchar* _tmp18_;
246
gchar* _tmp19_ = NULL;
249
_tmp17_ = move_string;
251
_tmp19_ = g_strdup_printf ("%s ", _tmp18_);
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;
265
_tmp20_ = g_strdup_printf ("%s ", _tmp19_);
267
_tmp22_ = g_strconcat (_tmp18_, _tmp21_, NULL);
254
268
_g_free0 (move_string);
255
move_string = _tmp21_;
269
move_string = _tmp22_;
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;
267
if (g_strcmp0 (_tmp24_, _tmp25_) == 0) {
271
_tmp27_ = gl_chess_test_count;
272
fprintf (_tmp26_, "%d. PASS\n", _tmp27_);
278
move_string = _tmp24_;
279
_tmp25_ = move_string;
281
if (g_strcmp0 (_tmp25_, _tmp26_) == 0) {
282
FILE* _tmp27_ = NULL;
285
_tmp28_ = gl_chess_test_count;
286
fprintf (_tmp27_, "%d. PASS\n", _tmp28_);
277
const gchar* _tmp31_;
278
const gchar* _tmp32_;
279
_tmp28_ = gl_chess_failure_count;
280
gl_chess_failure_count = _tmp28_ + 1;
282
_tmp30_ = gl_chess_test_count;
283
_tmp31_ = move_string;
285
fprintf (_tmp29_, "%d. FAIL got moves '%s', expected '%s'\n", _tmp30_, _tmp31_, _tmp32_);
289
FILE* _tmp30_ = NULL;
291
const gchar* _tmp32_ = NULL;
292
const gchar* _tmp33_ = NULL;
293
_tmp29_ = gl_chess_failure_count;
294
gl_chess_failure_count = _tmp29_ + 1;
296
_tmp31_ = gl_chess_test_count;
297
_tmp32_ = move_string;
299
fprintf (_tmp30_, "%d. FAIL got moves '%s', expected '%s'\n", _tmp31_, _tmp32_, _tmp33_);
287
301
_g_free0 (move_string);
288
302
_pgn_game_unref0 (game);