1 package urn
2
3 import (
4 "fmt"
5 "strconv"
6 "strings"
7 )
8
9 func ierror(index int) string {
10 return "Test case num. " + strconv.Itoa(index+1)
11 }
12
13 func herror(index int, test testCase) string {
14 return ierror(index) + ", input \"" + string(test.in) + "\""
15 }
16
17 func rxpad(str string, lim int) string {
18 str = str + strings.Repeat(" ", lim)
19 return str[:lim]
20 }
21
22 type testCase struct {
23 in []byte
24 ok bool
25 obj *URN
26 str string
27 norm string
28 estr string
29 isSCIM bool
30 }
31
32 var urnlexTestCases = []testCase{
33
34 {
35 []byte("urn:lex:it:stato:legge:2003-09-21;456"),
36 true,
37 &URN{
38 prefix: "urn",
39 ID: "lex",
40 SS: "it:stato:legge:2003-09-21;456",
41 },
42 "urn:lex:it:stato:legge:2003-09-21;456",
43 "urn:lex:it:stato:legge:2003-09-21;456",
44 "",
45 false,
46 },
47
48 {
49 []byte("urn:lex:fr:etat:lois:2004-12-06;321"),
50 true,
51 &URN{
52 prefix: "urn",
53 ID: "lex",
54 SS: "fr:etat:lois:2004-12-06;321",
55 },
56 "urn:lex:fr:etat:lois:2004-12-06;321",
57 "urn:lex:fr:etat:lois:2004-12-06;321",
58 "",
59 false,
60 },
61
62 {
63 []byte("urn:lex:es:estado:ley:2002-07-12;123"),
64 true,
65 &URN{
66 prefix: "urn",
67 ID: "lex",
68 SS: "es:estado:ley:2002-07-12;123",
69 },
70 "urn:lex:es:estado:ley:2002-07-12;123",
71 "urn:lex:es:estado:ley:2002-07-12;123",
72 "",
73 false,
74 },
75
76 {
77 []byte("urn:lex:ch;glarus:regiere:erlass:2007-10-15;963"),
78 true,
79 &URN{
80 prefix: "urn",
81 ID: "lex",
82 SS: "ch;glarus:regiere:erlass:2007-10-15;963",
83 },
84 "urn:lex:ch;glarus:regiere:erlass:2007-10-15;963",
85 "urn:lex:ch;glarus:regiere:erlass:2007-10-15;963",
86 "",
87 false,
88 },
89
90 {
91 []byte("urn:lex:eu:council:directive:2010-03-09;2010-19-UE"),
92 true,
93 &URN{
94 prefix: "urn",
95 ID: "lex",
96 SS: "eu:council:directive:2010-03-09;2010-19-UE",
97 },
98 "urn:lex:eu:council:directive:2010-03-09;2010-19-UE",
99 "urn:lex:eu:council:directive:2010-03-09;2010-19-UE",
100 "",
101 false,
102 },
103 {
104 []byte("urn:lex:eu:council:directive:2010-03-09;2010-19-UE"),
105 true,
106 &URN{
107 prefix: "urn",
108 ID: "lex",
109 SS: "eu:council:directive:2010-03-09;2010-19-UE",
110 },
111 "urn:lex:eu:council:directive:2010-03-09;2010-19-UE",
112 "urn:lex:eu:council:directive:2010-03-09;2010-19-UE",
113 "",
114 false,
115 },
116
117 {
118 []byte("urn:lex:us:federal.supreme.court:decision:1963-03-18;372.us.335"),
119 true,
120 &URN{
121 prefix: "urn",
122 ID: "lex",
123 SS: "us:federal.supreme.court:decision:1963-03-18;372.us.335",
124 },
125 "urn:lex:us:federal.supreme.court:decision:1963-03-18;372.us.335",
126 "urn:lex:us:federal.supreme.court:decision:1963-03-18;372.us.335",
127 "",
128 false,
129 },
130 }
131
132 var scimOnlyTestCases = []testCase{
133
134 {
135 []byte("urn:ietf:params:scim:schemas:core:2.0:User"),
136 true,
137 &URN{
138 prefix: "urn",
139 ID: "ietf:params:scim",
140 SS: "schemas:core:2.0:User",
141 },
142 "urn:ietf:params:scim:schemas:core:2.0:User",
143 "urn:ietf:params:scim:schemas:core:2.0:User",
144 "",
145 true,
146 },
147 {
148 []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"),
149 true,
150 &URN{
151 prefix: "urn",
152 ID: "ietf:params:scim",
153 SS: "schemas:extension:enterprise:2.0:User",
154 },
155 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
156 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
157 "",
158 true,
159 },
160 {
161 []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName"),
162 true,
163 &URN{
164 prefix: "urn",
165 ID: "ietf:params:scim",
166 SS: "schemas:extension:enterprise:2.0:User:userName",
167 },
168 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName",
169 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName",
170 "",
171 true,
172 },
173 {
174 []byte("urn:ietf:params:scim:api:messages:2.0:ListResponse"),
175 true,
176 &URN{
177 prefix: "urn",
178 ID: "ietf:params:scim",
179 SS: "api:messages:2.0:ListResponse",
180 },
181 "urn:ietf:params:scim:api:messages:2.0:ListResponse",
182 "urn:ietf:params:scim:api:messages:2.0:ListResponse",
183 "",
184 true,
185 },
186 {
187 []byte("urn:ietf:params:scim:schemas:core"),
188 true,
189 &URN{
190 prefix: "urn",
191 ID: "ietf:params:scim",
192 SS: "schemas:core",
193 },
194 "urn:ietf:params:scim:schemas:core",
195 "urn:ietf:params:scim:schemas:core",
196 "",
197 true,
198 },
199 {
200 []byte("urn:ietf:params:scim:param:core"),
201 true,
202 &URN{
203 prefix: "urn",
204 ID: "ietf:params:scim",
205 SS: "param:core",
206 },
207 "urn:ietf:params:scim:param:core",
208 "urn:ietf:params:scim:param:core",
209 "",
210 true,
211 },
212 {
213 []byte("urn:ietf:params:scim:api:messages:%FF"),
214 true,
215 &URN{
216 prefix: "urn",
217 ID: "ietf:params:scim",
218 SS: "api:messages:%FF",
219 },
220 "urn:ietf:params:scim:api:messages:%FF",
221 "urn:ietf:params:scim:api:messages:%ff",
222 "",
223 true,
224 },
225
226
227 {
228 []byte("arn:ietf:params:scim:schemas:core"),
229 false,
230 nil,
231 "",
232 "",
233 fmt.Sprintf(errPrefix, 0),
234 false,
235 },
236 {
237 []byte("usn:ietf:params:scim:schemas:core"),
238 false,
239 nil,
240 "",
241 "",
242 fmt.Sprintf(errPrefix, 1),
243 false,
244 },
245 {
246 []byte("urm:ietf:params:scim:schemas:core"),
247 false,
248 nil,
249 "",
250 "",
251 fmt.Sprintf(errPrefix, 2),
252 false,
253 },
254 {
255 []byte("urno:ietf:params:scim:schemas:core"),
256 false,
257 nil,
258 "",
259 "",
260 fmt.Sprintf(errPrefix, 3),
261 false,
262 },
263 {
264 []byte("urno"),
265 false,
266 nil,
267 "",
268 "",
269 fmt.Sprintf(errPrefix, 3),
270 false,
271 },
272 {
273 []byte("urn:WRONG:schemas:core"),
274 false,
275 nil,
276 "",
277 "",
278 fmt.Sprintf(errSCIMNamespace, 4),
279 false,
280 },
281 {
282 []byte("urn:ietf:params:scim:WRONG:core"),
283 false,
284 nil,
285 "",
286 "",
287 fmt.Sprintf(errSCIMType, 21),
288 false,
289 },
290 {
291 []byte("urn:ietf:params:scim:schemas:$"),
292 false,
293 nil,
294 "",
295 "",
296 fmt.Sprintf(errSCIMName, 29),
297 false,
298 },
299 {
300 []byte("urn:ietf:params:scim:schemas:core-"),
301 false,
302 nil,
303 "",
304 "",
305 fmt.Sprintf(errSCIMName, 33),
306 false,
307 },
308 {
309 []byte("urn:ietf:params:scim:schemas:core:"),
310 false,
311 nil,
312 "",
313 "",
314 fmt.Sprintf(errSCIMOtherIncomplete, 33),
315 false,
316 },
317 {
318 []byte("urn:ietf:params:scim:schemas:core:2.&"),
319 false,
320 nil,
321 "",
322 "",
323 fmt.Sprintf(errSCIMOther, 36),
324 false,
325 },
326 {
327 []byte("urn:ietf:params:scim:api:messages:%"),
328 false,
329 nil,
330 "",
331 "",
332 fmt.Sprintf(errSCIMOtherIncomplete, 34),
333 false,
334 },
335 {
336 []byte("urn:ietf:params:scim:api:messages:%F"),
337 false,
338 nil,
339 "",
340 "",
341 fmt.Sprintf(errSCIMOtherIncomplete, 35),
342 false,
343 },
344
345
346
347
348
349
350
351
352
353
354 {
355 []byte("urn:"),
356 false,
357 nil,
358 "",
359 "",
360 fmt.Sprintf(errSCIMNamespace, 4),
361 false,
362 },
363 {
364 []byte("urn::"),
365 false,
366 nil,
367 "",
368 "",
369 fmt.Sprintf(errSCIMNamespace, 4),
370 false,
371 },
372 {
373 []byte("urn:a:"),
374 false,
375 nil,
376 "",
377 "",
378 fmt.Sprintf(errSCIMNamespace, 4),
379 false,
380 },
381 {
382 []byte("urn:a"),
383 false,
384 nil,
385 "",
386 "",
387 fmt.Sprintf(errSCIMNamespace, 4),
388 false,
389 },
390 {
391 []byte(`u`),
392 false,
393 nil,
394 "",
395 "",
396 fmt.Sprintf(errPrefix, 1),
397 false,
398 },
399 {
400 []byte(`ur`),
401 false,
402 nil,
403 "",
404 "",
405 fmt.Sprintf(errPrefix, 2),
406 false,
407 },
408 {
409 []byte(`urn`),
410 false,
411 nil,
412 "",
413 "",
414 fmt.Sprintf(errPrefix, 3),
415 false,
416 },
417 }
418
419 var urn2141OnlyTestCases = []testCase{
420
421 {
422 []byte("urn:simple:simple"),
423 true,
424 &URN{
425 prefix: "urn",
426 ID: "simple",
427 SS: "simple",
428 },
429 "urn:simple:simple",
430 "urn:simple:simple",
431 "",
432 false,
433 },
434 {
435 []byte("urn:ciao:%5D"),
436 true,
437 &URN{
438 prefix: "urn",
439 ID: "ciao",
440 SS: "%5D",
441 },
442 "urn:ciao:%5D",
443 "urn:ciao:%5d",
444 "",
445 false,
446 },
447
448
449 {
450 []byte("URN:foo:a123,456"),
451 true,
452 &URN{
453 prefix: "URN",
454 ID: "foo",
455 SS: "a123,456",
456 },
457 "URN:foo:a123,456",
458 "urn:foo:a123,456",
459 "",
460 false,
461 },
462 {
463 []byte("urn:foo:a123,456"),
464 true,
465 &URN{
466 prefix: "urn",
467 ID: "foo",
468 SS: "a123,456",
469 },
470 "urn:foo:a123,456",
471 "urn:foo:a123,456",
472 "",
473 false,
474 },
475 {
476 []byte("urn:FOO:a123,456"),
477 true,
478 &URN{
479 prefix: "urn",
480 ID: "FOO",
481 SS: "a123,456",
482 },
483 "urn:FOO:a123,456",
484 "urn:foo:a123,456",
485 "",
486 false,
487 },
488 {
489 []byte("urn:foo:A123,456"),
490 true,
491 &URN{
492 prefix: "urn",
493 ID: "foo",
494 SS: "A123,456",
495 },
496 "urn:foo:A123,456",
497 "urn:foo:A123,456",
498 "",
499 false,
500 },
501 {
502 []byte("urn:foo:a123%2C456"),
503 true,
504 &URN{
505 prefix: "urn",
506 ID: "foo",
507 SS: "a123%2C456",
508 },
509 "urn:foo:a123%2C456",
510 "urn:foo:a123%2c456",
511 "",
512 false,
513 },
514 {
515 []byte("URN:FOO:a123%2c456"),
516 true,
517 &URN{
518 prefix: "URN",
519 ID: "FOO",
520 SS: "a123%2c456",
521 },
522 "URN:FOO:a123%2c456",
523 "urn:foo:a123%2c456",
524 "",
525 false,
526 },
527 {
528 []byte("URN:FOO:ABC%FFabc123%2c456"),
529 true,
530 &URN{
531 prefix: "URN",
532 ID: "FOO",
533 SS: "ABC%FFabc123%2c456",
534 },
535 "URN:FOO:ABC%FFabc123%2c456",
536 "urn:foo:ABC%ffabc123%2c456",
537 "",
538 false,
539 },
540 {
541 []byte("URN:FOO:ABC%FFabc123%2C456%9A"),
542 true,
543 &URN{
544 prefix: "URN",
545 ID: "FOO",
546 SS: "ABC%FFabc123%2C456%9A",
547 },
548 "URN:FOO:ABC%FFabc123%2C456%9A",
549 "urn:foo:ABC%ffabc123%2c456%9a",
550 "",
551 false,
552 },
553
554
555 {
556 []byte("urn:ietf:params:scim:schemas:core:2.0:User"),
557 true,
558 &URN{
559 prefix: "urn",
560 ID: "ietf",
561 SS: "params:scim:schemas:core:2.0:User",
562 },
563 "urn:ietf:params:scim:schemas:core:2.0:User",
564 "urn:ietf:params:scim:schemas:core:2.0:User",
565 "",
566 true,
567 },
568 {
569 []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"),
570 true,
571 &URN{
572 prefix: "urn",
573 ID: "ietf",
574 SS: "params:scim:schemas:extension:enterprise:2.0:User",
575 },
576 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
577 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
578 "",
579 true,
580 },
581 {
582 []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName"),
583 true,
584 &URN{
585 prefix: "urn",
586 ID: "ietf",
587 SS: "params:scim:schemas:extension:enterprise:2.0:User:userName",
588 },
589 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName",
590 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName",
591 "",
592 true,
593 },
594 {
595 []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified"),
596 true,
597 &URN{
598 prefix: "urn",
599 ID: "ietf",
600 SS: "params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified",
601 },
602 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified",
603 "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified",
604 "",
605 true,
606 },
607
608
609 {
610 []byte("urn:a:b"),
611 true,
612 &URN{
613 prefix: "urn",
614 ID: "a",
615 SS: "b",
616 },
617 "urn:a:b",
618 "urn:a:b",
619 "",
620 false,
621 },
622 {
623 []byte("urn:a::"),
624 true,
625 &URN{
626 prefix: "urn",
627 ID: "a",
628 SS: ":",
629 },
630 "urn:a::",
631 "urn:a::",
632 "",
633 false,
634 },
635 {
636 []byte("urn:a:-"),
637 true,
638 &URN{
639 prefix: "urn",
640 ID: "a",
641 SS: "-",
642 },
643 "urn:a:-",
644 "urn:a:-",
645 "",
646 false,
647 },
648
649
650 {
651 []byte("URN:simple:simple"),
652 true,
653 &URN{
654 prefix: "URN",
655 ID: "simple",
656 SS: "simple",
657 },
658 "URN:simple:simple",
659 "urn:simple:simple",
660 "",
661 false,
662 },
663 {
664 []byte("Urn:simple:simple"),
665 true,
666 &URN{
667 prefix: "Urn",
668 ID: "simple",
669 SS: "simple",
670 },
671 "Urn:simple:simple",
672 "urn:simple:simple",
673 "",
674 false,
675 },
676
677
678 {
679 []byte("urn:urna:simple"),
680 true,
681 &URN{
682 prefix: "urn",
683 ID: "urna",
684 SS: "simple",
685 },
686 "urn:urna:simple",
687 "urn:urna:simple",
688 "",
689 false,
690 },
691 {
692 []byte("urn:burnout:nss"),
693 true,
694 &URN{
695 prefix: "urn",
696 ID: "burnout",
697 SS: "nss",
698 },
699 "urn:burnout:nss",
700 "urn:burnout:nss",
701 "",
702 false,
703 },
704 {
705 []byte("urn:burn:nss"),
706 true,
707 &URN{
708 prefix: "urn",
709 ID: "burn",
710 SS: "nss",
711 },
712 "urn:burn:nss",
713 "urn:burn:nss",
714 "",
715 false,
716 },
717 {
718 []byte("urn:urnurnurn:x"),
719 true,
720 &URN{
721 prefix: "urn",
722 ID: "urnurnurn",
723 SS: "x",
724 },
725 "urn:urnurnurn:x",
726 "urn:urnurnurn:x",
727 "",
728 false,
729 },
730
731
732 {
733 []byte("urn:abcdefghilmnopqrstuvzabcdefghilm:x"),
734 true,
735 &URN{
736 prefix: "urn",
737 ID: "abcdefghilmnopqrstuvzabcdefghilm",
738 SS: "x",
739 },
740 "urn:abcdefghilmnopqrstuvzabcdefghilm:x",
741 "urn:abcdefghilmnopqrstuvzabcdefghilm:x",
742 "",
743 false,
744 },
745
746
747 {
748 []byte("URN:123:x"),
749 true,
750 &URN{
751 prefix: "URN",
752 ID: "123",
753 SS: "x",
754 },
755 "URN:123:x",
756 "urn:123:x",
757 "",
758 false,
759 },
760 {
761 []byte("URN:1ab:x"),
762 true,
763 &URN{
764 prefix: "URN",
765 ID: "1ab",
766 SS: "x",
767 },
768 "URN:1ab:x",
769 "urn:1ab:x",
770 "",
771 false,
772 },
773 {
774 []byte("URN:a1b:x"),
775 true,
776 &URN{
777 prefix: "URN",
778 ID: "a1b",
779 SS: "x",
780 },
781 "URN:a1b:x",
782 "urn:a1b:x",
783 "",
784 false,
785 },
786 {
787 []byte("URN:a12:x"),
788 true,
789 &URN{
790 prefix: "URN",
791 ID: "a12",
792 SS: "x",
793 },
794 "URN:a12:x",
795 "urn:a12:x",
796 "",
797 false,
798 },
799 {
800 []byte("URN:cd2:x"),
801 true,
802 &URN{
803 prefix: "URN",
804 ID: "cd2",
805 SS: "x",
806 },
807 "URN:cd2:x",
808 "urn:cd2:x",
809 "",
810 false,
811 },
812
813
814 {
815 []byte("URN:abcd-:x"),
816 true,
817 &URN{
818 prefix: "URN",
819 ID: "abcd-",
820 SS: "x",
821 },
822 "URN:abcd-:x",
823 "urn:abcd-:x",
824 "",
825 false,
826 },
827 {
828 []byte("URN:abcd-abcd:x"),
829 true,
830 &URN{
831 prefix: "URN",
832 ID: "abcd-abcd",
833 SS: "x",
834 },
835 "URN:abcd-abcd:x",
836 "urn:abcd-abcd:x",
837 "",
838 false,
839 },
840 {
841 []byte("URN:a123-456z:x"),
842 true,
843 &URN{
844 prefix: "URN",
845 ID: "a123-456z",
846 SS: "x",
847 },
848 "URN:a123-456z:x",
849 "urn:a123-456z:x",
850 "",
851 false,
852 },
853
854
855 {
856 []byte("urn:urnx:urn"),
857 true,
858 &URN{
859 prefix: "urn",
860 ID: "urnx",
861 SS: "urn",
862 },
863 "urn:urnx:urn",
864 "urn:urnx:urn",
865 "",
866 false,
867 },
868 {
869 []byte("urn:urnurnurn:urn"),
870 true,
871 &URN{
872 prefix: "urn",
873 ID: "urnurnurn",
874 SS: "urn",
875 },
876 "urn:urnurnurn:urn",
877 "urn:urnurnurn:urn",
878 "",
879 false,
880 },
881 {
882 []byte("urn:hey:urnurnurn"),
883 true,
884 &URN{
885 prefix: "urn",
886 ID: "hey",
887 SS: "urnurnurn",
888 },
889 "urn:hey:urnurnurn",
890 "urn:hey:urnurnurn",
891 "",
892 false,
893 },
894
895
896 {
897 []byte("urn:ciao:a:b:c"),
898 true,
899 &URN{
900 prefix: "urn",
901 ID: "ciao",
902 SS: "a:b:c",
903 },
904 "urn:ciao:a:b:c",
905 "urn:ciao:a:b:c",
906 "",
907 false,
908 },
909 {
910 []byte("urn:aaa:x:y:"),
911 true,
912 &URN{
913 prefix: "urn",
914 ID: "aaa",
915 SS: "x:y:",
916 },
917 "urn:aaa:x:y:",
918 "urn:aaa:x:y:",
919 "",
920 false,
921 },
922 {
923 []byte("urn:aaa:x:y:"),
924 true,
925 &URN{
926 prefix: "urn",
927 ID: "aaa",
928 SS: "x:y:",
929 },
930 "urn:aaa:x:y:",
931 "urn:aaa:x:y:",
932 "",
933 false,
934 },
935
936
937 {
938 []byte("urn:ciao:-"),
939 true,
940 &URN{
941 prefix: "urn",
942 ID: "ciao",
943 SS: "-",
944 },
945 "urn:ciao:-",
946 "urn:ciao:-",
947 "",
948 false,
949 },
950 {
951 []byte("urn:ciao:("),
952 true,
953 &URN{
954 prefix: "urn",
955 ID: "ciao",
956 SS: "(",
957 },
958 "urn:ciao:(",
959 "urn:ciao:(",
960 "",
961 false,
962 },
963 {
964 []byte("urn:ciao:)"),
965 true,
966 &URN{
967 prefix: "urn",
968 ID: "ciao",
969 SS: ")",
970 },
971 "urn:ciao:)",
972 "urn:ciao:)",
973 "",
974 false,
975 },
976 {
977 []byte("urn:ciao:+"),
978 true,
979 &URN{
980 prefix: "urn",
981 ID: "ciao",
982 SS: "+",
983 },
984 "urn:ciao:+",
985 "urn:ciao:+",
986 "",
987 false,
988 },
989 {
990 []byte("urn:ciao::"),
991 true,
992 &URN{
993 prefix: "urn",
994 ID: "ciao",
995 SS: ":",
996 },
997 "urn:ciao::",
998 "urn:ciao::",
999 "",
1000 false,
1001 },
1002 {
1003 []byte("urn:colon:::::nss"),
1004 true,
1005 &URN{
1006 prefix: "urn",
1007 ID: "colon",
1008 SS: "::::nss",
1009 },
1010 "urn:colon:::::nss",
1011 "urn:colon:::::nss",
1012 "",
1013 false,
1014 },
1015 {
1016 []byte("urn:ciao:!"),
1017 true,
1018 &URN{
1019 prefix: "urn",
1020 ID: "ciao",
1021 SS: "!",
1022 },
1023 "urn:ciao:!",
1024 "urn:ciao:!",
1025 "",
1026 false,
1027 },
1028 {
1029 []byte("urn:ciao:!!*"),
1030 true,
1031 &URN{
1032 prefix: "urn",
1033 ID: "ciao",
1034 SS: "!!*",
1035 },
1036 "urn:ciao:!!*",
1037 "urn:ciao:!!*",
1038 "",
1039 false,
1040 },
1041 {
1042 []byte("urn:ciao:-!:-,:x"),
1043 true,
1044 &URN{
1045 prefix: "urn",
1046 ID: "ciao",
1047 SS: "-!:-,:x",
1048 },
1049 "urn:ciao:-!:-,:x",
1050 "urn:ciao:-!:-,:x",
1051 "",
1052 false,
1053 },
1054 {
1055 []byte("urn:ciao:=@"),
1056 true,
1057 &URN{
1058 prefix: "urn",
1059 ID: "ciao",
1060 SS: "=@",
1061 },
1062 "urn:ciao:=@",
1063 "urn:ciao:=@",
1064 "",
1065 false,
1066 },
1067 {
1068 []byte("urn:ciao:@!=%2C(xyz)+a,b.*@g=$_'"),
1069 true,
1070 &URN{
1071 prefix: "urn",
1072 ID: "ciao",
1073 SS: "@!=%2C(xyz)+a,b.*@g=$_'",
1074 },
1075 "urn:ciao:@!=%2C(xyz)+a,b.*@g=$_'",
1076 "urn:ciao:@!=%2c(xyz)+a,b.*@g=$_'",
1077 "",
1078 false,
1079 },
1080
1081
1082 {
1083 []byte("URN:hexes:%25"),
1084 true,
1085 &URN{
1086 prefix: "URN",
1087 ID: "hexes",
1088 SS: "%25",
1089 },
1090 "URN:hexes:%25",
1091 "urn:hexes:%25",
1092 "",
1093 false,
1094 },
1095 {
1096 []byte("URN:x:abc%1Dz%2F%3az"),
1097 true,
1098 &URN{
1099 prefix: "URN",
1100 ID: "x",
1101 SS: "abc%1Dz%2F%3az",
1102 },
1103 "URN:x:abc%1Dz%2F%3az",
1104 "urn:x:abc%1dz%2f%3az",
1105 "",
1106 false,
1107 },
1108
1109
1110 {
1111 []byte("URN:-xxx:x"),
1112 false,
1113 nil,
1114 "",
1115 "",
1116 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1117 false,
1118 },
1119 {
1120 []byte("URN:---xxx:x"),
1121 false,
1122 nil,
1123 "",
1124 "",
1125 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1126 false,
1127 },
1128
1129
1130 {
1131 []byte("urn::colon:nss"),
1132 false,
1133 nil,
1134 "",
1135 "",
1136 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1137 false,
1138 },
1139 {
1140 []byte("urn::::nss"),
1141 false,
1142 nil,
1143 "",
1144 "",
1145 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1146 false,
1147 },
1148
1149
1150 {
1151 []byte("urn:abcdefghilmnopqrstuvzabcdefghilmn:specificstring"),
1152 false,
1153 nil,
1154 "",
1155 "",
1156 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 36]`,
1157 false,
1158 },
1159
1160
1161 {
1162 []byte("URN:a!?:x"),
1163 false,
1164 nil,
1165 "",
1166 "",
1167 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 5]`,
1168 false,
1169 },
1170 {
1171 []byte("URN:@,:x"),
1172 false,
1173 nil,
1174 "",
1175 "",
1176 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1177 false,
1178 },
1179 {
1180 []byte("URN:#,:x"),
1181 false,
1182 nil,
1183 "",
1184 "",
1185 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1186 false,
1187 },
1188 {
1189 []byte("URN:bc'.@:x"),
1190 false,
1191 nil,
1192 "",
1193 "",
1194 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 6]`,
1195 false,
1196 },
1197
1198
1199 {
1200 []byte("urn:urn:NSS"),
1201 false,
1202 nil,
1203 "",
1204 "",
1205 `expecting the identifier to not contain the "urn" reserved string [col 7]`,
1206 false,
1207 },
1208 {
1209 []byte("urn:URN:NSS"),
1210 false,
1211 nil,
1212 "",
1213 "",
1214 `expecting the identifier to not contain the "urn" reserved string [col 7]`,
1215 false,
1216 },
1217 {
1218 []byte("URN:URN:NSS"),
1219 false,
1220 nil,
1221 "",
1222 "",
1223 `expecting the identifier to not contain the "urn" reserved string [col 7]`,
1224 false,
1225 },
1226 {
1227 []byte("urn:UrN:NSS"),
1228 false,
1229 nil,
1230 "",
1231 "",
1232 `expecting the identifier to not contain the "urn" reserved string [col 7]`,
1233 false,
1234 },
1235 {
1236 []byte("urn:Urn:NSS"),
1237 false,
1238 nil,
1239 "",
1240 "",
1241 `expecting the identifier to not contain the "urn" reserved string [col 7]`,
1242 false,
1243 },
1244
1245
1246 {
1247 []byte("urn:white space:NSS"),
1248 false,
1249 nil,
1250 "",
1251 "",
1252 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 9]`,
1253 false,
1254 },
1255
1256
1257 {
1258 []byte("urn:concat:no spaces"),
1259 false,
1260 nil,
1261 "",
1262 "",
1263 `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 13]`,
1264 false,
1265 },
1266
1267
1268 {
1269 []byte("urn:a:%"),
1270 false,
1271 nil,
1272 "",
1273 "",
1274 fmt.Sprintf(errHex, 7),
1275 false,
1276 },
1277 {
1278 []byte("urn:a:%A"),
1279 false,
1280 nil,
1281 "",
1282 "",
1283 fmt.Sprintf(errHex, 8),
1284 false,
1285 },
1286 {
1287 []byte("urn:a:?"),
1288 false,
1289 nil,
1290 "",
1291 "",
1292 `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
1293 false,
1294 },
1295 {
1296 []byte("urn:a:#"),
1297 false,
1298 nil,
1299 "",
1300 "",
1301 `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
1302 false,
1303 },
1304 {
1305 []byte("urn:a:/"),
1306 false,
1307 nil,
1308 "",
1309 "",
1310 `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
1311 false,
1312 },
1313 {
1314 []byte("urn:ietf:params:scim:api:messages:%"),
1315 false,
1316 nil,
1317 "",
1318 "",
1319 fmt.Sprintf(errHex, 35),
1320 false,
1321 },
1322 {
1323 []byte("urn:ietf:params:scim:api:messages:%F"),
1324 false,
1325 nil,
1326 "",
1327 "",
1328 fmt.Sprintf(errHex, 36),
1329 false,
1330 },
1331 {
1332 []byte("arn:ietf:params:scim:schemas:core"),
1333 false,
1334 nil,
1335 "",
1336 "",
1337 fmt.Sprintf(errPrefix, 0),
1338 false,
1339 },
1340 {
1341 []byte("usn:ietf:params:scim:schemas:core"),
1342 false,
1343 nil,
1344 "",
1345 "",
1346 fmt.Sprintf(errPrefix, 1),
1347 false,
1348 },
1349 {
1350 []byte("urm:ietf:params:scim:schemas:core"),
1351 false,
1352 nil,
1353 "",
1354 "",
1355 fmt.Sprintf(errPrefix, 2),
1356 false,
1357 },
1358 {
1359 []byte("urno:ietf:params:scim:schemas:core"),
1360 false,
1361 nil,
1362 "",
1363 "",
1364 fmt.Sprintf(errPrefix, 3),
1365 false,
1366 },
1367 {
1368 []byte("urno"),
1369 false,
1370 nil,
1371 "",
1372 "",
1373 fmt.Sprintf(errPrefix, 3),
1374 false,
1375 },
1376 {
1377 []byte("URN:a!?:x"),
1378 false,
1379 nil,
1380 "",
1381 "",
1382 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 5]`,
1383 false,
1384 },
1385 {
1386 []byte("urn:Urn:NSS"),
1387 false,
1388 nil,
1389 "",
1390 "",
1391 `expecting the identifier to not contain the "urn" reserved string [col 7]`,
1392 false,
1393 },
1394 {
1395 []byte("urn:spazio bianco:NSS"),
1396 false,
1397 nil,
1398 "",
1399 "",
1400 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 10]`,
1401 false,
1402 },
1403 {
1404 []byte("urn:conca:z ws"),
1405 false,
1406 nil,
1407 "",
1408 "",
1409 fmt.Sprintf(errSpecificString, 11),
1410 false,
1411 },
1412 {
1413 []byte("urn:ietf:params:scim:schemas:core:2.&"),
1414 false,
1415 nil,
1416 "",
1417 "",
1418 fmt.Sprintf(errSpecificString, 36),
1419 false,
1420 },
1421
1422
1423 {
1424 []byte("urn:"),
1425 false,
1426 nil,
1427 "",
1428 "",
1429 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1430 false,
1431 },
1432 {
1433 []byte("urn::"),
1434 false,
1435 nil,
1436 "",
1437 "",
1438 `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its beginning) [col 4]`,
1439 false,
1440 },
1441 {
1442 []byte("urn:a:"),
1443 false,
1444 nil,
1445 "",
1446 "",
1447 `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
1448 false,
1449 },
1450 {
1451 []byte("urn:a"),
1452 false,
1453 nil,
1454 "",
1455 "",
1456 fmt.Sprintf(errIdentifier, 5),
1457 false,
1458 },
1459
1460 {
1461 []byte(`u`),
1462 false,
1463 nil,
1464 "",
1465 "",
1466 fmt.Sprintf(errPrefix, 1),
1467 false,
1468 },
1469 {
1470 []byte(`ur`),
1471 false,
1472 nil,
1473 "",
1474 "",
1475 fmt.Sprintf(errPrefix, 2),
1476 false,
1477 },
1478 {
1479 []byte(`urn`),
1480 false,
1481 nil,
1482 "",
1483 "",
1484 fmt.Sprintf(errPrefix, 3),
1485 false,
1486 },
1487
1488
1489 {
1490 []byte(""),
1491 false,
1492 nil,
1493 "",
1494 "",
1495 fmt.Sprintf(errPrefix, 0),
1496 false,
1497 },
1498 }
1499
1500 var rfc8141TestCases = []testCase{
1501
1502 {
1503 []byte("urn:lex:it:ministero.giustizia:decreto:1992-07-24;358~art5"),
1504 true,
1505 &URN{
1506 prefix: "urn",
1507 ID: "lex",
1508 SS: "it:ministero.giustizia:decreto:1992-07-24;358~art5",
1509 },
1510 "urn:lex:it:ministero.giustizia:decreto:1992-07-24;358~art5",
1511 "urn:lex:it:ministero.giustizia:decreto:1992-07-24;358~art5",
1512 "",
1513 false,
1514 },
1515 {
1516 []byte("urn:nid:nss/"),
1517 true,
1518 &URN{
1519 prefix: "urn",
1520 ID: "nid",
1521 SS: "nss/",
1522 },
1523 "urn:nid:nss/",
1524 "urn:nid:nss/",
1525 "",
1526 false,
1527 },
1528 {
1529 []byte("urn:nid:nss&"),
1530 true,
1531 &URN{
1532 prefix: "urn",
1533 ID: "nid",
1534 SS: "nss&",
1535 },
1536 "urn:nid:nss&",
1537 "urn:nid:nss&",
1538 "",
1539 false,
1540 },
1541 {
1542 []byte("urn:example:1/406/47452/2"),
1543 true,
1544 &URN{
1545 prefix: "urn",
1546 ID: "example",
1547 SS: "1/406/47452/2",
1548 },
1549 "urn:example:1/406/47452/2",
1550 "urn:example:1/406/47452/2",
1551 "",
1552 false,
1553 },
1554 {
1555 []byte("urn:example:foo-bar-baz-qux?+CCResolve:cc=uk"),
1556 true,
1557 &URN{
1558 prefix: "urn",
1559 ID: "example",
1560 SS: "foo-bar-baz-qux",
1561 rComponent: "CCResolve:cc=uk",
1562 },
1563 "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk",
1564 "urn:example:foo-bar-baz-qux",
1565 "",
1566 false,
1567 },
1568 {
1569 []byte("urn:example:foo-bar-baz-qux?+&"),
1570 true,
1571 &URN{
1572 prefix: "urn",
1573 ID: "example",
1574 SS: "foo-bar-baz-qux",
1575 rComponent: "&",
1576 },
1577 "urn:example:foo-bar-baz-qux?+&",
1578 "urn:example:foo-bar-baz-qux",
1579 "",
1580 false,
1581 },
1582 {
1583 []byte("urn:example:foo-bar-baz-qux?+~"),
1584 true,
1585 &URN{
1586 prefix: "urn",
1587 ID: "example",
1588 SS: "foo-bar-baz-qux",
1589 rComponent: "~",
1590 },
1591 "urn:example:foo-bar-baz-qux?+~",
1592 "urn:example:foo-bar-baz-qux",
1593 "",
1594 false,
1595 },
1596 {
1597 []byte("urn:example:foo-bar-baz-qux?+%16CCResolve:cc=uk"),
1598 true,
1599 &URN{
1600 prefix: "urn",
1601 ID: "example",
1602 SS: "foo-bar-baz-qux",
1603 rComponent: "%16CCResolve:cc=uk",
1604 },
1605 "urn:example:foo-bar-baz-qux?+%16CCResolve:cc=uk",
1606 "urn:example:foo-bar-baz-qux",
1607 "",
1608 false,
1609 },
1610 {
1611 []byte("urn:example:foo-bar-baz-qut?+~&%FF()+,-.:=@;$_!/?Alnum123456"),
1612 true,
1613 &URN{
1614 prefix: "urn",
1615 ID: "example",
1616 SS: "foo-bar-baz-qut",
1617 rComponent: "~&%FF()+,-.:=@;$_!/?Alnum123456",
1618 },
1619 "urn:example:foo-bar-baz-qut?+~&%FF()+,-.:=@;$_!/?Alnum123456",
1620 "urn:example:foo-bar-baz-qut",
1621 "",
1622 false,
1623 },
1624 {
1625 []byte("urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z"),
1626 true,
1627 &URN{
1628 prefix: "urn",
1629 ID: "example",
1630 SS: "weather",
1631 qComponent: "op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z",
1632 },
1633 "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z",
1634 "urn:example:weather",
1635 "",
1636 false,
1637 },
1638 {
1639 []byte("urn:esempio:climate?=alnum~&%FF()+,-.:=@;$_!/?123456"),
1640 true,
1641 &URN{
1642 prefix: "urn",
1643 ID: "esempio",
1644 SS: "climate",
1645 qComponent: "alnum~&%FF()+,-.:=@;$_!/?123456",
1646 },
1647 "urn:esempio:climate?=alnum~&%FF()+,-.:=@;$_!/?123456",
1648 "urn:esempio:climate",
1649 "",
1650 false,
1651 },
1652 {
1653 []byte("urn:esempio:climate?=&&"),
1654 true,
1655 &URN{
1656 prefix: "urn",
1657 ID: "esempio",
1658 SS: "climate",
1659 qComponent: "&&",
1660 },
1661 "urn:esempio:climate?=&&",
1662 "urn:esempio:climate",
1663 "",
1664 false,
1665 },
1666 {
1667 []byte("urn:esempio:climate?=%A1alnum~&%FF()+,-.:=@;$_!/?123456"),
1668 true,
1669 &URN{
1670 prefix: "urn",
1671 ID: "esempio",
1672 SS: "climate",
1673 qComponent: "%A1alnum~&%FF()+,-.:=@;$_!/?123456",
1674 },
1675 "urn:esempio:climate?=%A1alnum~&%FF()+,-.:=@;$_!/?123456",
1676 "urn:esempio:climate",
1677 "",
1678 false,
1679 },
1680 {
1681 []byte("urn:example:foo-bar-baz-qux#somepart"),
1682 true,
1683 &URN{
1684 prefix: "urn",
1685 ID: "example",
1686 SS: "foo-bar-baz-qux",
1687 fComponent: "somepart",
1688 },
1689 "urn:example:foo-bar-baz-qux#somepart",
1690 "urn:example:foo-bar-baz-qux",
1691 "",
1692 false,
1693 },
1694 {
1695 []byte("urn:example:foo-bar-baz-qux#~&"),
1696 true,
1697 &URN{
1698 prefix: "urn",
1699 ID: "example",
1700 SS: "foo-bar-baz-qux",
1701 fComponent: "~&",
1702 },
1703 "urn:example:foo-bar-baz-qux#~&",
1704 "urn:example:foo-bar-baz-qux",
1705 "",
1706 false,
1707 },
1708 {
1709 []byte("urn:example:foo-bar-baz-qux#alnum~&%FF()+,-.:=@;$_!/?123456"),
1710 true,
1711 &URN{
1712 prefix: "urn",
1713 ID: "example",
1714 SS: "foo-bar-baz-qux",
1715 fComponent: "alnum~&%FF()+,-.:=@;$_!/?123456",
1716 },
1717 "urn:example:foo-bar-baz-qux#alnum~&%FF()+,-.:=@;$_!/?123456",
1718 "urn:example:foo-bar-baz-qux",
1719 "",
1720 false,
1721 },
1722 {
1723 []byte("urn:example:foo-bar-baz-qux#%D0alnum~&%FF()+,-.:=@;$_!/?123456"),
1724 true,
1725 &URN{
1726 prefix: "urn",
1727 ID: "example",
1728 SS: "foo-bar-baz-qux",
1729 fComponent: "%D0alnum~&%FF()+,-.:=@;$_!/?123456",
1730 },
1731 "urn:example:foo-bar-baz-qux#%D0alnum~&%FF()+,-.:=@;$_!/?123456",
1732 "urn:example:foo-bar-baz-qux",
1733 "",
1734 false,
1735 },
1736 {
1737 []byte("urn:example:CamelCase1/406/47452/2?+Cc=it&prefix=39?=lat=41.22255&long=16.06596#frag"),
1738 true,
1739 &URN{
1740 prefix: "urn",
1741 ID: "example",
1742 SS: "CamelCase1/406/47452/2",
1743 rComponent: "Cc=it&prefix=39",
1744 qComponent: "lat=41.22255&long=16.06596",
1745 fComponent: "frag",
1746 },
1747 "urn:example:CamelCase1/406/47452/2?+Cc=it&prefix=39?=lat=41.22255&long=16.06596#frag",
1748 "urn:example:CamelCase1/406/47452/2",
1749 "",
1750 false,
1751 },
1752 {
1753 []byte("urn:example:CamelCase1/406/47452/2?=lat=41.22255&long=16.06596#frag"),
1754 true,
1755 &URN{
1756 prefix: "urn",
1757 ID: "example",
1758 SS: "CamelCase1/406/47452/2",
1759 qComponent: "lat=41.22255&long=16.06596",
1760 fComponent: "frag",
1761 },
1762 "urn:example:CamelCase1/406/47452/2?=lat=41.22255&long=16.06596#frag",
1763 "urn:example:CamelCase1/406/47452/2",
1764 "",
1765 false,
1766 },
1767 {
1768 []byte("urn:example:CamelCase1/406/47452/2?=lat=41.22255&long=16.06596#frag?some/slash/~%D0"),
1769 true,
1770 &URN{
1771 prefix: "urn",
1772 ID: "example",
1773 SS: "CamelCase1/406/47452/2",
1774 qComponent: "lat=41.22255&long=16.06596",
1775 fComponent: "frag?some/slash/~%D0",
1776 },
1777 "urn:example:CamelCase1/406/47452/2?=lat=41.22255&long=16.06596#frag?some/slash/~%D0",
1778 "urn:example:CamelCase1/406/47452/2",
1779 "",
1780 false,
1781 },
1782 {
1783 []byte("urn:example:CamelCase1/406/47452/2?+Cc=it&prefix=39?=lat=41.22255&long=16.06596"),
1784 true,
1785 &URN{
1786 prefix: "urn",
1787 ID: "example",
1788 SS: "CamelCase1/406/47452/2",
1789 rComponent: "Cc=it&prefix=39",
1790 qComponent: "lat=41.22255&long=16.06596",
1791 },
1792 "urn:example:CamelCase1/406/47452/2?+Cc=it&prefix=39?=lat=41.22255&long=16.06596",
1793 "urn:example:CamelCase1/406/47452/2",
1794 "",
1795 false,
1796 },
1797 {
1798 []byte("urn:TESTt3st:&/987/QWERTYUIOP/0#"),
1799 true,
1800 &URN{
1801 prefix: "urn",
1802 ID: "TESTt3st",
1803 SS: "&/987/QWERTYUIOP/0",
1804 fComponent: "",
1805 },
1806 "urn:TESTt3st:&/987/QWERTYUIOP/0",
1807 "urn:testt3st:&/987/QWERTYUIOP/0",
1808 "",
1809 false,
1810 },
1811 {
1812 []byte("urn:example:%D0%B0123,z456"),
1813 true,
1814 &URN{
1815 prefix: "urn",
1816 ID: "example",
1817 SS: "%D0%B0123,z456",
1818 },
1819 "urn:example:%D0%B0123,z456",
1820 "urn:example:%d0%b0123,z456",
1821 "",
1822 false,
1823 },
1824 {
1825 []byte("urn:example:apple:pear:plum:cherry"),
1826 true,
1827 &URN{
1828 prefix: "urn",
1829 ID: "example",
1830 SS: "apple:pear:plum:cherry",
1831 },
1832 "urn:example:apple:pear:plum:cherry",
1833 "urn:example:apple:pear:plum:cherry",
1834 "",
1835 false,
1836 },
1837 {
1838 []byte("urn:z------------------------------a:q"),
1839 true,
1840 &URN{
1841 prefix: "urn",
1842 ID: "z------------------------------a",
1843 SS: "q",
1844 },
1845 "urn:z------------------------------a:q",
1846 "urn:z------------------------------a:q",
1847 "",
1848 false,
1849 },
1850 {
1851 []byte("urn:10:2"),
1852 true,
1853 &URN{
1854 prefix: "urn",
1855 ID: "10",
1856 SS: "2",
1857 },
1858 "urn:10:2",
1859 "urn:10:2",
1860 "",
1861 false,
1862 },
1863 {
1864 []byte("urn:a1l2n3m4-56789aeiou:2"),
1865 true,
1866 &URN{
1867 prefix: "urn",
1868 ID: "a1l2n3m4-56789aeiou",
1869 SS: "2",
1870 },
1871 "urn:a1l2n3m4-56789aeiou:2",
1872 "urn:a1l2n3m4-56789aeiou:2",
1873 "",
1874 false,
1875 },
1876 {
1877 []byte("urn:a1l2n3m4-56789aeiou:2%D0%B0"),
1878 true,
1879 &URN{
1880 prefix: "urn",
1881 ID: "a1l2n3m4-56789aeiou",
1882 SS: "2%D0%B0",
1883 },
1884 "urn:a1l2n3m4-56789aeiou:2%D0%B0",
1885 "urn:a1l2n3m4-56789aeiou:2%d0%b0",
1886 "",
1887 false,
1888 },
1889 {
1890 []byte("urn:amp:&"),
1891 true,
1892 &URN{
1893 prefix: "urn",
1894 ID: "amp",
1895 SS: "&",
1896 },
1897 "urn:amp:&",
1898 "urn:amp:&",
1899 "",
1900 false,
1901 },
1902 {
1903 []byte("urn:tilde:~~~"),
1904 true,
1905 &URN{
1906 prefix: "urn",
1907 ID: "tilde",
1908 SS: "~~~",
1909 },
1910 "urn:tilde:~~~",
1911 "urn:tilde:~~~",
1912 "",
1913 false,
1914 },
1915 {
1916 []byte("urn:signs:()+,-.:=@;$_!*alnum123456789"),
1917 true,
1918 &URN{
1919 prefix: "urn",
1920 ID: "signs",
1921 SS: "()+,-.:=@;$_!*alnum123456789",
1922 },
1923 "urn:signs:()+,-.:=@;$_!*alnum123456789",
1924 "urn:signs:()+,-.:=@;$_!*alnum123456789",
1925 "",
1926 false,
1927 },
1928 {
1929 []byte("URN:signs:()+,-.:=@;$_!*alnum123456789"),
1930 true,
1931 &URN{
1932 prefix: "URN",
1933 ID: "signs",
1934 SS: "()+,-.:=@;$_!*alnum123456789",
1935 },
1936 "URN:signs:()+,-.:=@;$_!*alnum123456789",
1937 "urn:signs:()+,-.:=@;$_!*alnum123456789",
1938 "",
1939 false,
1940 },
1941 {
1942 []byte("urn:urn-7:informal"),
1943 true,
1944 &URN{
1945 prefix: "urn",
1946 ID: "urn-7",
1947 SS: "informal",
1948 },
1949 "urn:urn-7:informal",
1950 "urn:urn-7:informal",
1951 "",
1952 false,
1953 },
1954 {
1955 []byte("urn:ex:ex?+a?"),
1956 true,
1957 &URN{
1958 prefix: "urn",
1959 ID: "ex",
1960 SS: "ex",
1961 rComponent: "a?",
1962 },
1963 "urn:ex:ex?+a?",
1964 "urn:ex:ex",
1965 "",
1966 false,
1967 },
1968
1969
1970 {
1971 []byte("urn:urn-0:nss"),
1972 false,
1973 nil,
1974 "",
1975 "",
1976 fmt.Sprintf(err8141InformalID, 7),
1977 false,
1978 },
1979 {
1980 []byte("urn:urn-s:nss"),
1981 false,
1982 nil,
1983 "",
1984 "",
1985 fmt.Sprintf(err8141InformalID, 7),
1986 false,
1987 },
1988 {
1989 []byte("urn:example:а123,z456"),
1990 false,
1991 nil,
1992 "",
1993 "",
1994 fmt.Sprintf(err8141SpecificString, 12),
1995 false,
1996 },
1997 {
1998 []byte("URN:-leading:w"),
1999 false,
2000 nil,
2001 "",
2002 "",
2003 fmt.Sprintf(err8141Identifier, 4),
2004 false,
2005 },
2006 {
2007 []byte("URN:trailing-:w"),
2008 false,
2009 nil,
2010 "",
2011 "",
2012 fmt.Sprintf(err8141Identifier, 13),
2013 false,
2014 },
2015 {
2016 []byte("urn:a:nss"),
2017 false,
2018 nil,
2019 "",
2020 "",
2021 fmt.Sprintf(err8141Identifier, 5),
2022 false,
2023 },
2024 {
2025 []byte("urn:1:nss"),
2026 false,
2027 nil,
2028 "",
2029 "",
2030 fmt.Sprintf(err8141Identifier, 5),
2031 false,
2032 },
2033 {
2034 []byte("urn:yz-:nss"),
2035 false,
2036 nil,
2037 "",
2038 "",
2039 fmt.Sprintf(err8141Identifier, 7),
2040 false,
2041 },
2042 {
2043 []byte("urn:9x-:nss"),
2044 false,
2045 nil,
2046 "",
2047 "",
2048 fmt.Sprintf(err8141Identifier, 7),
2049 false,
2050 },
2051 {
2052 []byte("urn:X-:nss"),
2053 false,
2054 nil,
2055 "",
2056 "",
2057 fmt.Sprintf(err8141Identifier, 6),
2058 false,
2059 },
2060 {
2061 []byte("urn:xn--:nss"),
2062 false,
2063 nil,
2064 "",
2065 "",
2066 fmt.Sprintf(err8141Identifier, 8),
2067 false,
2068 },
2069 {
2070 []byte("urn:ss--:nss"),
2071 false,
2072 nil,
2073 "",
2074 "",
2075 fmt.Sprintf(err8141Identifier, 8),
2076 false,
2077 },
2078 {
2079 []byte("urn:1E--:nss"),
2080 false,
2081 nil,
2082 "",
2083 "",
2084 fmt.Sprintf(err8141Identifier, 8),
2085 false,
2086 },
2087 {
2088 []byte("urn:ex:ex?+a?+"),
2089 false,
2090 nil,
2091 "",
2092 "",
2093 fmt.Sprintf(err8141RComponentStart, 14),
2094 false,
2095 },
2096 {
2097 []byte("urn:ex:ex?+"),
2098 false,
2099 nil,
2100 "",
2101 "",
2102 fmt.Sprintf(err8141MalformedRComp, 11),
2103 false,
2104 },
2105 {
2106 []byte("urn:ex:ex?=a?="),
2107 false,
2108 nil,
2109 "",
2110 "",
2111 fmt.Sprintf(err8141QComponentStart, 14),
2112 false,
2113 },
2114 {
2115 []byte("urn:example:CamelCase1/406/47452/2?="),
2116 false,
2117 nil,
2118 "",
2119 "",
2120 fmt.Sprintf(err8141MalformedQComp, 36),
2121 false,
2122 },
2123 {
2124 []byte("urn:ex:ex?+rcomponent?+rcomponent?=qcomponent"),
2125 false,
2126 nil,
2127 "",
2128 "",
2129 fmt.Sprintf(err8141RComponentStart, 23),
2130 false,
2131 },
2132 {
2133 []byte("urn:ex:ex?+rcomponent?+rcomponent?="),
2134 false,
2135 nil,
2136 "",
2137 "",
2138 fmt.Sprintf(err8141RComponentStart, 23),
2139 false,
2140 },
2141 {
2142 []byte("urn:ex:ex?+rcomponent?=qcomponent?=q"),
2143 false,
2144 nil,
2145 "",
2146 "",
2147 fmt.Sprintf(err8141QComponentStart, 35),
2148 false,
2149 },
2150 {
2151 []byte("urn:ex:ex?+?=q"),
2152 false,
2153 nil,
2154 "",
2155 "",
2156 fmt.Sprintf(err8141MalformedRComp, 12),
2157 false,
2158 },
2159 {
2160 []byte("urn:ex:ex?+/"),
2161 false,
2162 nil,
2163 "",
2164 "",
2165 fmt.Sprintf(err8141MalformedRComp, 11),
2166 false,
2167 },
2168 {
2169 []byte("urn:ex:ex?+?"),
2170 false,
2171 nil,
2172 "",
2173 "",
2174 fmt.Sprintf(err8141MalformedRComp, 12),
2175 false,
2176 },
2177 {
2178 []byte("urn:ex:ex?=/"),
2179 false,
2180 nil,
2181 "",
2182 "",
2183 fmt.Sprintf(err8141MalformedQComp, 11),
2184 false,
2185 },
2186 {
2187 []byte("urn:ex:ex?=?"),
2188 false,
2189 nil,
2190 "",
2191 "",
2192 fmt.Sprintf(err8141MalformedQComp, 12),
2193 false,
2194 },
2195 {
2196 []byte("urn:mm:/"),
2197 false,
2198 nil,
2199 "",
2200 "",
2201 fmt.Sprintf(err8141SpecificString, 7),
2202 false,
2203 },
2204 {
2205 []byte("urn:mm:?"),
2206 false,
2207 nil,
2208 "",
2209 "",
2210 fmt.Sprintf(err8141SpecificString, 7),
2211 false,
2212 },
2213 {
2214 []byte("urn:123456789-1234567890-abcdefghilmn:o"),
2215 false,
2216 nil,
2217 "",
2218 "",
2219 fmt.Sprintf(err8141Identifier, 36),
2220 false,
2221 },
2222 {
2223 []byte("urn:"),
2224 false,
2225 nil,
2226 "",
2227 "",
2228 fmt.Sprintf(err8141Identifier, 4),
2229 false,
2230 },
2231 {
2232 []byte("urn::"),
2233 false,
2234 nil,
2235 "",
2236 "",
2237 fmt.Sprintf(err8141Identifier, 4),
2238 false,
2239 },
2240 {
2241 []byte("urn:aa:"),
2242 false,
2243 nil,
2244 "",
2245 "",
2246 fmt.Sprintf(err8141SpecificString, 7),
2247 false,
2248 },
2249 {
2250 []byte("urn:a"),
2251 false,
2252 nil,
2253 "",
2254 "",
2255 fmt.Sprintf(err8141Identifier, 5),
2256 false,
2257 },
2258 {
2259 []byte("urn:ex:ex?=%"),
2260 false,
2261 nil,
2262 "",
2263 "",
2264 fmt.Sprintf(errHex, 12),
2265 false,
2266 },
2267 {
2268 []byte("urn:ex:ex?+%"),
2269 false,
2270 nil,
2271 "",
2272 "",
2273 fmt.Sprintf(errHex, 12),
2274 false,
2275 },
2276 {
2277 []byte("urn:ex:ex?=something#%"),
2278 false,
2279 nil,
2280 "",
2281 "",
2282 fmt.Sprintf(errHex, 22),
2283 false,
2284 },
2285 {
2286 []byte("urn:example%:test"),
2287 false,
2288 nil,
2289 "",
2290 "",
2291 fmt.Sprintf(err8141Identifier, 11),
2292 false,
2293 },
2294 {
2295 []byte(`urn:"`),
2296 false,
2297 nil,
2298 "",
2299 "",
2300 fmt.Sprintf(err8141Identifier, 4),
2301 false,
2302 },
2303 {
2304 []byte(`urn:a1{}`),
2305 false,
2306 nil,
2307 "",
2308 "",
2309 fmt.Sprintf(err8141Identifier, 6),
2310 false,
2311 },
2312 {
2313 []byte(`u`),
2314 false,
2315 nil,
2316 "",
2317 "",
2318 fmt.Sprintf(errPrefix, 1),
2319 false,
2320 },
2321 {
2322 []byte(`ur`),
2323 false,
2324 nil,
2325 "",
2326 "",
2327 fmt.Sprintf(errPrefix, 2),
2328 false,
2329 },
2330 {
2331 []byte(`urn`),
2332 false,
2333 nil,
2334 "",
2335 "",
2336 fmt.Sprintf(errPrefix, 3),
2337 false,
2338 },
2339 }
2340
View as plain text