"vscode:/vscode.git/clone" did not exist on "8c517bf0fd6c627ca4dfcdc84d932928a1527ac8"
spectests.cpp 33.9 KB
Newer Older
Jesse Beder's avatar
Jesse Beder committed
1
2
3
4
5
6
7
#include "spectests.h"
#include "yaml.h"
#include <fstream>
#include <sstream>
#include <vector>
#include <iostream>

Jesse Beder's avatar
Jesse Beder committed
8
9
10
11
12
13
14
15
16
17
18
namespace {
	struct TEST {
		TEST(): ok(false) {}
		TEST(bool ok_): ok(ok_) {}
		TEST(const char *error_): ok(false), error(error_) {}
		
		bool ok;
		std::string error;
	};
}

19
#define YAML_ASSERT(cond) do { if(!(cond)) return "  Assert failed: " #cond; } while(false)
20
21
22
23
24
25
#define PARSE(doc, input) \
	std::stringstream stream(input);\
	YAML::Parser parser(stream);\
	YAML::Node doc;\
	parser.GetNextDocument(doc)
#define PARSE_NEXT(doc) parser.GetNextDocument(doc)
26

Jesse Beder's avatar
Jesse Beder committed
27
28
namespace Test {
	namespace {
Jesse Beder's avatar
Jesse Beder committed
29
		void RunSpecTest(TEST (*test)(), const std::string& index, const std::string& name, int& passed, int& total) {
Jesse Beder's avatar
Jesse Beder committed
30
			TEST ret;
Jesse Beder's avatar
Jesse Beder committed
31
			try {
Jesse Beder's avatar
Jesse Beder committed
32
				ret = test();
Jesse Beder's avatar
Jesse Beder committed
33
			} catch(const YAML::Exception& e) {
Jesse Beder's avatar
Jesse Beder committed
34
				ret.ok = false;
35
				ret.error = "  Exception caught: " + e.msg;
Jesse Beder's avatar
Jesse Beder committed
36
			}
Jesse Beder's avatar
Jesse Beder committed
37
			
Jesse Beder's avatar
Jesse Beder committed
38
			if(!ret.ok) {
Jesse Beder's avatar
Jesse Beder committed
39
				std::cout << "Spec test " << index << " failed: " << name << "\n";
Jesse Beder's avatar
Jesse Beder committed
40
				std::cout << ret.error << "\n";
Jesse Beder's avatar
Jesse Beder committed
41
			}
Jesse Beder's avatar
Jesse Beder committed
42
43
44
45
			
			if(ret.ok)
				passed++;
			total++;
Jesse Beder's avatar
Jesse Beder committed
46
47
48
49
		}
	}

	namespace Spec {
50
		// 2.1
Jesse Beder's avatar
Jesse Beder committed
51
		TEST SeqScalars() {
Jesse Beder's avatar
Jesse Beder committed
52
53
54
55
			std::string input =
				"- Mark McGwire\n"
				"- Sammy Sosa\n"
				"- Ken Griffey";
56
57

			PARSE(doc, input);
58
59
60
61
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0] == "Mark McGwire");
			YAML_ASSERT(doc[1] == "Sammy Sosa");
			YAML_ASSERT(doc[2] == "Ken Griffey");
Jesse Beder's avatar
Jesse Beder committed
62
63
64
			return true;
		}
		
65
		// 2.2
Jesse Beder's avatar
Jesse Beder committed
66
		TEST MappingScalarsToScalars() {
Jesse Beder's avatar
Jesse Beder committed
67
68
69
70
71
			std::string input =
				"hr:  65    # Home runs\n"
				"avg: 0.278 # Batting average\n"
				"rbi: 147   # Runs Batted In";

72
			PARSE(doc, input);
73
74
75
76
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["hr"] == "65");
			YAML_ASSERT(doc["avg"] == "0.278");
			YAML_ASSERT(doc["rbi"] == "147");
Jesse Beder's avatar
Jesse Beder committed
77
78
			return true;
		}
Jesse Beder's avatar
Jesse Beder committed
79
		
80
		// 2.3
Jesse Beder's avatar
Jesse Beder committed
81
82
83
84
85
86
87
88
89
90
		TEST MappingScalarsToSequences() {
			std::string input =
				"american:\n"
				"- Boston Red Sox\n"
				"- Detroit Tigers\n"
				"- New York Yankees\n"
				"national:\n"
				"- New York Mets\n"
				"- Chicago Cubs\n"
				"- Atlanta Braves";
91
92

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
93
94
95
96
97
98
99
100
101
102
103
104
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["american"].size() == 3);
			YAML_ASSERT(doc["american"][0] == "Boston Red Sox");
			YAML_ASSERT(doc["american"][1] == "Detroit Tigers");
			YAML_ASSERT(doc["american"][2] == "New York Yankees");
			YAML_ASSERT(doc["national"].size() == 3);
			YAML_ASSERT(doc["national"][0] == "New York Mets");
			YAML_ASSERT(doc["national"][1] == "Chicago Cubs");
			YAML_ASSERT(doc["national"][2] == "Atlanta Braves");
			return true;
		}
		
105
		// 2.4
Jesse Beder's avatar
Jesse Beder committed
106
107
108
109
110
111
112
113
114
115
116
		TEST SequenceOfMappings()
		{
			std::string input =
				"-\n"
				"  name: Mark McGwire\n"
				"  hr:   65\n"
				"  avg:  0.278\n"
				"-\n"
				"  name: Sammy Sosa\n"
				"  hr:   63\n"
				"  avg:  0.288";
117
118

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
119
120
121
122
123
124
125
126
127
128
129
130
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 3);
			YAML_ASSERT(doc[0]["name"] == "Mark McGwire");
			YAML_ASSERT(doc[0]["hr"] == "65");
			YAML_ASSERT(doc[0]["avg"] == "0.278");
			YAML_ASSERT(doc[1].size() == 3);
			YAML_ASSERT(doc[1]["name"] == "Sammy Sosa");
			YAML_ASSERT(doc[1]["hr"] == "63");
			YAML_ASSERT(doc[1]["avg"] == "0.288");
			return true;
		}
		
131
		// 2.5
Jesse Beder's avatar
Jesse Beder committed
132
133
134
135
136
137
		TEST SequenceOfSequences()
		{
			std::string input =
				"- [name        , hr, avg  ]\n"
				"- [Mark McGwire, 65, 0.278]\n"
				"- [Sammy Sosa  , 63, 0.288]";
138
139

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].size() == 3);
			YAML_ASSERT(doc[0][0] == "name");
			YAML_ASSERT(doc[0][1] == "hr");
			YAML_ASSERT(doc[0][2] == "avg");
			YAML_ASSERT(doc[1].size() == 3);
			YAML_ASSERT(doc[1][0] == "Mark McGwire");
			YAML_ASSERT(doc[1][1] == "65");
			YAML_ASSERT(doc[1][2] == "0.278");
			YAML_ASSERT(doc[2].size() == 3);
			YAML_ASSERT(doc[2][0] == "Sammy Sosa");
			YAML_ASSERT(doc[2][1] == "63");
			YAML_ASSERT(doc[2][2] == "0.288");
			return true;
		}
		
156
		// 2.6
Jesse Beder's avatar
Jesse Beder committed
157
158
159
160
161
162
163
164
		TEST MappingOfMappings()
		{
			std::string input =
				"Mark McGwire: {hr: 65, avg: 0.278}\n"
				"Sammy Sosa: {\n"
				"    hr: 63,\n"
				"    avg: 0.288\n"
				"  }";
165
166

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
167
168
169
170
171
172
173
174
175
176
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["Mark McGwire"].size() == 2);
			YAML_ASSERT(doc["Mark McGwire"]["hr"] == "65");
			YAML_ASSERT(doc["Mark McGwire"]["avg"] == "0.278");
			YAML_ASSERT(doc["Sammy Sosa"].size() == 2);
			YAML_ASSERT(doc["Sammy Sosa"]["hr"] == "63");
			YAML_ASSERT(doc["Sammy Sosa"]["avg"] == "0.288");
			return true;
		}
		
177
		// 2.7
Jesse Beder's avatar
Jesse Beder committed
178
179
180
181
182
183
184
185
186
187
188
189
190
		TEST TwoDocumentsInAStream()
		{
			std::string input =
				"# Ranking of 1998 home runs\n"
				"---\n"
				"- Mark McGwire\n"
				"- Sammy Sosa\n"
				"- Ken Griffey\n"
				"\n"
				"# Team ranking\n"
				"---\n"
				"- Chicago Cubs\n"
				"- St Louis Cardinals";
191
192

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
193
194
195
196
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0] == "Mark McGwire");
			YAML_ASSERT(doc[1] == "Sammy Sosa");
			YAML_ASSERT(doc[2] == "Ken Griffey");
197
198

			PARSE_NEXT(doc);
Jesse Beder's avatar
Jesse Beder committed
199
200
201
202
203
204
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0] == "Chicago Cubs");
			YAML_ASSERT(doc[1] == "St Louis Cardinals");
			return true;
		}
		
205
		// 2.8
Jesse Beder's avatar
Jesse Beder committed
206
207
208
209
210
211
212
213
214
215
216
217
218
		TEST PlayByPlayFeed()
		{
			std::string input =
				"---\n"
				"time: 20:03:20\n"
				"player: Sammy Sosa\n"
				"action: strike (miss)\n"
				"...\n"
				"---\n"
				"time: 20:03:47\n"
				"player: Sammy Sosa\n"
				"action: grand slam\n"
				"...";
219
220

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
221
222
223
224
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["time"] == "20:03:20");
			YAML_ASSERT(doc["player"] == "Sammy Sosa");
			YAML_ASSERT(doc["action"] == "strike (miss)");
225
226

			PARSE_NEXT(doc);
Jesse Beder's avatar
Jesse Beder committed
227
228
229
230
231
232
233
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["time"] == "20:03:47");
			YAML_ASSERT(doc["player"] == "Sammy Sosa");
			YAML_ASSERT(doc["action"] == "grand slam");
			return true;
		}
		
234
		// 2.9
Jesse Beder's avatar
Jesse Beder committed
235
236
237
238
239
240
241
242
243
244
245
		TEST SingleDocumentWithTwoComments()
		{
			std::string input =
				"---\n"
				"hr: # 1998 hr ranking\n"
				"  - Mark McGwire\n"
				"  - Sammy Sosa\n"
				"rbi:\n"
				"  # 1998 rbi ranking\n"
				"  - Sammy Sosa\n"
				"  - Ken Griffey";
246
247

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
248
249
250
251
252
253
254
255
256
257
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["hr"].size() == 2);
			YAML_ASSERT(doc["hr"][0] == "Mark McGwire");
			YAML_ASSERT(doc["hr"][1] == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"].size() == 2);
			YAML_ASSERT(doc["rbi"][0] == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"][1] == "Ken Griffey");
			return true;
		}
		
258
		// 2.10
Jesse Beder's avatar
Jesse Beder committed
259
260
261
262
263
264
265
266
267
268
269
		TEST SimpleAnchor()
		{
			std::string input =
				"---\n"
				"hr:\n"
				"  - Mark McGwire\n"
				"  # Following node labeled SS\n"
				"  - &SS Sammy Sosa\n"
				"rbi:\n"
				"  - *SS # Subsequent occurrence\n"
				"  - Ken Griffey";
270
271

			PARSE(doc, input);
Jesse Beder's avatar
Jesse Beder committed
272
273
274
275
276
277
278
279
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["hr"].size() == 2);
			YAML_ASSERT(doc["hr"][0] == "Mark McGwire");
			YAML_ASSERT(doc["hr"][1] == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"].size() == 2);
			YAML_ASSERT(doc["rbi"][0] == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"][1] == "Ken Griffey");
			return true;
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
		}
		
		struct Pair {
			Pair() {}
			Pair(const std::string& f, const std::string& s): first(f), second(s) {}
			std::string first, second;
		};
		
		bool operator == (const Pair& p, const Pair& q) {
			return p.first == q.first && p.second == q.second;
		}
		
		void operator >> (const YAML::Node& node, Pair& p) {
			node[0] >> p.first;
			node[1] >> p.second;
		}
		
297
		// 2.11
298
299
300
301
302
303
304
305
306
307
308
309
310
		TEST MappingBetweenSequences()
		{
			std::string input =
				"? - Detroit Tigers\n"
				"  - Chicago cubs\n"
				":\n"
				"  - 2001-07-23\n"
				"\n"
				"? [ New York Yankees,\n"
				"    Atlanta Braves ]\n"
				": [ 2001-07-02, 2001-08-12,\n"
				"    2001-08-14 ]";

311
			PARSE(doc, input);
312
			YAML_ASSERT(doc.size() == 2);
313
314
			YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")].size() == 1);
			YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")][0] == "2001-07-23");
315
316
317
318
319
320
			YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")].size() == 3);
			YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][0] == "2001-07-02");
			YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1] == "2001-08-12");
			YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][2] == "2001-08-14");
			return true;
		}
321
		
322
		// 2.12
323
324
325
326
327
328
329
330
331
332
333
		TEST CompactNestedMapping()
		{
			std::string input =
				"---\n"
				"# Products purchased\n"
				"- item    : Super Hoop\n"
				"  quantity: 1\n"
				"- item    : Basketball\n"
				"  quantity: 4\n"
				"- item    : Big Shoes\n"
				"  quantity: 1";
334
335

			PARSE(doc, input);
336
337
338
339
340
341
342
343
344
345
346
347
348
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].size() == 2);
			YAML_ASSERT(doc[0]["item"] == "Super Hoop");
			YAML_ASSERT(doc[0]["quantity"] == 1);
			YAML_ASSERT(doc[1].size() == 2);
			YAML_ASSERT(doc[1]["item"] == "Basketball");
			YAML_ASSERT(doc[1]["quantity"] == 4);
			YAML_ASSERT(doc[2].size() == 2);
			YAML_ASSERT(doc[2]["item"] == "Big Shoes");
			YAML_ASSERT(doc[2]["quantity"] == 1);
			return true;
		}
		
349
		// 2.13
350
351
352
353
354
355
356
		TEST InLiteralsNewlinesArePreserved()
		{
			std::string input =
				"# ASCII Art\n"
				"--- |\n"
				"  \\//||\\/||\n"
				"  // ||  ||__";
357
358

			PARSE(doc, input);
359
360
361
362
363
			YAML_ASSERT(doc ==
						"\\//||\\/||\n"
						"// ||  ||__");
			return true;
		}
364
365
366
367
368
369
370
371
372
		
		// 2.14
		TEST InFoldedScalarsNewlinesBecomeSpaces()
		{
			std::string input =
				"--- >\n"
				"  Mark McGwire's\n"
				"  year was crippled\n"
				"  by a knee injury.";
373
374

			PARSE(doc, input);
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
			YAML_ASSERT(doc == "Mark McGwire's year was crippled by a knee injury.");
			return true;
		}
		
		// 2.15
		TEST FoldedNewlinesArePreservedForMoreIndentedAndBlankLines()
		{
			std::string input =
				">\n"
				" Sammy Sosa completed another\n"
				" fine season with great stats.\n"
				" \n"
				"   63 Home Runs\n"
				"   0.288 Batting Average\n"
				" \n"
				" What a year!";
391
392

			PARSE(doc, input);
393
			YAML_ASSERT(doc ==
Jesse Beder's avatar
Jesse Beder committed
394
						"Sammy Sosa completed another fine season with great stats.\n\n"
395
						"  63 Home Runs\n"
Jesse Beder's avatar
Jesse Beder committed
396
						"  0.288 Batting Average\n\n"
397
398
399
400
401
402
403
404
405
406
407
408
409
410
						"What a year!");
			return true;
		}
		
		// 2.16
		TEST IndentationDeterminesScope()
		{
			std::string input =
				"name: Mark McGwire\n"
				"accomplishment: >\n"
				"  Mark set a major league\n"
				"  home run record in 1998.\n"
				"stats: |\n"
				"  65 Home Runs\n"
411
				"  0.278 Batting Average\n";
412
413

			PARSE(doc, input);
414
415
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["name"] == "Mark McGwire");
416
417
			YAML_ASSERT(doc["accomplishment"] == "Mark set a major league home run record in 1998.\n");
			YAML_ASSERT(doc["stats"] == "65 Home Runs\n0.278 Batting Average\n");
418
419
420
421
422
423
424
425
426
427
428
429
430
431
			return true;
		}
		
		// 2.17
		TEST QuotedScalars()
		{
			std::string input =
				"unicode: \"Sosa did fine.\\u263A\"\n"
				"control: \"\\b1998\\t1999\\t2000\\n\"\n"
				"hex esc: \"\\x0d\\x0a is \\r\\n\"\n"
				"\n"
				"single: '\"Howdy!\" he cried.'\n"
				"quoted: ' # Not a ''comment''.'\n"
				"tie-fighter: '|\\-*-/|'";
432
433

			PARSE(doc, input);
434
			YAML_ASSERT(doc.size() == 6);
435
			YAML_ASSERT(doc["unicode"] == "Sosa did fine.\xe2\x98\xba");
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
			YAML_ASSERT(doc["control"] == "\b1998\t1999\t2000\n");
			YAML_ASSERT(doc["hex esc"] == "\x0d\x0a is \r\n");
			YAML_ASSERT(doc["single"] == "\"Howdy!\" he cried.");
			YAML_ASSERT(doc["quoted"] == " # Not a 'comment'.");
			YAML_ASSERT(doc["tie-fighter"] == "|\\-*-/|");
			return true;
		}
		
		// 2.18
		TEST MultiLineFlowScalars()
		{
			std::string input =
				"plain:\n"
				"  This unquoted scalar\n"
				"  spans many lines.\n"
				"\n"
				"quoted: \"So does this\n"
				"  quoted scalar.\\n\"";
454
455

			PARSE(doc, input);
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["plain"] == "This unquoted scalar spans many lines.");
			YAML_ASSERT(doc["quoted"] == "So does this quoted scalar.\n");
			return true;
		}
		
		// TODO: 2.19 - 2.26 tags
		
		// 2.27
		TEST Invoice()
		{
			std::string input =
				"--- !<tag:clarkevans.com,2002:invoice>\n"
				"invoice: 34843\n"
				"date   : 2001-01-23\n"
				"bill-to: &id001\n"
				"    given  : Chris\n"
				"    family : Dumars\n"
				"    address:\n"
				"        lines: |\n"
				"            458 Walkman Dr.\n"
				"            Suite #292\n"
				"        city    : Royal Oak\n"
				"        state   : MI\n"
				"        postal  : 48046\n"
				"ship-to: *id001\n"
				"product:\n"
				"    - sku         : BL394D\n"
				"      quantity    : 4\n"
				"      description : Basketball\n"
				"      price       : 450.00\n"
				"    - sku         : BL4438H\n"
				"      quantity    : 1\n"
				"      description : Super Hoop\n"
				"      price       : 2392.00\n"
				"tax  : 251.42\n"
				"total: 4443.52\n"
				"comments:\n"
				"    Late afternoon is best.\n"
				"    Backup contact is Nancy\n"
				"    Billsmer @ 338-4338.";
497
498

			PARSE(doc, input);
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
			YAML_ASSERT(doc.size() == 8);
			YAML_ASSERT(doc["invoice"] == 34843);
			YAML_ASSERT(doc["date"] == "2001-01-23");
			YAML_ASSERT(doc["bill-to"].size() == 3);
			YAML_ASSERT(doc["bill-to"]["given"] == "Chris");
			YAML_ASSERT(doc["bill-to"]["family"] == "Dumars");
			YAML_ASSERT(doc["bill-to"]["address"].size() == 4);
			YAML_ASSERT(doc["bill-to"]["address"]["lines"] == "458 Walkman Dr.\nSuite #292\n");
			YAML_ASSERT(doc["bill-to"]["address"]["city"] == "Royal Oak");
			YAML_ASSERT(doc["bill-to"]["address"]["state"] == "MI");
			YAML_ASSERT(doc["bill-to"]["address"]["postal"] == "48046");
			YAML_ASSERT(doc["ship-to"].size() == 3);
			YAML_ASSERT(doc["ship-to"]["given"] == "Chris");
			YAML_ASSERT(doc["ship-to"]["family"] == "Dumars");
			YAML_ASSERT(doc["ship-to"]["address"].size() == 4);
			YAML_ASSERT(doc["ship-to"]["address"]["lines"] == "458 Walkman Dr.\nSuite #292\n");
			YAML_ASSERT(doc["ship-to"]["address"]["city"] == "Royal Oak");
			YAML_ASSERT(doc["ship-to"]["address"]["state"] == "MI");
			YAML_ASSERT(doc["ship-to"]["address"]["postal"] == "48046");
			YAML_ASSERT(doc["product"].size() == 2);
			YAML_ASSERT(doc["product"][0].size() == 4);
			YAML_ASSERT(doc["product"][0]["sku"] == "BL394D");
			YAML_ASSERT(doc["product"][0]["quantity"] == 4);
			YAML_ASSERT(doc["product"][0]["description"] == "Basketball");
			YAML_ASSERT(doc["product"][0]["price"] == "450.00");
			YAML_ASSERT(doc["product"][1].size() == 4);
			YAML_ASSERT(doc["product"][1]["sku"] == "BL4438H");
			YAML_ASSERT(doc["product"][1]["quantity"] == 1);
			YAML_ASSERT(doc["product"][1]["description"] == "Super Hoop");
			YAML_ASSERT(doc["product"][1]["price"] == "2392.00");
			YAML_ASSERT(doc["tax"] == "251.42");
			YAML_ASSERT(doc["total"] == "4443.52");
			YAML_ASSERT(doc["comments"] == "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.");
			return true;
		}
		
		// 2.28
		TEST LogFile()
		{
			std::string input =
				"---\n"
				"Time: 2001-11-23 15:01:42 -5\n"
				"User: ed\n"
				"Warning:\n"
				"  This is an error message\n"
				"  for the log file\n"
				"---\n"
				"Time: 2001-11-23 15:02:31 -5\n"
				"User: ed\n"
				"Warning:\n"
				"  A slightly different error\n"
				"  message.\n"
				"---\n"
				"Date: 2001-11-23 15:03:17 -5\n"
				"User: ed\n"
				"Fatal:\n"
				"  Unknown variable \"bar\"\n"
				"Stack:\n"
				"  - file: TopClass.py\n"
				"    line: 23\n"
				"    code: |\n"
				"      x = MoreObject(\"345\\n\")\n"
				"  - file: MoreClass.py\n"
				"    line: 58\n"
				"    code: |-\n"
				"      foo = bar";
565
566

			PARSE(doc, input);
567
568
569
570
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["Time"] == "2001-11-23 15:01:42 -5");
			YAML_ASSERT(doc["User"] == "ed");
			YAML_ASSERT(doc["Warning"] == "This is an error message for the log file");
571
572

			PARSE_NEXT(doc);
573
574
575
576
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["Time"] == "2001-11-23 15:02:31 -5");
			YAML_ASSERT(doc["User"] == "ed");
			YAML_ASSERT(doc["Warning"] == "A slightly different error message.");
577
578

			PARSE_NEXT(doc);
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc["Date"] == "2001-11-23 15:03:17 -5");
			YAML_ASSERT(doc["User"] == "ed");
			YAML_ASSERT(doc["Fatal"] == "Unknown variable \"bar\"");
			YAML_ASSERT(doc["Stack"].size() == 2);
			YAML_ASSERT(doc["Stack"][0].size() == 3);
			YAML_ASSERT(doc["Stack"][0]["file"] == "TopClass.py");
			YAML_ASSERT(doc["Stack"][0]["line"] == "23");
			YAML_ASSERT(doc["Stack"][0]["code"] == "x = MoreObject(\"345\\n\")\n");
			YAML_ASSERT(doc["Stack"][1].size() == 3);
			YAML_ASSERT(doc["Stack"][1]["file"] == "MoreClass.py");
			YAML_ASSERT(doc["Stack"][1]["line"] == "58");
			YAML_ASSERT(doc["Stack"][1]["code"] == "foo = bar");
			return true;
		}
		
		// TODO: 5.1 - 5.2 BOM
		
		// 5.3
		TEST BlockStructureIndicators()
		{
			std::string input =
				"sequence:\n"
				"- one\n"
				"- two\n"
				"mapping:\n"
				"  ? sky\n"
				"  : blue\n"
				"  sea : green";
608
609

			PARSE(doc, input);
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["sequence"].size() == 2);
			YAML_ASSERT(doc["sequence"][0] == "one");
			YAML_ASSERT(doc["sequence"][1] == "two");
			YAML_ASSERT(doc["mapping"].size() == 2);
			YAML_ASSERT(doc["mapping"]["sky"] == "blue");
			YAML_ASSERT(doc["mapping"]["sea"] == "green");
			return true;
		}
		
		// 5.4
		TEST FlowStructureIndicators()
		{
			std::string input =
				"sequence: [ one, two, ]\n"
				"mapping: { sky: blue, sea: green }";
626
627

			PARSE(doc, input);
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["sequence"].size() == 2);
			YAML_ASSERT(doc["sequence"][0] == "one");
			YAML_ASSERT(doc["sequence"][1] == "two");
			YAML_ASSERT(doc["mapping"].size() == 2);
			YAML_ASSERT(doc["mapping"]["sky"] == "blue");
			YAML_ASSERT(doc["mapping"]["sea"] == "green");
			return true;
		}
		
		// TODO: 5.5 comment only
		
		// 5.6
		TEST NodePropertyIndicators()
		{
			std::string input =
				"anchored: !local &anchor value\n"
				"alias: *anchor";
646
647

			PARSE(doc, input);
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["anchored"] == "value"); // TODO: assert tag
			YAML_ASSERT(doc["alias"] == "value");
			return true;
		}
		
		// 5.7
		TEST BlockScalarIndicators()
		{
			std::string input =
				"literal: |\n"
				"  some\n"
				"  text\n"
				"folded: >\n"
				"  some\n"
				"  text\n";
664
665

			PARSE(doc, input);
666
667
668
669
670
671
672
673
674
675
676
677
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["literal"] == "some\ntext\n");
			YAML_ASSERT(doc["folded"] == "some text\n");
			return true;
		}
		
		// 5.8
		TEST QuotedScalarIndicators()
		{
			std::string input =
				"single: 'text'\n"
				"double: \"text\"";
678
679

			PARSE(doc, input);
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["single"] == "text");
			YAML_ASSERT(doc["double"] == "text");
			return true;
		}
		
		// TODO: 5.9 directive
		// TODO: 5.10 reserved indicator
		
		// 5.11
		TEST LineBreakCharacters()
		{
			std::string input =
				"|\n"
				"  Line break (no glyph)\n"
				"  Line break (glyphed)\n";
696
697

			PARSE(doc, input);
698
699
700
701
702
703
704
705
706
707
708
709
710
711
			YAML_ASSERT(doc == "Line break (no glyph)\nLine break (glyphed)\n");
			return true;
		}
		
		// 5.12
		TEST TabsAndSpaces()
		{
			std::string input =
				"# Tabs and spaces\n"
				"quoted: \"Quoted\t\"\n"
				"block:	|\n"
				"  void main() {\n"
				"  \tprintf(\"Hello, world!\\n\");\n"
				"  }";
712
713

			PARSE(doc, input);
714
715
716
717
718
719
720
721
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["quoted"] == "Quoted\t");
			YAML_ASSERT(doc["block"] ==
						"void main() {\n"
						"\tprintf(\"Hello, world!\\n\");\n"
						"}");
			return true;
		}
722
723
724
725
726
727
728
729
730
731
		
		// 5.13
		TEST EscapedCharacters()
		{
			std::string input =
				"\"Fun with \\\\\n"
				"\\\" \\a \\b \\e \\f \\\n"
				"\\n \\r \\t \\v \\0 \\\n"
				"\\  \\_ \\N \\L \\P \\\n"
				"\\x41 \\u0041 \\U00000041\"";
732
733

			PARSE(doc, input);
734
			YAML_ASSERT(doc == "Fun with \x5C \x22 \x07 \x08 \x1B \x0C \x0A \x0D \x09 \x0B " + std::string("\x00", 1) + " \x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9 A A A");
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
			return true;
		}
		
		// 5.14
		TEST InvalidEscapedCharacters()
		{
			std::string input =
				"Bad escapes:\n"
				"  \"\\c\n"
				"  \\xq-\"";
			
			std::stringstream stream(input);
			try {
				YAML::Parser parser(stream);
				YAML::Node doc;
				parser.GetNextDocument(doc);
			} catch(const YAML::ParserException& e) {
				YAML_ASSERT(e.msg == YAML::ErrorMsg::INVALID_ESCAPE + "c");
				return true;
			}
			
			return false;
		}
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
		
		// 6.1
		TEST IndentationSpaces()
		{
			std::string input =
				"  # Leading comment line spaces are\n"
				"   # neither content nor indentation.\n"
				"    \n"
				"Not indented:\n"
				" By one space: |\n"
				"    By four\n"
				"      spaces\n"
				" Flow style: [    # Leading spaces\n"
				"   By two,        # in flow style\n"
				"  Also by two,    # are neither\n"
				"  \tStill by two   # content nor\n"
				"    ]             # indentation.";
775
776

			PARSE(doc, input);
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["Not indented"].size() == 2);
			YAML_ASSERT(doc["Not indented"]["By one space"] == "By four\n  spaces\n");
			YAML_ASSERT(doc["Not indented"]["Flow style"].size() == 3);
			YAML_ASSERT(doc["Not indented"]["Flow style"][0] == "By two");
			YAML_ASSERT(doc["Not indented"]["Flow style"][1] == "Also by two");
			YAML_ASSERT(doc["Not indented"]["Flow style"][2] == "Still by two");
			return true;
		}
		
		// 6.2
		TEST IndentationIndicators()
		{
			std::string input =
				"? a\n"
				": -\tb\n"
				"  -  -\tc\n"
				"     - d";
795
796

			PARSE(doc, input);
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["a"].size() == 2);
			YAML_ASSERT(doc["a"][0] == "b");
			YAML_ASSERT(doc["a"][1].size() == 2);
			YAML_ASSERT(doc["a"][1][0] == "c");
			YAML_ASSERT(doc["a"][1][1] == "d");
			return true;
		}
		
		// 6.3
		TEST SeparationSpaces()
		{
			std::string input =
				"- foo:\t bar\n"
				"- - baz\n"
				"  -\tbaz";
813
814

			PARSE(doc, input);
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 1);
			YAML_ASSERT(doc[0]["foo"] == "bar");
			YAML_ASSERT(doc[1].size() == 2);
			YAML_ASSERT(doc[1][0] == "baz");
			YAML_ASSERT(doc[1][1] == "baz");
			return true;
		}
		
		// 6.4
		TEST LinePrefixes()
		{
			std::string input =
				"plain: text\n"
				"  lines\n"
				"quoted: \"text\n"
				"  \tlines\"\n"
				"block: |\n"
				"  text\n"
				"   \tlines\n";
835
836

			PARSE(doc, input);
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["plain"] == "text lines");
			YAML_ASSERT(doc["quoted"] == "text lines");
			YAML_ASSERT(doc["block"] == "text\n \tlines\n");
			return true;
		}
		
		// 6.5
		TEST EmptyLines()
		{
			std::string input =
				"Folding:\n"
				"  \"Empty line\n"
				"   \t\n"
				"  as a line feed\"\n"
				"Chomping: |\n"
				"  Clipped empty lines\n"
				" ";
855
856

			PARSE(doc, input);
857
858
859
860
861
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["Folding"] == "Empty line\nas a line feed");
			YAML_ASSERT(doc["Chomping"] == "Clipped empty lines\n");
			return true;
		}
862
863
864
865
866
867
868
869
870
871
872
873
		
		// 6.6
		TEST LineFolding()
		{
			std::string input =
				">-\n"
				"  trimmed\n"
				"  \n"
				" \n"
				"\n"
				"  as\n"
				"  space";
874
875

			PARSE(doc, input);
876
877
878
879
880
881
882
883
884
885
886
887
888
889
			YAML_ASSERT(doc == "trimmed\n\n\nas space");
			return true;
		}
		
		// 6.7
		TEST BlockFolding()
		{
			std::string input =
				">\n"
				"  foo \n"
				" \n"
				"  \t bar\n"
				"\n"
				"  baz\n";
890
891

			PARSE(doc, input);
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
			YAML_ASSERT(doc == "foo \n\n\t bar\n\nbaz\n");
			return true;
		}
		
		// 6.8
		TEST FlowFolding()
		{
			std::string input =
				"\"\n"
				"  foo \n"
				" \n"
				"  \t bar\n"
				"\n"
				"  baz\n"
				"\"";
907
908

			PARSE(doc, input);			
909
910
911
			YAML_ASSERT(doc == " foo\nbar\nbaz ");
			return true;
		}
912
913
914
915
916
917
918
		
		// 6.9
		TEST SeparatedComment()
		{
			std::string input =
				"key:    # Comment\n"
				"  value";
919
920

			PARSE(doc, input);
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["key"] == "value");
			return true;
		}
		
		// 6.10
		TEST CommentLines()
		{
			std::string input =
				"  # Comment\n"
				"   \n"
				"\n";
			std::stringstream stream(input);
			YAML::Parser parser(stream);
			
			YAML_ASSERT(!parser);
			return true;
		}
		
		// 6.11
		TEST MultiLineComments()
		{
			std::string input =
				"key:    # Comment\n"
				"        # lines\n"
				"  value\n"
				"\n";
948
949

			PARSE(doc, input);
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["key"] == "value");
			return true;
		}

		struct StringMap {
			typedef std::map<std::string, std::string> Map;
			Map _;
		};
		
		bool operator == (const StringMap& m, const StringMap& n) {
			return m._ == n._;
		}
		
		void operator >> (const YAML::Node& node, StringMap& m) {
			m._.clear();
			for(YAML::Iterator it=node.begin();it!=node.end();++it) {
				std::string key = it.first();
				std::string value = it.second();
				m._[key] = value;
			}
		}

		
		// 6.12
		TEST SeparationSpacesII()
		{
			std::string input =
				"{ first: Sammy, last: Sosa }:\n"
				"# Statistics:\n"
				"  hr:  # Home runs\n"
				"     65\n"
				"  avg: # Average\n"
				"   0.278";
984
985

			PARSE(doc, input);
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
			StringMap key;
			key._["first"] = "Sammy";
			key._["last"] = "Sosa";
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc[key].size() == 2);
			YAML_ASSERT(doc[key]["hr"] == 65);
			YAML_ASSERT(doc[key]["avg"] == "0.278");
			return true;
		}
		
		// TODO: 6.13 - 6.17 directives
		// TODO: 6.18 - 6.28 tags

		// 6.29
		TEST NodeAnchors()
		{
			std::string input =
				"First occurrence: &anchor Value\n"
				"Second occurrence: *anchor";
1005
1006

			PARSE(doc, input);
1007
1008
1009
1010
1011
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["First occurrence"] == "Value");
			YAML_ASSERT(doc["Second occurrence"] == "Value");
			return true;
		}
1012
1013
1014
1015
1016
1017
1018
1019
1020
		
		// 7.1
		TEST AliasNodes()
		{
			std::string input =
				"First occurrence: &anchor Foo\n"
				"Second occurrence: *anchor\n"
				"Override anchor: &anchor Bar\n"
				"Reuse anchor: *anchor";
1021
1022

			PARSE(doc, input);
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc["First occurrence"] == "Foo");
			YAML_ASSERT(doc["Second occurrence"] == "Foo");
			YAML_ASSERT(doc["Override anchor"] == "Bar");
			YAML_ASSERT(doc["Reuse anchor"] == "Bar");
			return true;
		}
		
		// 7.2
		TEST EmptyNodes()
		{
			std::string input =
				"{\n"
				"  foo : !!str,\n"
				"  !!str : bar,\n"
				"}";
1039
1040

			PARSE(doc, input);
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["foo"] == ""); // TODO: check tag
			YAML_ASSERT(doc[""] == "bar");
			return true;
		}
		
		// 7.3
		TEST CompletelyEmptyNodes()
		{
			std::string input =
				"{\n"
				"  ? foo :,\n"
				"  : bar,\n"
				"}\n";
1055
1056

			PARSE(doc, input);
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(IsNull(doc["foo"]));
			YAML_ASSERT(doc[YAML::Null] == "bar");
			return true;
		}
		
		// 7.4
		TEST DoubleQuotedImplicitKeys()
		{
			std::string input =
				"\"implicit block key\" : [\n"
				"  \"implicit flow key\" : value,\n"
				" ]";
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163

			PARSE(doc, input);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["implicit block key"].size() == 1);
			YAML_ASSERT(doc["implicit block key"][0].size() == 1);
			YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"] == "value");
			return true;
		}
		
		// 7.5
		TEST DoubleQuotedLineBreaks()
		{
			std::string input =
				"\"folded \n"
				"to a space,\t\n"
				" \n"
				"to a line feed, or \t\\\n"
				" \\ \tnon-content\"";

			PARSE(doc, input);
			YAML_ASSERT(doc == "folded to a space,\nto a line feed, or \t \tnon-content");
			return true;
		}
		
		// 7.6
		TEST DoubleQuotedLines()
		{
			std::string input =
				"\" 1st non-empty\n"
				"\n"
				" 2nd non-empty \n"
				"\t3rd non-empty \"";

			PARSE(doc, input);
			YAML_ASSERT(doc == " 1st non-empty\n2nd non-empty 3rd non-empty ");
			return true;
		}
		
		// 7.7
		TEST SingleQuotedCharacters()
		{
			std::string input = " 'here''s to \"quotes\"'";

			PARSE(doc, input);
			YAML_ASSERT(doc == "here's to \"quotes\"");
			return true;
		}
		
		// 7.8
		TEST SingleQuotedImplicitKeys()
		{
			std::string input =
				"'implicit block key' : [\n"
				"  'implicit flow key' : value,\n"
				" ]";
			
			PARSE(doc, input);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["implicit block key"].size() == 1);
			YAML_ASSERT(doc["implicit block key"][0].size() == 1);
			YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"] == "value");
			return true;
		}
		
		// 7.9
		TEST SingleQuotedLines()
		{
			std::string input =
				"' 1st non-empty\n"
				"\n"
				" 2nd non-empty \n"
				"\t3rd non-empty '";
			
			PARSE(doc, input);
			YAML_ASSERT(doc == " 1st non-empty\n2nd non-empty 3rd non-empty ");
			return true;
		}
		
		// 7.10
		TEST PlainCharacters()
		{
			std::string input =
				"# Outside flow collection:\n"
				"- ::vector\n"
				"- \": - ()\"\n"
				"- Up, up, and away!\n"
				"- -123\n"
				"- http://example.com/foo#bar\n"
				"# Inside flow collection:\n"
				"- [ ::vector,\n"
				"  \": - ()\",\n"
				"  \"Up, up, and away!\",\n"
				"  -123,\n"
				"  http://example.com/foo#bar ]";
1164
			
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
			PARSE(doc, input);
			YAML_ASSERT(doc.size() == 6);
			YAML_ASSERT(doc[0] == "::vector");
			YAML_ASSERT(doc[1] == ": - ()");
			YAML_ASSERT(doc[2] == "Up, up, and away!");
			YAML_ASSERT(doc[3] == -123);
			YAML_ASSERT(doc[4] == "http://example.com/foo#bar");
			YAML_ASSERT(doc[5].size() == 5);
			YAML_ASSERT(doc[5][0] == "::vector");
			YAML_ASSERT(doc[5][1] == ": - ()");
			YAML_ASSERT(doc[5][2] == "Up, up, and away!");
			YAML_ASSERT(doc[5][3] == -123);
			YAML_ASSERT(doc[5][4] == "http://example.com/foo#bar");
			return true;
		}
		
		// 7.11
		TEST PlainImplicitKeys()
		{
			std::string input =
				"implicit block key : [\n"
				"  implicit flow key : value,\n"
				" ]";

			PARSE(doc, input);
1190
1191
1192
1193
1194
1195
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["implicit block key"].size() == 1);
			YAML_ASSERT(doc["implicit block key"][0].size() == 1);
			YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"] == "value");
			return true;
		}
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
		
		// 7.12
		TEST PlainLines()
		{
			std::string input =
				"1st non-empty\n"
				"\n"
				" 2nd non-empty \n"
				"\t3rd non-empty";
			
			PARSE(doc, input);
			YAML_ASSERT(doc == "1st non-empty\n2nd non-empty 3rd non-empty");
			return true;
		}
Jesse Beder's avatar
Jesse Beder committed
1210
1211
1212
1213
	}

	bool RunSpecTests()
	{
Jesse Beder's avatar
Jesse Beder committed
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
		int passed = 0;
		int total = 0;
		RunSpecTest(&Spec::SeqScalars, "2.1", "Sequence of Scalars", passed, total);
		RunSpecTest(&Spec::MappingScalarsToScalars, "2.2", "Mapping Scalars to Scalars", passed, total);
		RunSpecTest(&Spec::MappingScalarsToSequences, "2.3", "Mapping Scalars to Sequences", passed, total);
		RunSpecTest(&Spec::SequenceOfMappings, "2.4", "Sequence of Mappings", passed, total);
		RunSpecTest(&Spec::SequenceOfSequences, "2.5", "Sequence of Sequences", passed, total);
		RunSpecTest(&Spec::MappingOfMappings, "2.6", "Mapping of Mappings", passed, total);
		RunSpecTest(&Spec::TwoDocumentsInAStream, "2.7", "Two Documents in a Stream", passed, total);
		RunSpecTest(&Spec::PlayByPlayFeed, "2.8", "Play by Play Feed from a Game", passed, total);
		RunSpecTest(&Spec::SingleDocumentWithTwoComments, "2.9", "Single Document with Two Comments", passed, total);
		RunSpecTest(&Spec::SimpleAnchor, "2.10", "Node for \"Sammy Sosa\" appears twice in this document", passed, total);
		RunSpecTest(&Spec::MappingBetweenSequences, "2.11", "Mapping between Sequences", passed, total);
		RunSpecTest(&Spec::CompactNestedMapping, "2.12", "Compact Nested Mapping", passed, total);
		RunSpecTest(&Spec::InLiteralsNewlinesArePreserved, "2.13", "In literals, newlines are preserved", passed, total);
		RunSpecTest(&Spec::InFoldedScalarsNewlinesBecomeSpaces, "2.14", "In folded scalars, newlines become spaces", passed, total);
		RunSpecTest(&Spec::FoldedNewlinesArePreservedForMoreIndentedAndBlankLines, "2.15", "Folded newlines are preserved for \"more indented\" and blank lines", passed, total);
		RunSpecTest(&Spec::IndentationDeterminesScope, "2.16", "Indentation determines scope", passed, total);
		RunSpecTest(&Spec::QuotedScalars, "2.17", "Quoted scalars", passed, total);
		RunSpecTest(&Spec::MultiLineFlowScalars, "2.18", "Multi-line flow scalars", passed, total);
		
		RunSpecTest(&Spec::Invoice, "2.27", "Invoice", passed, total);
		RunSpecTest(&Spec::LogFile, "2.28", "Log File", passed, total);
		
		RunSpecTest(&Spec::BlockStructureIndicators, "5.3", "Block Structure Indicators", passed, total);
		RunSpecTest(&Spec::FlowStructureIndicators, "5.4", "Flow Structure Indicators", passed, total);
		RunSpecTest(&Spec::NodePropertyIndicators, "5.6", "Node Property Indicators", passed, total);
		RunSpecTest(&Spec::BlockScalarIndicators, "5.7", "Block Scalar Indicators", passed, total);
		RunSpecTest(&Spec::QuotedScalarIndicators, "5.8", "Quoted Scalar Indicators", passed, total);
		RunSpecTest(&Spec::LineBreakCharacters, "5.11", "Line Break Characters", passed, total);
		RunSpecTest(&Spec::TabsAndSpaces, "5.12", "Tabs and Spaces", passed, total);
		RunSpecTest(&Spec::EscapedCharacters, "5.13", "Escaped Characters", passed, total);
		RunSpecTest(&Spec::InvalidEscapedCharacters, "5.14", "Invalid Escaped Characters", passed, total);
		
		RunSpecTest(&Spec::IndentationSpaces, "6.1", "Indentation Spaces", passed, total);
		RunSpecTest(&Spec::IndentationIndicators, "6.2", "Indentation Indicators", passed, total);
		RunSpecTest(&Spec::SeparationSpaces, "6.3", "Separation Spaces", passed, total);
		RunSpecTest(&Spec::LinePrefixes, "6.4", "Line Prefixes", passed, total);
		RunSpecTest(&Spec::EmptyLines, "6.5", "Empty Lines", passed, total);
1253
1254
1255
		RunSpecTest(&Spec::LineFolding, "6.6", "Line Folding", passed, total);
		RunSpecTest(&Spec::BlockFolding, "6.7", "Block Folding", passed, total);
		RunSpecTest(&Spec::FlowFolding, "6.8", "Flow Folding", passed, total);
1256
1257
1258
1259
1260
		RunSpecTest(&Spec::SeparatedComment, "6.9", "Separated Comment", passed, total);
		RunSpecTest(&Spec::CommentLines, "6.10", "Comment Lines", passed, total);
		RunSpecTest(&Spec::SeparationSpacesII, "6.11", "Separation Spaces", passed, total);
		
		RunSpecTest(&Spec::NodeAnchors, "6.29", "Node Anchors", passed, total);
1261
1262
1263
1264
1265
		
		RunSpecTest(&Spec::AliasNodes, "7.1", "Alias Nodes", passed, total);
		RunSpecTest(&Spec::EmptyNodes, "7.2", "Empty Nodes", passed, total);
		RunSpecTest(&Spec::CompletelyEmptyNodes, "7.3", "Completely Empty Nodes", passed, total);
		RunSpecTest(&Spec::DoubleQuotedImplicitKeys, "7.4", "Double Quoted Implicit Keys", passed, total);
1266
1267
1268
1269
1270
1271
1272
1273
		RunSpecTest(&Spec::DoubleQuotedLineBreaks, "7.5", "Double Quoted Line Breaks", passed, total);
		RunSpecTest(&Spec::DoubleQuotedLines, "7.6", "Double Quoted Lines", passed, total);
		RunSpecTest(&Spec::SingleQuotedCharacters, "7.7", "Single Quoted Characters", passed, total);
		RunSpecTest(&Spec::SingleQuotedImplicitKeys, "7.8", "Single Quoted Implicit Keys", passed, total);
		RunSpecTest(&Spec::SingleQuotedLines, "7.9", "Single Quoted Lines", passed, total);
		RunSpecTest(&Spec::PlainCharacters, "7.10", "Plain Characters", passed, total);
		RunSpecTest(&Spec::PlainImplicitKeys, "7.11", "Plain Implicit Keys", passed, total);
		RunSpecTest(&Spec::PlainLines, "7.12", "Plain Lines", passed, total);
Jesse Beder's avatar
Jesse Beder committed
1274
1275
1276

		std::cout << "Spec tests: " << passed << "/" << total << " passed\n";
		return passed == total;
Jesse Beder's avatar
Jesse Beder committed
1277
1278
1279
1280
	}
	
}