yaparc 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_uri.rb DELETED
@@ -1,752 +0,0 @@
1
- require 'lib/yaparc.rb'
2
- require 'test/unit'
3
-
4
- module URIParser
5
-
6
-
7
- class URIReference # = [ absoluteURI | relativeURI ] [ "#" fragment ]
8
- include Yaparc::Parsable
9
- def initialize
10
- @parser = lambda do |input|
11
- Yaparc::Seq.new(
12
- Yaparc::ZeroOne.new(Yaparc::Alt.new(AbsoluteURI.new,
13
- RelativeURI.new,'')),
14
- Yaparc::ZeroOne.new(
15
- Yaparc::Seq.new(Yaparc::Symbol.new('#'),Fragment.new),''))
16
- end
17
- end
18
- end
19
-
20
- class AbsoluteURI # = scheme ":" ( hier_part | opaque_part )
21
- include Yaparc::Parsable
22
- def initialize
23
- @parser = lambda do |input|
24
- Yaparc::Seq.new(Scheme.new,
25
- Yaparc::Symbol.new(':'),
26
- Yaparc::Alt.new(HierPart.new,
27
- OpaquePart.new))
28
- end
29
- end
30
- end
31
-
32
- class RelativeURI
33
- include Yaparc::Parsable
34
- def initialize
35
- @parser = lambda do |input|
36
- Yaparc::Seq.new(Yaparc::Alt.new(NetPath.new,
37
- AbsPath.new,
38
- RelPath.new),
39
- Yaparc::ZeroOne.new(Yaparc::Seq.new(Yaparc::Symbol.new('?'),Query.new),''))
40
- end
41
- end
42
- end
43
-
44
- class HierPart # = ( net_path | abs_path ) [ "?" query ]
45
- include Yaparc::Parsable
46
- def initialize
47
- @parser = lambda do |input|
48
- Yaparc::Seq.new(Yaparc::Alt.new(NetPath.new,
49
- AbsPath.new),
50
- Yaparc::ZeroOne.new(Yaparc::Seq.new(Yaparc::Symbol.new('?'),Query.new),''))
51
- end
52
- end
53
- end
54
-
55
- class Path
56
- include Yaparc::Parsable
57
- def initialize
58
- @parser = lambda do |input|
59
- Yaparc::ZeroOne.new(Yaparc::Alt.new(AbsPath.new,
60
- OpaquePart.new),'')
61
- end
62
- end
63
- end
64
-
65
- class OpaquePart # = uric_no_slash *uric
66
- include Yaparc::Parsable
67
- def initialize
68
- @parser = lambda do |input|
69
- Yaparc::Seq.new(UricNoSlash.new,
70
- Yaparc::Many.new(Uric.new,''))
71
-
72
- end
73
- end
74
- end
75
-
76
- class UricNoSlash # = unreserved | escaped | ";" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","
77
- include Yaparc::Parsable
78
- def initialize
79
- @parser = lambda do |input|
80
- Yaparc::Alt.new(Unreserved.new,
81
- Escaped.new,
82
- Yaparc::Regex.new(/[;?:@&=+$,]/))
83
- end
84
- end
85
- end
86
-
87
- class NetPath # = "//" authority [ abs_path ]
88
- include Yaparc::Parsable
89
- def initialize
90
- @parser = lambda do |input|
91
- Yaparc::Seq.new(Yaparc::Symbol.new('//'),
92
- Authority.new,
93
- Yaparc::ZeroOne.new(AbsPath.new,''))
94
- end
95
- end
96
- end
97
-
98
- class RelPath
99
- include Yaparc::Parsable
100
- def initialize
101
- @parser = lambda do |input|
102
- Yaparc::Seq.new(RelSegment.new,
103
- Yaparc::ZeroOne.new(AbsPath.new,''))
104
- end
105
- end
106
- end
107
-
108
- class AbsPath
109
- include Yaparc::Parsable
110
- def initialize
111
- @parser = lambda do |input|
112
- Yaparc::Seq.new(Yaparc::Symbol.new('/'),
113
- PathSegments.new)
114
- end
115
- end
116
- end
117
-
118
- class RelSegment
119
- include Yaparc::Parsable
120
- def initialize
121
- @parser = lambda do |input|
122
- Yaparc::ZeroOne.new(Yaparc::Alt.new(Unreserved.new,
123
- Escaped.new,
124
- Yaparc::Regex.new(/[;@&=+$,]/)),'')
125
- end
126
- end
127
- end
128
-
129
- class Scheme # = alpha *( alpha | digit | "+" | "-" | "." )
130
- include Yaparc::Parsable
131
- def initialize
132
- @parser = lambda do |input|
133
- Yaparc::Seq.new(Alpha.new,
134
- Yaparc::Many.new(
135
- Yaparc::Alt.new(
136
- Alpha.new,
137
- Digit.new,
138
- Yaparc::Regex.new(/[+-.]/)),''))
139
- end
140
- end
141
- end
142
-
143
- class Authority
144
- include Yaparc::Parsable
145
- def initialize
146
- @parser = lambda do |input|
147
- Yaparc::Alt.new(Server.new,
148
- RegName.new)
149
- end
150
- end
151
- end
152
-
153
- class RegName # 1*( unreserved | escaped | "$" | "," | ";" | ":" | "@" | "&" | "=" | "+" )
154
- include Yaparc::Parsable
155
- def initialize
156
- @parser = lambda do |input|
157
- Yaparc::ManyOne.new(Yaparc::Alt.new(
158
- Unreserved.new,
159
- Escaped.new,
160
- Yaparc::Regex.new(/[$,;:@&=+]/)),'')
161
- end
162
- end
163
- end
164
-
165
- class Server # = [ [ userinfo "@" ] hostport ]
166
- include Yaparc::Parsable
167
- def initialize
168
- @parser = lambda do |input|
169
- Yaparc::Alt.new(
170
- Yaparc::Seq.new(UserInfo.new, Yaparc::Symbol.new('@'),HostPort.new),
171
- HostPort.new,
172
- Yaparc::Succeed.new(''))
173
- # Yaparc::ZeroOne.new(
174
- # Yaparc::Seq.new(
175
- # Yaparc::ZeroOne.new(
176
- # Yaparc::Seq.new(UserInfo.new, Yaparc::Symbol.new('@')),''),
177
- # HostPort.new,''),'')
178
- end
179
- end
180
- end
181
-
182
- class UserInfo
183
- include Yaparc::Parsable
184
- def initialize
185
- @parser = lambda do |input|
186
- Yaparc::Many.new(Yaparc::Alt.new(Unreserved.new,
187
- Escaped.new,
188
- Yaparc::Regex.new(/[;:&=+$,]/)),'')
189
- end
190
- end
191
- end
192
-
193
- class HostPort
194
- include Yaparc::Parsable
195
- def initialize
196
- @parser = lambda do |input|
197
- Yaparc::Seq.new(Host.new,
198
- Yaparc::ZeroOne.new(
199
- Yaparc::Seq.new(Yaparc::Symbol.new(':'),Port.new),''))
200
- end
201
- end
202
- end
203
-
204
-
205
- class Host
206
- include Yaparc::Parsable
207
- def initialize
208
- @parser = lambda do |input|
209
- Yaparc::Alt.new(HostName.new,
210
- IPv4Address.new)
211
- end
212
- end
213
- end
214
-
215
- class HostName
216
- include Yaparc::Parsable
217
- def initialize
218
- @parser = lambda do |input|
219
- Yaparc::Seq.new(Yaparc::Many.new(Yaparc::Seq.new(DomainLabel.new,Yaparc::Symbol.new('.')),''),
220
- TopLabel.new,
221
- Yaparc::ZeroOne.new(Yaparc::Symbol.new('.'),''))
222
- end
223
- end
224
- end
225
-
226
- class DomainLabel
227
- include Yaparc::Parsable
228
- def initialize
229
- @parser = lambda do |input|
230
- Yaparc::Alt.new(AlphaNum.new,
231
- Yaparc::Seq.new(AlphaNum.new,
232
- Yaparc::Many.new(
233
- Yaparc::Alt.new(AlphaNum.new,Yaparc::Symbol.new('-')),''),
234
- AlphaNum.new))
235
- end
236
- end
237
- end
238
-
239
- class TopLabel
240
- include Yaparc::Parsable
241
- def initialize
242
- @parser = lambda do |input|
243
- Yaparc::Alt.new(Alpha.new,
244
- Yaparc::Seq.new(Alpha.new,
245
- Yaparc::Many.new(
246
- Yaparc::Alt.new(Alpha.new,Yaparc::Symbol.new('-')),''),
247
- AlphaNum.new))
248
- end
249
- end
250
- end
251
-
252
-
253
- class IPv4Address
254
- include Yaparc::Parsable
255
- def initialize
256
- @parser = lambda do |input|
257
- Yaparc::Regex.new(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)
258
- # Yaparc::Seq.new(Yaparc::ManyOne.new(Digit.new,""),
259
- # Yaparc::Symbol.new('.'),
260
- # Yaparc::ManyOne.new(Digit.new,""),
261
- # Yaparc::Symbol.new('.'),
262
- # Yaparc::ManyOne.new(Digit.new,""),
263
- # Yaparc::Symbol.new('.'),
264
- # Yaparc::ManyOne.new(Digit.new,""))
265
- end
266
- end
267
- end
268
-
269
- class Port
270
- include Yaparc::Parsable
271
- def initialize
272
- @parser = lambda do |input|
273
- Yaparc::Many.new(Digit.new,'')
274
- end
275
- end
276
- end
277
-
278
- class PathSegments
279
- include Yaparc::Parsable
280
- def initialize
281
- @parser = lambda do |input|
282
- Yaparc::Seq.new(Segment.new,
283
- Yaparc::Many.new(
284
- Yaparc::Seq.new(Yaparc::Symbol.new('/'),
285
- Segment.new),''))
286
- end
287
- end
288
- end
289
-
290
- class Segment
291
- include Yaparc::Parsable
292
- def initialize
293
- @parser = lambda do |input|
294
- Yaparc::Seq.new(Yaparc::Many.new(Pchar.new,''),
295
- Yaparc::Many.new(
296
- Yaparc::Seq.new(Yaparc::Symbol.new(';'),
297
- Param.new),'')
298
- )
299
- end
300
- end
301
- end
302
-
303
- class Param
304
- include Yaparc::Parsable
305
- def initialize
306
- @parser = lambda do |input|
307
- Yaparc::Many.new(Pchar.new,'')
308
- end
309
- end
310
- end
311
-
312
- class Pchar
313
- include Yaparc::Parsable
314
- def initialize
315
- @parser = lambda do |input|
316
- Yaparc::Alt.new(Unreserved.new,Escaped.new,::Yaparc::Regex.new(/[:@&=+$,]/))
317
- end
318
- end
319
- end
320
-
321
- class Query
322
- include Yaparc::Parsable
323
- def initialize
324
- @parser = lambda do |input|
325
- Yaparc::Many.new(Uric.new,'')
326
- end
327
- end
328
- end
329
-
330
- class Fragment
331
- include Yaparc::Parsable
332
- def initialize
333
- @parser = lambda do |input|
334
- Yaparc::Many.new(Uric.new,'')
335
- end
336
- end
337
- end
338
-
339
- class Uric
340
- include Yaparc::Parsable
341
- def initialize
342
- @parser = lambda do |input|
343
- Yaparc::Alt.new(Reserved.new,Unreserved.new,Escaped.new)
344
- end
345
- end
346
- end
347
-
348
- class Reserved
349
- include Yaparc::Parsable
350
- def initialize
351
- @parser = lambda do |input|
352
- ::Yaparc::Regex.new(/[;\/?\:@&=+$,]/)
353
- end
354
- end
355
- end
356
-
357
- class Unreserved
358
- include Yaparc::Parsable
359
- def initialize
360
- @parser = lambda do |input|
361
- Yaparc::Alt.new(AlphaNum.new, Mark.new)
362
- end
363
- end
364
- end
365
-
366
- class Mark
367
- include Yaparc::Parsable
368
- def initialize
369
- @parser = lambda do |input|
370
- ::Yaparc::Regex.new(/[-_.!~*'()]/)
371
- end
372
- end
373
- end
374
-
375
- class Escaped
376
- include Yaparc::Parsable
377
- def initialize
378
- @parser = lambda do |input|
379
- ::Yaparc::Seq.new(::Yaparc::Symbol.new('%'),
380
- Hex.new,
381
- Hex.new)
382
- end
383
- end
384
- end
385
-
386
- class Hex
387
- include Yaparc::Parsable
388
- def initialize
389
- @parser = lambda do |input|
390
- ::Yaparc::Regex.new(/[0-9A-Fa-f]/)
391
- end
392
- end
393
- end
394
-
395
- class AlphaNum
396
- include Yaparc::Parsable
397
- def initialize
398
- @parser = lambda do |input|
399
- Yaparc::Alt.new(Alpha.new, Digit.new)
400
- end
401
- end
402
- end
403
-
404
- class Alpha
405
- include Yaparc::Parsable
406
- def initialize
407
- @parser = lambda do |input|
408
- Yaparc::Alt.new(LowAlpha.new, UpAlpha.new)
409
- end
410
- end
411
- end
412
-
413
- class LowAlpha
414
- include Yaparc::Parsable
415
- def initialize
416
- @parser = lambda do |input|
417
- ::Yaparc::Regex.new(/[a-z]/)
418
- end
419
- end
420
- end
421
-
422
- class UpAlpha
423
- include Yaparc::Parsable
424
- def initialize
425
- @parser = lambda do |input|
426
- ::Yaparc::Regex.new(/[A-Z]/)
427
- end
428
- end
429
- end
430
-
431
- class Digit
432
- include Yaparc::Parsable
433
- def initialize
434
- @parser = lambda do |input|
435
- ::Yaparc::Regex.new(/[0-9]/)
436
- end
437
- end
438
- end
439
- end
440
-
441
- class UriTest < Test::Unit::TestCase
442
- include ::Yaparc
443
-
444
-
445
- def test_uri_reference
446
- uri_reference = URIParser::URIReference.new
447
- assert_instance_of Result::OK, uri_reference.parse("http://localhost.localdomain:3000/pchar;param")
448
- assert_instance_of Result::OK, uri_reference.parse("ftp://localhost.localdomain/pchar;param/pchar;param")
449
- assert_instance_of Result::OK, uri_reference.parse("http://localhost.localdomain:3000/pchar;param?query")
450
- assert_instance_of Result::OK, uri_reference.parse("ftp://localhost.localdomain/pchar;param/pchar;param?query")
451
-
452
- end
453
-
454
- def test_absolute_uri # = scheme ":" ( hier_part | opaque_part )
455
- absolute_uri = URIParser::AbsoluteURI.new
456
- # assert_instance_of Result::OK, URIParser::HierPart.new.parse("//localhost.localdomain:3000/pchar;param")
457
-
458
- # assert_instance_of Result::OK, absolute_uri.parse("http://localhost.localdomain:3000/pchar;param")
459
-
460
- # assert_instance_of Result::OK, absolute_uri.parse("ftp://localhost.localdomain/pchar;param/pchar;param")
461
- # assert_instance_of Result::OK, absolute_uri.parse("http://localhost.localdomain:3000/pchar;param?query")
462
- # assert_instance_of Result::OK, absolute_uri.parse("ftp://localhost.localdomain/pchar;param/pchar;param?query")
463
- end
464
-
465
- def test_relative_uri # ( net_path | abs_path | rel_path ) [ "?" query ]
466
- relative_uri = URIParser::RelativeURI.new
467
- assert_instance_of Result::OK, relative_uri.parse("//localhost.localdomain:3000/pchar;param")
468
- assert_instance_of Result::OK, relative_uri.parse("//localhost.localdomain/pchar;param/pchar;param")
469
- assert_instance_of Result::OK, relative_uri.parse("//localhost.localdomain:3000/pchar;param?query")
470
- assert_instance_of Result::OK, relative_uri.parse("//localhost.localdomain/pchar;param/pchar;param?query")
471
- end
472
-
473
- def test_hier_part # ( net_path | abs_path ) [ "?" query ]
474
- hier_part = URIParser::HierPart.new
475
- assert_instance_of Result::OK, hier_part.parse("//localhost.localdomain:3000/pchar;param")
476
- assert_instance_of Result::OK, hier_part.parse("//localhost.localdomain/pchar;param/pchar;param")
477
- assert_instance_of Result::OK, hier_part.parse("//localhost.localdomain:3000/pchar;param?query")
478
- assert_instance_of Result::OK, hier_part.parse("//localhost.localdomain/pchar;param/pchar;param?query")
479
- end
480
-
481
- def test_path
482
- path = URIParser::Path.new
483
- end
484
-
485
- def test_opaque_part
486
- opaque_part = URIParser::OpaquePart.new
487
- end
488
-
489
- def test_uric_no_slash
490
- uric_no_slash = URIParser::UricNoSlash.new
491
- end
492
-
493
-
494
- def test_net_path
495
- net_path = URIParser::NetPath.new
496
- assert_instance_of Result::OK, net_path.parse("//localhost.localdomain:3000/pchar;param")
497
- assert_instance_of Result::OK, net_path.parse("//localhost.localdomain/pchar;param/pchar;param")
498
- end
499
-
500
- def test_rel_path
501
- rel_path = URIParser::RelPath.new
502
- assert_instance_of Result::OK, rel_path.parse("pchar;param")
503
- assert_instance_of Result::OK, rel_path.parse("pchar;param/pchar;param")
504
- end
505
-
506
- def test_abs_path
507
- abs_path = URIParser::AbsPath.new
508
- assert_instance_of Result::OK, abs_path.parse("/pchar;param")
509
- assert_instance_of Result::OK, abs_path.parse("/pchar;param/pchar;param")
510
- end
511
-
512
- def test_rel_segment
513
- rel_segment = URIParser::RelSegment.new
514
- assert_instance_of Result::OK, rel_segment.parse("_")
515
- assert_instance_of Result::OK, rel_segment.parse("'")
516
- assert_instance_of Result::OK, rel_segment.parse("(")
517
- assert_instance_of Result::OK, rel_segment.parse("z")
518
- assert_instance_of Result::OK, rel_segment.parse(";")
519
- end
520
-
521
- def test_scheme
522
- scheme = URIParser::Scheme.new
523
- assert_instance_of Result::OK, scheme.parse("http")
524
- assert_instance_of Result::OK, scheme.parse("ftp")
525
- end
526
-
527
- def test_authority
528
- authority = URIParser::Authority.new
529
- assert_instance_of Result::OK, authority.parse("a")
530
- assert_instance_of Result::OK, authority.parse("localhost")
531
- assert_instance_of Result::OK, authority.parse("localhost.localdomain")
532
- assert_instance_of Result::OK, authority.parse("192.168.0.2:8080")
533
- assert_instance_of Result::OK, authority.parse("localhost.localdomain:3000")
534
- assert_instance_of Result::OK, authority.parse("192.168.0.2")
535
- assert_instance_of Result::OK, authority.parse("emile@localhost.localdomain:3000")
536
- assert_instance_of Result::OK, authority.parse("emile@192.168.0.2")
537
- assert_instance_of Result::OK, authority.parse("192")
538
- assert_instance_of Result::OK, authority.parse("_")
539
- assert_instance_of Result::OK, authority.parse("'")
540
- assert_instance_of Result::OK, authority.parse("(")
541
- assert_instance_of Result::OK, authority.parse("z")
542
- assert_instance_of Result::OK, authority.parse(";")
543
- end
544
-
545
- def test_reg_name
546
- reg_name = URIParser::RegName.new
547
- assert_instance_of Result::OK, reg_name.parse("_")
548
- assert_instance_of Result::OK, reg_name.parse("'")
549
- assert_instance_of Result::OK, reg_name.parse("(")
550
- assert_instance_of Result::OK, reg_name.parse("z")
551
- assert_instance_of Result::OK, reg_name.parse(";")
552
- end
553
-
554
-
555
- def test_server
556
- server = URIParser::Server.new
557
- assert_instance_of Result::OK, server.parse("a")
558
- assert_instance_of Result::OK, server.parse("localhost")
559
- assert_instance_of Result::OK, server.parse("localhost.localdomain")
560
- assert_instance_of Result::OK, server.parse("192.168.0.2:8080")
561
- assert_instance_of Result::OK, server.parse("localhost.localdomain:3000")
562
- assert_instance_of Result::OK, server.parse("192.168.0.2")
563
- assert_instance_of Result::OK, server.parse("emile@localhost.localdomain:3000")
564
- assert_instance_of Result::OK, server.parse("emile@192.168.0.2")
565
- assert_instance_of Result::OK, server.parse("192")
566
- end
567
-
568
- def test_user_info
569
- user_info = URIParser::UserInfo.new
570
- end
571
-
572
- def test_host_port
573
- host_port = URIParser::HostPort.new
574
- assert_instance_of Result::OK, host_port.parse("a")
575
- assert_instance_of Result::OK, host_port.parse("localhost")
576
- assert_instance_of Result::OK, host_port.parse("localhost.localdomain")
577
- assert_instance_of Result::OK, host_port.parse("192.168.0.2:8080")
578
- assert_instance_of Result::OK, host_port.parse("localhost.localdomain:3000")
579
- assert_instance_of Result::OK, host_port.parse("192.168.0.2")
580
- assert_instance_of Result::Fail, host_port.parse("192")
581
- end
582
-
583
- def test_host
584
- host = URIParser::Host.new
585
- assert_instance_of Result::OK, host.parse("a")
586
- assert_instance_of Result::OK, host.parse("localhost")
587
- assert_instance_of Result::OK, host.parse("localhost.localdomain")
588
- assert_instance_of Result::OK, host.parse("192.168.0.2")
589
- assert_instance_of Result::Fail, host.parse("192")
590
- end
591
-
592
- def test_host_name
593
- host_name = URIParser::HostName.new
594
- assert_instance_of Result::OK, host_name.parse("a")
595
- assert_instance_of Result::OK, host_name.parse("localhost")
596
- assert_instance_of Result::OK, host_name.parse("localhost.localdomain")
597
- assert_instance_of Result::Fail, host_name.parse("192")
598
- end
599
-
600
- def test_domain_label
601
- domain_label = URIParser::DomainLabel.new
602
- assert_instance_of Result::OK, domain_label.parse("a")
603
- assert_instance_of Result::OK, domain_label.parse("localhost")
604
- assert_instance_of Result::OK, domain_label.parse("192")
605
- end
606
-
607
- def test_top_label
608
- top_label = URIParser::TopLabel.new
609
- assert_instance_of Result::OK, top_label.parse("a")
610
- assert_instance_of Result::OK, top_label.parse("localhost")
611
- assert_instance_of Result::Fail, top_label.parse("192")
612
- end
613
-
614
- def test_ipv4address
615
- ipv4address = URIParser::IPv4Address.new
616
- assert_instance_of Result::OK, ipv4address.parse("192.168.0.1")
617
- assert_instance_of Result::Fail, ipv4address.parse("8080")
618
- end
619
-
620
- def test_port
621
- port = URIParser::Port.new
622
- assert_instance_of Result::OK, port.parse("8080")
623
- assert_instance_of Result::OK, port.parse("pchar;param/pchar;param")
624
- end
625
-
626
- def test_path_segment
627
- path_segments = URIParser::PathSegments.new
628
- assert_instance_of Result::OK, path_segments.parse("pchar;param")
629
- assert_instance_of Result::OK, path_segments.parse("pchar;param/pchar;param")
630
- end
631
-
632
- def test_segment
633
- segment = URIParser::Segment.new
634
- assert_instance_of Result::OK, segment.parse("pchar;param")
635
- end
636
-
637
- def test_param
638
- param = URIParser::Param.new
639
- assert_instance_of Result::OK, param.parse("_")
640
- assert_instance_of Result::OK, param.parse("'")
641
- assert_instance_of Result::OK, param.parse("(")
642
- assert_instance_of Result::OK, param.parse("z")
643
- assert_instance_of Result::OK, param.parse(";")
644
- end
645
-
646
- def test_pchar
647
- pchar = URIParser::Pchar.new
648
- assert_instance_of Result::OK, pchar.parse("_")
649
- assert_instance_of Result::OK, pchar.parse("'")
650
- assert_instance_of Result::OK, pchar.parse("(")
651
- assert_instance_of Result::OK, pchar.parse("z")
652
- assert_instance_of Result::Fail, pchar.parse(";")
653
- end
654
-
655
- def test_fragment
656
- fragment = URIParser::Fragment.new
657
- assert_instance_of Result::OK, fragment.parse(";")
658
- assert_instance_of Result::OK, fragment.parse("_")
659
- assert_instance_of Result::OK, fragment.parse("'")
660
- assert_instance_of Result::OK, fragment.parse("(")
661
- assert_instance_of Result::OK, fragment.parse("z")
662
- end
663
-
664
- def test_uric
665
- uric = URIParser::Uric.new
666
- assert_instance_of Result::OK, uric.parse(";")
667
- assert_instance_of Result::OK, uric.parse("_")
668
- assert_instance_of Result::OK, uric.parse("'")
669
- assert_instance_of Result::OK, uric.parse("(")
670
- assert_instance_of Result::OK, uric.parse("z")
671
- end
672
-
673
- def test_reserved
674
- reserved = URIParser::Reserved.new
675
- assert_instance_of Result::OK, reserved.parse(";")
676
- assert_instance_of Result::Fail, reserved.parse("_")
677
- assert_instance_of Result::Fail, reserved.parse("'")
678
- assert_instance_of Result::Fail, reserved.parse("(")
679
- assert_instance_of Result::Fail, reserved.parse("z")
680
- end
681
-
682
- def test_unreserved
683
- unreserved = URIParser::Unreserved.new
684
- assert_instance_of Result::OK, unreserved.parse("_")
685
- assert_instance_of Result::OK, unreserved.parse("'")
686
- assert_instance_of Result::OK, unreserved.parse("(")
687
- assert_instance_of Result::OK, unreserved.parse("z")
688
- assert_instance_of Result::Fail, unreserved.parse(";")
689
- end
690
-
691
- def test_mark
692
- mark = URIParser::Mark.new
693
- assert_instance_of Result::OK, mark.parse("_")
694
- assert_instance_of Result::OK, mark.parse("'")
695
- assert_instance_of Result::OK, mark.parse("(")
696
- assert_instance_of Result::Fail, mark.parse("z")
697
- end
698
-
699
- def test_hex
700
- hex = URIParser::Hex.new
701
- assert_instance_of Result::OK, hex.parse("b")
702
- assert_instance_of Result::OK, hex.parse("A")
703
- assert_instance_of Result::OK, hex.parse("0")
704
- assert_instance_of Result::Fail, hex.parse("z")
705
- end
706
-
707
- def test_escaped
708
- escaped = URIParser::Escaped.new
709
- assert_instance_of Result::OK, escaped.parse("%aA")
710
- assert_instance_of Result::Fail, escaped.parse("0")
711
- assert_instance_of Result::Fail, escaped.parse("z")
712
- end
713
-
714
- def test_alpha
715
- alpha = URIParser::Alpha.new
716
- assert_instance_of Result::OK, alpha.parse("b")
717
- assert_instance_of Result::OK, alpha.parse("A")
718
- assert_instance_of Result::Fail, alpha.parse("0")
719
- end
720
-
721
- def test_alpha_num
722
- alpha_num = URIParser::AlphaNum.new
723
- assert_instance_of Result::OK, alpha_num.parse("b")
724
- assert_instance_of Result::OK, alpha_num.parse("A")
725
- assert_instance_of Result::OK, alpha_num.parse("0")
726
- end
727
-
728
- def test_low_alpha
729
- low_alpha = URIParser::LowAlpha.new
730
- assert_instance_of Result::OK, low_alpha.parse("b")
731
- assert_instance_of Result::Fail, low_alpha.parse("A")
732
- assert_instance_of Result::Fail, low_alpha.parse("0")
733
- end
734
-
735
- def test_up_alpha
736
- up_alpha = URIParser::UpAlpha.new
737
- assert_instance_of Result::OK, up_alpha.parse("A")
738
- assert_instance_of Result::Fail, up_alpha.parse("b")
739
- assert_instance_of Result::Fail, up_alpha.parse("0")
740
- end
741
-
742
- def test_digit
743
- digit = URIParser::Digit.new
744
- assert_instance_of Result::OK, digit.parse("1")
745
- assert_instance_of Result::OK, digit.parse("0")
746
- assert_instance_of Result::OK, digit.parse("2")
747
- assert_instance_of Result::OK, digit.parse("9")
748
- assert_instance_of Result::Fail, digit.parse("a")
749
- end
750
-
751
-
752
- end