spectests.cpp 31.5 KB
Newer Older
1
#include "spectests.h"
2
3
4
5
#include "specexamples.h"
#include "yaml-cpp/yaml.h"

#define YAML_ASSERT(cond) do { if(!(cond)) return "  Assert failed: " #cond; } while(false)
6

7
8
9
namespace Test
{
	namespace Spec
10
	{
11
		// 2.1
12
13
14
15
16
17
18
19
20
		TEST SeqScalars() {
			YAML::Node doc = YAML::Parse(ex2_1);
			YAML_ASSERT(doc.Type() == YAML::NodeType::Sequence);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].as<std::string>() == "Mark McGwire");
			YAML_ASSERT(doc[1].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc[2].as<std::string>() == "Ken Griffey");
			return true;
		}
21
22
		
		// 2.2
23
24
25
26
27
28
29
30
31
		TEST MappingScalarsToScalars() {
			YAML::Node doc = YAML::Parse(ex2_2);
			YAML_ASSERT(doc.Type() == YAML::NodeType::Map);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["hr"].as<std::string>() == "65");
			YAML_ASSERT(doc["avg"].as<std::string>() == "0.278");
			YAML_ASSERT(doc["rbi"].as<std::string>() == "147");
			return true;
		}
32
33
		
		// 2.3
34
35
36
37
38
39
40
41
42
43
44
45
46
47
		TEST MappingScalarsToSequences() {
			YAML::Node doc = YAML::Parse(ex2_3);
			YAML_ASSERT(doc.Type() == YAML::NodeType::Map);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["american"].size() == 3);
			YAML_ASSERT(doc["american"][0].as<std::string>() == "Boston Red Sox");
			YAML_ASSERT(doc["american"][1].as<std::string>() == "Detroit Tigers");
			YAML_ASSERT(doc["american"][2].as<std::string>() == "New York Yankees");
			YAML_ASSERT(doc["national"].size() == 3);
			YAML_ASSERT(doc["national"][0].as<std::string>() == "New York Mets");
			YAML_ASSERT(doc["national"][1].as<std::string>() == "Chicago Cubs");
			YAML_ASSERT(doc["national"][2].as<std::string>() == "Atlanta Braves");
			return true;
		}
48
49
		
		// 2.4
50
51
52
53
54
55
56
57
58
59
60
61
62
		TEST SequenceOfMappings() {
			YAML::Node doc = YAML::Parse(ex2_4);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 3);
			YAML_ASSERT(doc[0]["name"].as<std::string>() == "Mark McGwire");
			YAML_ASSERT(doc[0]["hr"].as<std::string>() == "65");
			YAML_ASSERT(doc[0]["avg"].as<std::string>() == "0.278");
			YAML_ASSERT(doc[1].size() == 3);
			YAML_ASSERT(doc[1]["name"].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc[1]["hr"].as<std::string>() == "63");
			YAML_ASSERT(doc[1]["avg"].as<std::string>() == "0.288");
			return true;
		}
63
64
		
		// 2.5
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
		TEST SequenceOfSequences() {
			YAML::Node doc = YAML::Parse(ex2_5);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].size() == 3);
			YAML_ASSERT(doc[0][0].as<std::string>() == "name");
			YAML_ASSERT(doc[0][1].as<std::string>() == "hr");
			YAML_ASSERT(doc[0][2].as<std::string>() == "avg");
			YAML_ASSERT(doc[1].size() == 3);
			YAML_ASSERT(doc[1][0].as<std::string>() == "Mark McGwire");
			YAML_ASSERT(doc[1][1].as<std::string>() == "65");
			YAML_ASSERT(doc[1][2].as<std::string>() == "0.278");
			YAML_ASSERT(doc[2].size() == 3);
			YAML_ASSERT(doc[2][0].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc[2][1].as<std::string>() == "63");
			YAML_ASSERT(doc[2][2].as<std::string>() == "0.288");
			return true;
		}
82
83
		
		// 2.6
84
85
86
87
88
89
90
91
92
93
94
		TEST MappingOfMappings() {
			YAML::Node doc = YAML::Parse(ex2_6);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["Mark McGwire"].size() == 2);
			YAML_ASSERT(doc["Mark McGwire"]["hr"].as<std::string>() == "65");
			YAML_ASSERT(doc["Mark McGwire"]["avg"].as<std::string>() == "0.278");
			YAML_ASSERT(doc["Sammy Sosa"].size() == 2);
			YAML_ASSERT(doc["Sammy Sosa"]["hr"].as<std::string>() == "63");
			YAML_ASSERT(doc["Sammy Sosa"]["avg"].as<std::string>() == "0.288");
			return true;
		}
95
96
		
		// 2.7
97
98
99
		TEST TwoDocumentsInAStream() {
			return "  not written yet"; 
		}
100
101
		
		// 2.8
102
103
104
		TEST PlayByPlayFeed() {
			return "  not written yet";
		}
105
106
		
		// 2.9
107
108
109
110
111
112
113
114
115
116
117
		TEST SingleDocumentWithTwoComments() {
			YAML::Node doc = YAML::Parse(ex2_9);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["hr"].size() == 2);
			YAML_ASSERT(doc["hr"][0].as<std::string>() == "Mark McGwire");
			YAML_ASSERT(doc["hr"][1].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"].size() == 2);
			YAML_ASSERT(doc["rbi"][0].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"][1].as<std::string>() == "Ken Griffey");
			return true;
		}
118
119
		
		// 2.10
120
121
122
123
124
125
126
127
128
129
130
		TEST SimpleAnchor() {
			YAML::Node doc = YAML::Parse(ex2_10);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["hr"].size() == 2);
			YAML_ASSERT(doc["hr"][0].as<std::string>() == "Mark McGwire");
			YAML_ASSERT(doc["hr"][1].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"].size() == 2);
			YAML_ASSERT(doc["rbi"][0].as<std::string>() == "Sammy Sosa");
			YAML_ASSERT(doc["rbi"][1].as<std::string>() == "Ken Griffey");
			return true;
		}
131
132
		
		// 2.11
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
		TEST MappingBetweenSequences() {
			YAML::Node doc = YAML::Parse(ex2_11);

			std::vector<std::string> tigers_cubs;
			tigers_cubs.push_back("Detroit Tigers");
			tigers_cubs.push_back("Chicago cubs");
			
			std::vector<std::string> yankees_braves;
			yankees_braves.push_back("New York Yankees");
			yankees_braves.push_back("Atlanta Braves");
			
			
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[tigers_cubs].size() == 1);
			YAML_ASSERT(doc[tigers_cubs][0].as<std::string>() == "2001-07-23");
			YAML_ASSERT(doc[yankees_braves].size() == 3);
			YAML_ASSERT(doc[yankees_braves][0].as<std::string>() == "2001-07-02");
			YAML_ASSERT(doc[yankees_braves][1].as<std::string>() == "2001-08-12");
			YAML_ASSERT(doc[yankees_braves][2].as<std::string>() == "2001-08-14");
			return true;
		}
154
155
		
		// 2.12
156
157
158
159
160
161
162
163
164
165
166
167
168
169
		TEST CompactNestedMapping() {
			YAML::Node doc = YAML::Parse(ex2_12);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].size() == 2);
			YAML_ASSERT(doc[0]["item"].as<std::string>() == "Super Hoop");
			YAML_ASSERT(doc[0]["quantity"].as<int>() == 1);
			YAML_ASSERT(doc[1].size() == 2);
			YAML_ASSERT(doc[1]["item"].as<std::string>() == "Basketball");
			YAML_ASSERT(doc[1]["quantity"].as<int>() == 4);
			YAML_ASSERT(doc[2].size() == 2);
			YAML_ASSERT(doc[2]["item"].as<std::string>() == "Big Shoes");
			YAML_ASSERT(doc[2]["quantity"].as<int>() == 1);
			return true;
		}
170
171
		
		// 2.13
172
173
174
175
176
177
178
		TEST InLiteralsNewlinesArePreserved() {
			YAML::Node doc = YAML::Parse(ex2_13);
			YAML_ASSERT(doc.as<std::string>() ==
						"\\//||\\/||\n"
						"// ||  ||__");
			return true;
		}
179
180
		
		// 2.14
181
182
183
184
185
		TEST InFoldedScalarsNewlinesBecomeSpaces() {
			YAML::Node doc = YAML::Parse(ex2_14);
			YAML_ASSERT(doc.as<std::string>() == "Mark McGwire's year was crippled by a knee injury.");
			return true;
		}
186
187
		
		// 2.15
188
189
190
191
192
193
194
195
196
		TEST FoldedNewlinesArePreservedForMoreIndentedAndBlankLines() {
			YAML::Node doc = YAML::Parse(ex2_15);
			YAML_ASSERT(doc.as<std::string>() ==
						"Sammy Sosa completed another fine season with great stats.\n\n"
						"  63 Home Runs\n"
						"  0.288 Batting Average\n\n"
						"What a year!");
			return true;
		}
197
198
		
		// 2.16
199
200
201
202
203
204
205
206
		TEST IndentationDeterminesScope() {
			YAML::Node doc = YAML::Parse(ex2_16);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["name"].as<std::string>() == "Mark McGwire");
			YAML_ASSERT(doc["accomplishment"].as<std::string>() == "Mark set a major league home run record in 1998.\n");
			YAML_ASSERT(doc["stats"].as<std::string>() == "65 Home Runs\n0.278 Batting Average\n");
			return true;
		}
207
208
		
		// 2.17
209
210
211
212
213
214
215
216
217
218
219
		TEST QuotedScalars() {
			YAML::Node doc = YAML::Parse(ex2_17);
			YAML_ASSERT(doc.size() == 6);
			YAML_ASSERT(doc["unicode"].as<std::string>() == "Sosa did fine.\xe2\x98\xba");
			YAML_ASSERT(doc["control"].as<std::string>() == "\b1998\t1999\t2000\n");
			YAML_ASSERT(doc["hex esc"].as<std::string>() == "\x0d\x0a is \r\n");
			YAML_ASSERT(doc["single"].as<std::string>() == "\"Howdy!\" he cried.");
			YAML_ASSERT(doc["quoted"].as<std::string>() == " # Not a 'comment'.");
			YAML_ASSERT(doc["tie-fighter"].as<std::string>() == "|\\-*-/|");
			return true;
		}
220
221
		
		// 2.18
222
223
224
225
226
227
228
		TEST MultiLineFlowScalars() {
			YAML::Node doc = YAML::Parse(ex2_18);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["plain"].as<std::string>() == "This unquoted scalar spans many lines.");
			YAML_ASSERT(doc["quoted"].as<std::string>() == "So does this quoted scalar.\n");
			return true;
		}
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
		
		// TODO: 2.19 - 2.22 schema tags
		
		// 2.23
		TEST VariousExplicitTags() { return "  not written yet"; }
		
		// 2.24
		TEST GlobalTags() { return "  not written yet"; }
		
		// 2.25
		TEST UnorderedSets() { return "  not written yet"; }
		
		// 2.26
		TEST OrderedMappings() { return "  not written yet"; }
		
		// 2.27
		TEST Invoice() { return "  not written yet"; }
		
		// 2.28
		TEST LogFile() { return "  not written yet"; }
		
		// TODO: 5.1 - 5.2 BOM
		
		// 5.3
Jesse Beder's avatar
Jesse Beder committed
253
254
255
256
257
258
259
260
261
262
263
		TEST BlockStructureIndicators() {
			YAML::Node doc = YAML::Parse(ex5_3);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["sequence"].size() == 2);
			YAML_ASSERT(doc["sequence"][0].as<std::string>() == "one");
			YAML_ASSERT(doc["sequence"][1].as<std::string>() == "two");
			YAML_ASSERT(doc["mapping"].size() == 2);
			YAML_ASSERT(doc["mapping"]["sky"].as<std::string>() == "blue");
			YAML_ASSERT(doc["mapping"]["sea"].as<std::string>() == "green");
			return true;
		}
264
265
		
		// 5.4
Jesse Beder's avatar
Jesse Beder committed
266
267
268
269
270
271
272
273
274
275
276
		TEST FlowStructureIndicators() {
			YAML::Node doc = YAML::Parse(ex5_4);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["sequence"].size() == 2);
			YAML_ASSERT(doc["sequence"][0].as<std::string>() == "one");
			YAML_ASSERT(doc["sequence"][1].as<std::string>() == "two");
			YAML_ASSERT(doc["mapping"].size() == 2);
			YAML_ASSERT(doc["mapping"]["sky"].as<std::string>() == "blue");
			YAML_ASSERT(doc["mapping"]["sea"].as<std::string>() == "green");
			return true;
		}
277
278
		
		// 5.5
Jesse Beder's avatar
Jesse Beder committed
279
280
281
282
283
		TEST CommentIndicator() {
			YAML::Node doc = YAML::Parse(ex5_5);
			YAML_ASSERT(doc.Type() == YAML::NodeType::Null);
			return true;
		}
284
285
		
		// 5.6
Jesse Beder's avatar
Jesse Beder committed
286
287
288
289
290
291
292
		TEST NodePropertyIndicators() {
			YAML::Node doc = YAML::Parse(ex5_6);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["anchored"].as<std::string>() == "value"); // TODO: assert tag
			YAML_ASSERT(doc["alias"].as<std::string>() == "value");
			return true;
		}
293
294
		
		// 5.7
Jesse Beder's avatar
Jesse Beder committed
295
296
297
298
299
300
301
		TEST BlockScalarIndicators() {
			YAML::Node doc = YAML::Parse(ex5_7);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["literal"].as<std::string>() == "some\ntext\n");
			YAML_ASSERT(doc["folded"].as<std::string>() == "some text\n");
			return true;
		}
302
303
		
		// 5.8
Jesse Beder's avatar
Jesse Beder committed
304
305
306
307
308
309
310
		TEST QuotedScalarIndicators() {
			YAML::Node doc = YAML::Parse(ex5_8);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["single"].as<std::string>() == "text");
			YAML_ASSERT(doc["double"].as<std::string>() == "text");
			return true;
		}
311
312
313
314
315
		
		// TODO: 5.9 directive
		// TODO: 5.10 reserved indicator
		
		// 5.11
Jesse Beder's avatar
Jesse Beder committed
316
317
318
319
320
		TEST LineBreakCharacters() {
			YAML::Node doc = YAML::Parse(ex5_11);
			YAML_ASSERT(doc.as<std::string>() == "Line break (no glyph)\nLine break (glyphed)\n");
			return true;
		}
321
322
		
		// 5.12
Jesse Beder's avatar
Jesse Beder committed
323
324
325
326
327
328
329
330
331
332
		TEST TabsAndSpaces() {
			YAML::Node doc = YAML::Parse(ex5_12);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["quoted"].as<std::string>() == "Quoted\t");
			YAML_ASSERT(doc["block"].as<std::string>() ==
						"void main() {\n"
						"\tprintf(\"Hello, world!\\n\");\n"
						"}");
			return true;
		}
333
334
		
		// 5.13
Jesse Beder's avatar
Jesse Beder committed
335
336
337
338
339
		TEST EscapedCharacters() {
			YAML::Node doc = YAML::Parse(ex5_13);
			YAML_ASSERT(doc.as<std::string>() == "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");
			return true;
		}
340
341
		
		// 5.14
Jesse Beder's avatar
Jesse Beder committed
342
343
344
345
346
347
348
349
350
351
		TEST InvalidEscapedCharacters() {
			try {
				YAML::Parse(ex5_14);
			} catch(const YAML::ParserException& e) {
				YAML_ASSERT(e.msg == std::string(YAML::ErrorMsg::INVALID_ESCAPE) + "c");
				return true;
			}
			
			return false;
		}
352
353
		
		// 6.1
354
355
356
357
358
359
360
361
362
363
364
		TEST IndentationSpaces() {
			YAML::Node doc = YAML::Parse(ex6_1);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["Not indented"].size() == 2);
			YAML_ASSERT(doc["Not indented"]["By one space"].as<std::string>() == "By four\n  spaces\n");
			YAML_ASSERT(doc["Not indented"]["Flow style"].size() == 3);
			YAML_ASSERT(doc["Not indented"]["Flow style"][0].as<std::string>() == "By two");
			YAML_ASSERT(doc["Not indented"]["Flow style"][1].as<std::string>() == "Also by two");
			YAML_ASSERT(doc["Not indented"]["Flow style"][2].as<std::string>() == "Still by two");
			return true;
		}
365
366
		
		// 6.2
367
368
369
370
371
372
373
374
375
376
		TEST IndentationIndicators() {
			YAML::Node doc = YAML::Parse(ex6_2);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["a"].size() == 2);
			YAML_ASSERT(doc["a"][0].as<std::string>() == "b");
			YAML_ASSERT(doc["a"][1].size() == 2);
			YAML_ASSERT(doc["a"][1][0].as<std::string>() == "c");
			YAML_ASSERT(doc["a"][1][1].as<std::string>() == "d");
			return true;
		}
377
378
		
		// 6.3
379
380
381
382
383
384
385
386
387
388
		TEST SeparationSpaces() {
			YAML::Node doc = YAML::Parse(ex6_3);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 1);
			YAML_ASSERT(doc[0]["foo"].as<std::string>() == "bar");
			YAML_ASSERT(doc[1].size() == 2);
			YAML_ASSERT(doc[1][0].as<std::string>() == "baz");
			YAML_ASSERT(doc[1][1].as<std::string>() == "baz");
			return true;
		}
389
390
		
		// 6.4
391
392
393
394
395
396
397
398
		TEST LinePrefixes() {
			YAML::Node doc = YAML::Parse(ex6_4);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["plain"].as<std::string>() == "text lines");
			YAML_ASSERT(doc["quoted"].as<std::string>() == "text lines");
			YAML_ASSERT(doc["block"].as<std::string>() == "text\n \tlines\n");
			return true;
		}
399
400
		
		// 6.5
401
402
403
404
405
406
407
		TEST EmptyLines() {
			YAML::Node doc = YAML::Parse(ex6_5);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["Folding"].as<std::string>() == "Empty line\nas a line feed");
			YAML_ASSERT(doc["Chomping"].as<std::string>() == "Clipped empty lines\n");
			return true;
		}
408
409
		
		// 6.6
410
411
412
413
414
		TEST LineFolding() {
			YAML::Node doc = YAML::Parse(ex6_6);
			YAML_ASSERT(doc.as<std::string>() == "trimmed\n\n\nas space");
			return true;
		}
415
416
		
		// 6.7
417
418
419
420
421
		TEST BlockFolding() {
			YAML::Node doc = YAML::Parse(ex6_7);
			YAML_ASSERT(doc.as<std::string>() == "foo \n\n\t bar\n\nbaz\n");
			return true;
		}
422
423
		
		// 6.8
424
425
426
427
428
		TEST FlowFolding() {
			YAML::Node doc = YAML::Parse(ex6_8);
			YAML_ASSERT(doc.as<std::string>() == " foo\nbar\nbaz ");
			return true;
		}
429
430
		
		// 6.9
431
432
433
434
435
436
		TEST SeparatedComment() {
			YAML::Node doc = YAML::Parse(ex6_9);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["key"].as<std::string>() == "value");
			return true;
		}
437
438
		
		// 6.10
439
440
441
442
443
		TEST CommentLines() {
			YAML::Node doc = YAML::Parse(ex6_10);
			YAML_ASSERT(doc.Type() == YAML::NodeType::Null);
			return true;
		}
444
445
		
		// 6.11
446
447
448
449
450
451
		TEST MultiLineComments() {
			YAML::Node doc = YAML::Parse(ex6_11);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["key"].as<std::string>() == "value");
			return true;
		}
452
453
		
		// 6.12
454
455
456
457
458
459
460
461
462
463
464
465
466
		TEST SeparationSpacesII() {
			YAML::Node doc = YAML::Parse(ex6_12);
			
			std::map<std::string, std::string> sammy;
			sammy["first"] = "Sammy";
			sammy["last"] = "Sosa";
			
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc[sammy].size() == 2);
			YAML_ASSERT(doc[sammy]["hr"].as<int>() == 65);
			YAML_ASSERT(doc[sammy]["avg"].as<std::string>() == "0.278");
			return true;
		}
467
468
		
		// 6.13
469
470
471
472
473
		TEST ReservedDirectives() {
			YAML::Node doc = YAML::Parse(ex6_13);
			YAML_ASSERT(doc.as<std::string>() == "foo");
			return true;
		}
474
475
		
		// 6.14
476
477
478
479
480
		TEST YAMLDirective() {
			YAML::Node doc = YAML::Parse(ex6_14);
			YAML_ASSERT(doc.as<std::string>() == "foo");
			return true;
		}
481
482
		
		// 6.15
483
484
485
486
487
488
489
490
491
492
		TEST InvalidRepeatedYAMLDirective() {
			try {
				YAML::Parse(ex6_15);
			} catch(const YAML::ParserException& e) {
				YAML_ASSERT(e.msg == YAML::ErrorMsg::REPEATED_YAML_DIRECTIVE);
				return true;
			}
			
			return "  No exception was thrown";
		}
493
494
495
496
497
498
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
		
		// 6.16
		TEST TagDirective() { return "  not written yet"; }
		
		// 6.17
		TEST InvalidRepeatedTagDirective() { return "  not written yet"; }
		
		// 6.18
		TEST PrimaryTagHandle() { return "  not written yet"; }
		
		// 6.19
		TEST SecondaryTagHandle() { return "  not written yet"; }
		
		// 6.20
		TEST TagHandles() { return "  not written yet"; }
		
		// 6.21
		TEST LocalTagPrefix() { return "  not written yet"; }
		
		// 6.22
		TEST GlobalTagPrefix() { return "  not written yet"; }
		
		// 6.23
		TEST NodeProperties() { return "  not written yet"; }
		
		// 6.24
		TEST VerbatimTags() { return "  not written yet"; }
		
		// 6.25
		TEST InvalidVerbatimTags() { return "  not written yet"; }
		
		// 6.26
		TEST TagShorthands() { return "  not written yet"; }
		
		// 6.27
		TEST InvalidTagShorthands() { return "  not written yet"; }
		
		// 6.28
		TEST NonSpecificTags() { return "  not written yet"; }
		
		// 6.29
534
535
536
537
538
539
540
		TEST NodeAnchors() {
			YAML::Node doc = YAML::Parse(ex6_29);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["First occurrence"].as<std::string>() == "Value");
			YAML_ASSERT(doc["Second occurrence"].as<std::string>() == "Value");
			return true;
		}
541
542
		
		// 7.1
543
544
545
546
547
548
549
550
551
		TEST AliasNodes() {
			YAML::Node doc = YAML::Parse(ex7_1);
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc["First occurrence"].as<std::string>() == "Foo");
			YAML_ASSERT(doc["Second occurrence"].as<std::string>() == "Foo");
			YAML_ASSERT(doc["Override anchor"].as<std::string>() == "Bar");
			YAML_ASSERT(doc["Reuse anchor"].as<std::string>() == "Bar");
			return true;
		}
552
553
554
555
556
		
		// 7.2
		TEST EmptyNodes() { return "  not written yet"; }
		
		// 7.3
557
558
559
560
		TEST CompletelyEmptyNodes() {
			YAML::Node doc = YAML::Parse(ex7_3);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["foo"].Type() == YAML::NodeType::Null);
561
//			YAML_ASSERT(doc[YAML::as<.as<std::string>() == "bar");
562
563
564
			return "  null as a key not implemented";
			return true;
		}
565
566
		
		// 7.4
567
568
569
570
571
572
573
574
		TEST DoubleQuotedImplicitKeys() {
			YAML::Node doc = YAML::Parse(ex7_4);
			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"].as<std::string>() == "value");
			return true;
		}
575
576
		
		// 7.5
577
578
579
580
581
		TEST DoubleQuotedLineBreaks() {
			YAML::Node doc = YAML::Parse(ex7_5);
			YAML_ASSERT(doc.as<std::string>() == "folded to a space,\nto a line feed, or \t \tnon-content");
			return true;
		}
582
583
		
		// 7.6
584
585
586
587
588
		TEST DoubleQuotedLines() {
			YAML::Node doc = YAML::Parse(ex7_6);
			YAML_ASSERT(doc.as<std::string>() == " 1st non-empty\n2nd non-empty 3rd non-empty ");
			return true;
		}
589
590
		
		// 7.7
591
592
593
594
595
		TEST SingleQuotedCharacters() {
			YAML::Node doc = YAML::Parse(ex7_7);
			YAML_ASSERT(doc.as<std::string>() == "here's to \"quotes\"");
			return true;
		}
596
597
		
		// 7.8
598
599
600
601
602
603
604
605
		TEST SingleQuotedImplicitKeys() {
			YAML::Node doc = YAML::Parse(ex7_8);
			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"].as<std::string>() == "value");
			return true;
		}
606
607
		
		// 7.9
608
609
610
611
612
		TEST SingleQuotedLines() {
			YAML::Node doc = YAML::Parse(ex7_9);
			YAML_ASSERT(doc.as<std::string>() == " 1st non-empty\n2nd non-empty 3rd non-empty ");
			return true;
		}
613
614
		
		// 7.10
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
		TEST PlainCharacters() {
			YAML::Node doc = YAML::Parse(ex7_10);
			YAML_ASSERT(doc.size() == 6);
			YAML_ASSERT(doc[0].as<std::string>() == "::vector");
			YAML_ASSERT(doc[1].as<std::string>() == ": - ()");
			YAML_ASSERT(doc[2].as<std::string>() == "Up, up, and away!");
			YAML_ASSERT(doc[3].as<int>() == -123);
			YAML_ASSERT(doc[4].as<std::string>() == "http://example.com/foo#bar");
			YAML_ASSERT(doc[5].size() == 5);
			YAML_ASSERT(doc[5][0].as<std::string>() == "::vector");
			YAML_ASSERT(doc[5][1].as<std::string>() == ": - ()");
			YAML_ASSERT(doc[5][2].as<std::string>() == "Up, up, and away!");
			YAML_ASSERT(doc[5][3].as<int>() == -123);
			YAML_ASSERT(doc[5][4].as<std::string>() == "http://example.com/foo#bar");
			return true;
		}
631
632
		
		// 7.11
633
634
635
636
637
638
639
640
		TEST PlainImplicitKeys() {
			YAML::Node doc = YAML::Parse(ex7_11);
			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"].as<std::string>() == "value");
			return true;
		}
641
642
		
		// 7.12
643
644
645
646
647
		TEST PlainLines() {
			YAML::Node doc = YAML::Parse(ex7_12);
			YAML_ASSERT(doc.as<std::string>() == "1st non-empty\n2nd non-empty 3rd non-empty");
			return true;
		}
648
649
		
		// 7.13
650
651
652
653
654
655
656
657
658
659
660
		TEST FlowSequence() {
			YAML::Node doc = YAML::Parse(ex7_13);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 2);
			YAML_ASSERT(doc[0][0].as<std::string>() == "one");
			YAML_ASSERT(doc[0][1].as<std::string>() == "two");
			YAML_ASSERT(doc[1].size() == 2);
			YAML_ASSERT(doc[1][0].as<std::string>() == "three");
			YAML_ASSERT(doc[1][1].as<std::string>() == "four");
			return true;
		}
661
662
		
		// 7.14
663
664
665
666
667
668
669
670
671
672
673
674
		TEST FlowSequenceEntries() {
			YAML::Node doc = YAML::Parse(ex7_14);
			YAML_ASSERT(doc.size() == 5);
			YAML_ASSERT(doc[0].as<std::string>() == "double quoted");
			YAML_ASSERT(doc[1].as<std::string>() == "single quoted");
			YAML_ASSERT(doc[2].as<std::string>() == "plain text");
			YAML_ASSERT(doc[3].size() == 1);
			YAML_ASSERT(doc[3][0].as<std::string>() == "nested");
			YAML_ASSERT(doc[4].size() == 1);
			YAML_ASSERT(doc[4]["single"].as<std::string>() == "pair");
			return true;
		}
675
676
		
		// 7.15
677
678
679
680
681
682
683
684
685
686
687
		TEST FlowMappings() {
			YAML::Node doc = YAML::Parse(ex7_15);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 2);
			YAML_ASSERT(doc[0]["one"].as<std::string>() == "two");
			YAML_ASSERT(doc[0]["three"].as<std::string>() == "four");
			YAML_ASSERT(doc[1].size() == 2);
			YAML_ASSERT(doc[1]["five"].as<std::string>() == "six");
			YAML_ASSERT(doc[1]["seven"].as<std::string>() == "eight");
			return true;
		}
688
689
		
		// 7.16
690
691
692
693
694
		TEST FlowMappingEntries() {
			YAML::Node doc = YAML::Parse(ex7_16);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["explicit"].as<std::string>() == "entry");
			YAML_ASSERT(doc["implicit"].as<std::string>() == "entry");
695
//			YAML_ASSERT(doc[YAML::as<.Type() == YAML::NodeType::Null);
696
697
698
			return "  null as a key not implemented";
			return true;
		}
699
700
		
		// 7.17
701
702
703
704
705
706
		TEST FlowMappingSeparateValues() {
			YAML::Node doc = YAML::Parse(ex7_17);
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc["unquoted"].as<std::string>() == "separate");
			YAML_ASSERT(doc["http://foo.com"].Type() == YAML::NodeType::Null);
			YAML_ASSERT(doc["omitted value"].Type() == YAML::NodeType::Null);
707
//			YAML_ASSERT(doc[YAML::as<.as<std::string>() == "omitted key");
708
709
710
			return "  null as a key not implemented";
			return true;
		}
711
712
		
		// 7.18
713
714
715
716
717
718
719
720
		TEST FlowMappingAdjacentValues() {
			YAML::Node doc = YAML::Parse(ex7_18);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["adjacent"].as<std::string>() == "value");
			YAML_ASSERT(doc["readable"].as<std::string>() == "value");
			YAML_ASSERT(doc["empty"].Type() == YAML::NodeType::Null);
			return true;
		}
721
722
		
		// 7.19
723
724
725
726
727
728
729
		TEST SinglePairFlowMappings() {
			YAML::Node doc = YAML::Parse(ex7_19);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc[0].size() == 1);
			YAML_ASSERT(doc[0]["foo"].as<std::string>() == "bar");
			return true;
		}
730
731
		
		// 7.20
732
733
734
735
736
737
738
		TEST SinglePairExplicitEntry() {
			YAML::Node doc = YAML::Parse(ex7_20);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc[0].size() == 1);
			YAML_ASSERT(doc[0]["foo bar"].as<std::string>() == "baz");
			return true;
		}
739
740
		
		// 7.21
741
742
743
744
745
746
747
748
		TEST SinglePairImplicitEntries() {
			YAML::Node doc = YAML::Parse(ex7_21);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].size() == 1);
			YAML_ASSERT(doc[0][0].size() == 1);
			YAML_ASSERT(doc[0][0]["YAML"].as<std::string>() == "separate");
			YAML_ASSERT(doc[1].size() == 1);
			YAML_ASSERT(doc[1][0].size() == 1);
749
//			YAML_ASSERT(doc[1][0][YAML::as<.as<std::string>() == "empty key entry");
750
751
752
753
754
755
756
757
758
			return "  null as a key not implemented";
			YAML_ASSERT(doc[2].size() == 1);
			YAML_ASSERT(doc[2][0].size() == 1);
			
			std::map<std::string, std::string> key;
			key["JSON"] = "like";
			YAML_ASSERT(doc[2][0][key].as<std::string>() == "adjacent");
			return true;
		}
759
760
		
		// 7.22
761
762
763
764
765
766
767
768
769
770
771
		TEST InvalidImplicitKeys() {
			try {
				YAML::Parse(ex7_22);
			} catch(const YAML::Exception& e) {
				if(e.msg == YAML::ErrorMsg::END_OF_SEQ_FLOW)
					return true;
				
				throw;
			}
			return "  no exception thrown";
		}
772
773
		
		// 7.23
774
775
776
777
778
779
780
781
782
783
784
785
786
		TEST FlowContent() {
			YAML::Node doc = YAML::Parse(ex7_23);
			YAML_ASSERT(doc.size() == 5);
			YAML_ASSERT(doc[0].size() == 2);
			YAML_ASSERT(doc[0][0].as<std::string>() == "a");
			YAML_ASSERT(doc[0][1].as<std::string>() == "b");
			YAML_ASSERT(doc[1].size() == 1);
			YAML_ASSERT(doc[1]["a"].as<std::string>() == "b");
			YAML_ASSERT(doc[2].as<std::string>() == "a");
			YAML_ASSERT(doc[3].as<char>() == 'b');
			YAML_ASSERT(doc[4].as<std::string>() == "c");
			return true;
		}
787
788
789
		
		// 7.24
		TEST FlowNodes() { return "  not written yet"; }
790

791
		// 8.1
792
793
794
795
796
797
798
799
800
		TEST BlockScalarHeader() {
			YAML::Node doc = YAML::Parse(ex8_1);
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc[0].as<std::string>() == "literal\n");
			YAML_ASSERT(doc[1].as<std::string>() == " folded\n");
			YAML_ASSERT(doc[2].as<std::string>() == "keep\n\n");
			YAML_ASSERT(doc[3].as<std::string>() == " strip");
			return true;
		}
801
802
		
		// 8.2
803
804
805
806
807
808
809
810
811
		TEST BlockIndentationHeader() {
			YAML::Node doc = YAML::Parse(ex8_2);
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc[0].as<std::string>() == "detected\n");
			YAML_ASSERT(doc[1].as<std::string>() == "\n\n# detected\n");
			YAML_ASSERT(doc[2].as<std::string>() == " explicit\n");
			YAML_ASSERT(doc[3].as<std::string>() == "\t\ndetected\n");
			return true;
		}
812
813
		
		// 8.3
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
		TEST InvalidBlockScalarIndentationIndicators() {
			{
				bool threw = false;
				try {
					YAML::Parse(ex8_3a);
				} catch(const YAML::Exception& e) {
					if(e.msg != YAML::ErrorMsg::END_OF_SEQ)
						throw;
					
					threw = true;
				}
				
				if(!threw)
					return "  no exception thrown for less indented auto-detecting indentation for a literal block scalar";
			}
			
			{
				bool threw = false;
				try {
					YAML::Parse(ex8_3b);
				} catch(const YAML::Exception& e) {
					if(e.msg != YAML::ErrorMsg::END_OF_SEQ)
						throw;
					
					threw = true;
				}
				
				if(!threw)
					return "  no exception thrown for less indented auto-detecting indentation for a folded block scalar";
			}
			
			{
				bool threw = false;
				try {
					YAML::Parse(ex8_3c);
				} catch(const YAML::Exception& e) {
					if(e.msg != YAML::ErrorMsg::END_OF_SEQ)
						throw;
					
					threw = true;
				}
				
				if(!threw)
					return "  no exception thrown for less indented explicit indentation for a literal block scalar";
			}
			
			return true;
		}
862
863
		
		// 8.4
864
865
866
867
868
869
870
871
		TEST ChompingFinalLineBreak() {
			YAML::Node doc = YAML::Parse(ex8_4);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["strip"].as<std::string>() == "text");
			YAML_ASSERT(doc["clip"].as<std::string>() == "text\n");
			YAML_ASSERT(doc["keep"].as<std::string>() == "text\n");
			return true;
		}
872
873
		
		// 8.5
874
875
876
877
878
879
880
881
		TEST ChompingTrailingLines() {
			YAML::Node doc = YAML::Parse(ex8_5);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["strip"].as<std::string>() == "# text");
			YAML_ASSERT(doc["clip"].as<std::string>() == "# text\n");
			YAML_ASSERT(doc["keep"].as<std::string>() == "# text\n"); // Note: I believe this is a bug in the YAML spec - it should be "# text\n\n"
			return true;
		}
882
883
		
		// 8.6
884
885
886
887
888
889
890
891
		TEST EmptyScalarChomping() {
			YAML::Node doc = YAML::Parse(ex8_6);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["strip"].as<std::string>() == "");
			YAML_ASSERT(doc["clip"].as<std::string>() == "");
			YAML_ASSERT(doc["keep"].as<std::string>() == "\n");
			return true;
		}
892
893
		
		// 8.7
894
895
896
897
898
		TEST LiteralScalar() {
			YAML::Node doc = YAML::Parse(ex8_7);
			YAML_ASSERT(doc.as<std::string>() == "literal\n\ttext\n");
			return true;
		}
899
900
		
		// 8.8
901
902
903
904
905
		TEST LiteralContent() {
			YAML::Node doc = YAML::Parse(ex8_8);
			YAML_ASSERT(doc.as<std::string>() == "\n\nliteral\n \n\ntext\n");
			return true;
		}
906
907
		
		// 8.9
908
909
910
911
912
		TEST FoldedScalar() {
			YAML::Node doc = YAML::Parse(ex8_9);
			YAML_ASSERT(doc.as<std::string>() == "folded text\n");
			return true;
		}
913
914
		
		// 8.10
915
916
917
918
919
		TEST FoldedLines() {
			YAML::Node doc = YAML::Parse(ex8_10);
			YAML_ASSERT(doc.as<std::string>() == "\nfolded line\nnext line\n  * bullet\n\n  * list\n  * lines\n\nlast line\n");
			return true;
		}
920
921
		
		// 8.11
922
923
924
925
926
		TEST MoreIndentedLines() {
			YAML::Node doc = YAML::Parse(ex8_11);
			YAML_ASSERT(doc.as<std::string>() == "\nfolded line\nnext line\n  * bullet\n\n  * list\n  * lines\n\nlast line\n");
			return true;
		}
927
928
		
		// 8.12
929
930
931
932
933
		TEST EmptySeparationLines() {
			YAML::Node doc = YAML::Parse(ex8_12);
			YAML_ASSERT(doc.as<std::string>() == "\nfolded line\nnext line\n  * bullet\n\n  * list\n  * lines\n\nlast line\n");
			return true;
		}
934
935
		
		// 8.13
936
937
938
939
940
		TEST FinalEmptyLines() {
			YAML::Node doc = YAML::Parse(ex8_13);
			YAML_ASSERT(doc.as<std::string>() == "\nfolded line\nnext line\n  * bullet\n\n  * list\n  * lines\n\nlast line\n");
			return true;
		}
941
942
		
		// 8.14
943
944
945
946
947
948
949
950
951
		TEST BlockSequence() {
			YAML::Node doc = YAML::Parse(ex8_14);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["block sequence"].size() == 2);
			YAML_ASSERT(doc["block sequence"][0].as<std::string>() == "one");
			YAML_ASSERT(doc["block sequence"][1].size() == 1);
			YAML_ASSERT(doc["block sequence"][1]["two"].as<std::string>() == "three");
			return true;
		}
952
953
		
		// 8.15
954
955
956
957
958
959
960
961
962
963
964
965
		TEST BlockSequenceEntryTypes() {
			YAML::Node doc = YAML::Parse(ex8_15);
			YAML_ASSERT(doc.size() == 4);
			YAML_ASSERT(doc[0].Type() == YAML::NodeType::Null);
			YAML_ASSERT(doc[1].as<std::string>() == "block node\n");
			YAML_ASSERT(doc[2].size() == 2);
			YAML_ASSERT(doc[2][0].as<std::string>() == "one");
			YAML_ASSERT(doc[2][1].as<std::string>() == "two");
			YAML_ASSERT(doc[3].size() == 1);
			YAML_ASSERT(doc[3]["one"].as<std::string>() == "two");
			return true;
		}
966
967
		
		// 8.16
968
969
970
971
972
973
974
		TEST BlockMappings() {
			YAML::Node doc = YAML::Parse(ex8_16);
			YAML_ASSERT(doc.size() == 1);
			YAML_ASSERT(doc["block mapping"].size() == 1);
			YAML_ASSERT(doc["block mapping"]["key"].as<std::string>() == "value");
			return true;
		}
975
976
		
		// 8.17
977
978
979
980
981
982
983
984
985
		TEST ExplicitBlockMappingEntries() {
			YAML::Node doc = YAML::Parse(ex8_17);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["explicit key"].Type() == YAML::NodeType::Null);
			YAML_ASSERT(doc["block key\n"].size() == 2);
			YAML_ASSERT(doc["block key\n"][0].as<std::string>() == "one");
			YAML_ASSERT(doc["block key\n"][1].as<std::string>() == "two");
			return true;
		}
986
987
		
		// 8.18
988
989
990
991
992
993
994
995
996
997
		TEST ImplicitBlockMappingEntries() {
			YAML::Node doc = YAML::Parse(ex8_18);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc["plain key"].as<std::string>() == "in-line value");
//			YAML_ASSERT(doc[YAML::Null].Type() == YAML::NodeType::Null);
			return "  null not implemented as key";
			YAML_ASSERT(doc["quoted key"].size() == 1);
			YAML_ASSERT(doc["quoted key"][0].as<std::string>() == "entry");
			return true;
		}
998
999
		
		// 8.19
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
		TEST CompactBlockMappings() {
			YAML::Node doc = YAML::Parse(ex8_19);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc[0].size() == 1);
			YAML_ASSERT(doc[0]["sun"].as<std::string>() == "yellow");
			YAML_ASSERT(doc[1].size() == 1);
			std::map<std::string, std::string> key;
			key["earth"] = "blue";
			YAML_ASSERT(doc[1][key].size() == 1);
			YAML_ASSERT(doc[1][key]["moon"].as<std::string>() == "white");
			return true;
		}
1012
1013
		
		// 8.20
1014
1015
1016
1017
1018
1019
1020
1021
1022
		TEST BlockNodeTypes() {
			YAML::Node doc = YAML::Parse(ex8_20);
			YAML_ASSERT(doc.size() == 3);
			YAML_ASSERT(doc[0].as<std::string>() == "flow in block");
			YAML_ASSERT(doc[1].as<std::string>() == "Block scalar\n");
			YAML_ASSERT(doc[2].size() == 1);
			YAML_ASSERT(doc[2]["foo"].as<std::string>() == "bar");
			return true;
		}
1023
1024
1025
1026
1027
		
		// 8.21
		TEST BlockScalarNodes() { return "  not written yet"; }
		
		// 8.22
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
		TEST BlockCollectionNodes() {
			YAML::Node doc = YAML::Parse(ex8_22);
			YAML_ASSERT(doc.size() == 2);
			YAML_ASSERT(doc["sequence"].size() == 2);
			YAML_ASSERT(doc["sequence"][0].as<std::string>() == "entry");
			YAML_ASSERT(doc["sequence"][1].size() == 1);
			YAML_ASSERT(doc["sequence"][1][0].as<std::string>() == "nested");
			YAML_ASSERT(doc["mapping"].size() == 1);
			YAML_ASSERT(doc["mapping"]["foo"].as<std::string>() == "bar");
			return true;
		}
1039
1040
	}
}