tables_test.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. package urn
  2. import (
  3. "strconv"
  4. "strings"
  5. )
  6. func ierror(index int) string {
  7. return "Test case num. " + strconv.Itoa(index+1)
  8. }
  9. func herror(index int, test testCase) string {
  10. return ierror(index) + ", input \"" + string(test.in) + "\""
  11. }
  12. func rxpad(str string, lim int) string {
  13. str = str + strings.Repeat(" ", lim)
  14. return str[:lim]
  15. }
  16. type testCase struct {
  17. in []byte // the input
  18. ok bool // whether it is valid or not
  19. obj *URN // a pointer to the resulting urn.URN instance
  20. str string // string representation
  21. norm string // norm string representation
  22. estr string // error string
  23. }
  24. var tests = []testCase{
  25. // ok
  26. {
  27. []byte("urn:simple:simple"),
  28. true,
  29. &URN{
  30. prefix: "urn",
  31. ID: "simple",
  32. SS: "simple",
  33. },
  34. "urn:simple:simple",
  35. "urn:simple:simple",
  36. "",
  37. },
  38. {
  39. []byte("urn:ciao:%5D"),
  40. true,
  41. &URN{
  42. prefix: "urn",
  43. ID: "ciao",
  44. SS: "%5D",
  45. },
  46. "urn:ciao:%5D",
  47. "urn:ciao:%5d",
  48. "",
  49. },
  50. // ok - RFC examples
  51. {
  52. []byte("URN:foo:a123,456"),
  53. true,
  54. &URN{
  55. prefix: "URN",
  56. ID: "foo",
  57. SS: "a123,456",
  58. },
  59. "URN:foo:a123,456",
  60. "urn:foo:a123,456",
  61. "",
  62. },
  63. {
  64. []byte("urn:foo:a123,456"),
  65. true,
  66. &URN{
  67. prefix: "urn",
  68. ID: "foo",
  69. SS: "a123,456",
  70. },
  71. "urn:foo:a123,456",
  72. "urn:foo:a123,456",
  73. "",
  74. },
  75. {
  76. []byte("urn:FOO:a123,456"),
  77. true,
  78. &URN{
  79. prefix: "urn",
  80. ID: "FOO",
  81. SS: "a123,456",
  82. },
  83. "urn:FOO:a123,456",
  84. "urn:foo:a123,456",
  85. "",
  86. },
  87. {
  88. []byte("urn:foo:A123,456"),
  89. true,
  90. &URN{
  91. prefix: "urn",
  92. ID: "foo",
  93. SS: "A123,456",
  94. },
  95. "urn:foo:A123,456",
  96. "urn:foo:A123,456",
  97. "",
  98. },
  99. {
  100. []byte("urn:foo:a123%2C456"),
  101. true,
  102. &URN{
  103. prefix: "urn",
  104. ID: "foo",
  105. SS: "a123%2C456",
  106. },
  107. "urn:foo:a123%2C456",
  108. "urn:foo:a123%2c456",
  109. "",
  110. },
  111. {
  112. []byte("URN:FOO:a123%2c456"),
  113. true,
  114. &URN{
  115. prefix: "URN",
  116. ID: "FOO",
  117. SS: "a123%2c456",
  118. },
  119. "URN:FOO:a123%2c456",
  120. "urn:foo:a123%2c456",
  121. "",
  122. },
  123. {
  124. []byte("URN:FOO:ABC%FFabc123%2c456"),
  125. true,
  126. &URN{
  127. prefix: "URN",
  128. ID: "FOO",
  129. SS: "ABC%FFabc123%2c456",
  130. },
  131. "URN:FOO:ABC%FFabc123%2c456",
  132. "urn:foo:ABC%ffabc123%2c456",
  133. "",
  134. },
  135. {
  136. []byte("URN:FOO:ABC%FFabc123%2C456%9A"),
  137. true,
  138. &URN{
  139. prefix: "URN",
  140. ID: "FOO",
  141. SS: "ABC%FFabc123%2C456%9A",
  142. },
  143. "URN:FOO:ABC%FFabc123%2C456%9A",
  144. "urn:foo:ABC%ffabc123%2c456%9a",
  145. "",
  146. },
  147. // ok - SCIM v2
  148. {
  149. []byte("urn:ietf:params:scim:schemas:core:2.0:User"),
  150. true,
  151. &URN{
  152. prefix: "urn",
  153. ID: "ietf",
  154. SS: "params:scim:schemas:core:2.0:User",
  155. },
  156. "urn:ietf:params:scim:schemas:core:2.0:User",
  157. "urn:ietf:params:scim:schemas:core:2.0:User",
  158. "",
  159. },
  160. {
  161. []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"),
  162. true,
  163. &URN{
  164. prefix: "urn",
  165. ID: "ietf",
  166. SS: "params:scim:schemas:extension:enterprise:2.0:User",
  167. },
  168. "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
  169. "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
  170. "",
  171. },
  172. {
  173. []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName"),
  174. true,
  175. &URN{
  176. prefix: "urn",
  177. ID: "ietf",
  178. SS: "params:scim:schemas:extension:enterprise:2.0:User:userName",
  179. },
  180. "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName",
  181. "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:userName",
  182. "",
  183. },
  184. {
  185. []byte("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified"),
  186. true,
  187. &URN{
  188. prefix: "urn",
  189. ID: "ietf",
  190. SS: "params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified",
  191. },
  192. "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified",
  193. "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:meta.lastModified",
  194. "",
  195. },
  196. // ok - minimum urn
  197. {
  198. []byte("urn:a:b"),
  199. true,
  200. &URN{
  201. prefix: "urn",
  202. ID: "a",
  203. SS: "b",
  204. },
  205. "urn:a:b",
  206. "urn:a:b",
  207. "",
  208. },
  209. {
  210. []byte("urn:a::"),
  211. true,
  212. &URN{
  213. prefix: "urn",
  214. ID: "a",
  215. SS: ":",
  216. },
  217. "urn:a::",
  218. "urn:a::",
  219. "",
  220. },
  221. {
  222. []byte("urn:a:-"),
  223. true,
  224. &URN{
  225. prefix: "urn",
  226. ID: "a",
  227. SS: "-",
  228. },
  229. "urn:a:-",
  230. "urn:a:-",
  231. "",
  232. },
  233. // ok - URN prefix is case-insensitive
  234. {
  235. []byte("URN:simple:simple"),
  236. true,
  237. &URN{
  238. prefix: "URN",
  239. ID: "simple",
  240. SS: "simple",
  241. },
  242. "URN:simple:simple",
  243. "urn:simple:simple",
  244. "",
  245. },
  246. {
  247. []byte("Urn:simple:simple"),
  248. true,
  249. &URN{
  250. prefix: "Urn",
  251. ID: "simple",
  252. SS: "simple",
  253. },
  254. "Urn:simple:simple",
  255. "urn:simple:simple",
  256. "",
  257. },
  258. // ok - ID can contain the "urn" string but it can not be exactly equal to it
  259. {
  260. []byte("urn:urna:simple"),
  261. true,
  262. &URN{
  263. prefix: "urn",
  264. ID: "urna",
  265. SS: "simple",
  266. },
  267. "urn:urna:simple",
  268. "urn:urna:simple",
  269. "",
  270. },
  271. {
  272. []byte("urn:burnout:nss"),
  273. true,
  274. &URN{
  275. prefix: "urn",
  276. ID: "burnout",
  277. SS: "nss",
  278. },
  279. "urn:burnout:nss",
  280. "urn:burnout:nss",
  281. "",
  282. },
  283. {
  284. []byte("urn:burn:nss"),
  285. true,
  286. &URN{
  287. prefix: "urn",
  288. ID: "burn",
  289. SS: "nss",
  290. },
  291. "urn:burn:nss",
  292. "urn:burn:nss",
  293. "",
  294. },
  295. {
  296. []byte("urn:urnurnurn:x"),
  297. true,
  298. &URN{
  299. prefix: "urn",
  300. ID: "urnurnurn",
  301. SS: "x",
  302. },
  303. "urn:urnurnurn:x",
  304. "urn:urnurnurn:x",
  305. "",
  306. },
  307. // ok - ID can contains maximum 32 characters
  308. {
  309. []byte("urn:abcdefghilmnopqrstuvzabcdefghilm:x"),
  310. true,
  311. &URN{
  312. prefix: "urn",
  313. ID: "abcdefghilmnopqrstuvzabcdefghilm",
  314. SS: "x",
  315. },
  316. "urn:abcdefghilmnopqrstuvzabcdefghilm:x",
  317. "urn:abcdefghilmnopqrstuvzabcdefghilm:x",
  318. "",
  319. },
  320. // ok - ID can be alpha numeric
  321. {
  322. []byte("URN:123:x"),
  323. true,
  324. &URN{
  325. prefix: "URN",
  326. ID: "123",
  327. SS: "x",
  328. },
  329. "URN:123:x",
  330. "urn:123:x",
  331. "",
  332. },
  333. {
  334. []byte("URN:1ab:x"),
  335. true,
  336. &URN{
  337. prefix: "URN",
  338. ID: "1ab",
  339. SS: "x",
  340. },
  341. "URN:1ab:x",
  342. "urn:1ab:x",
  343. "",
  344. },
  345. {
  346. []byte("URN:a1b:x"),
  347. true,
  348. &URN{
  349. prefix: "URN",
  350. ID: "a1b",
  351. SS: "x",
  352. },
  353. "URN:a1b:x",
  354. "urn:a1b:x",
  355. "",
  356. },
  357. {
  358. []byte("URN:a12:x"),
  359. true,
  360. &URN{
  361. prefix: "URN",
  362. ID: "a12",
  363. SS: "x",
  364. },
  365. "URN:a12:x",
  366. "urn:a12:x",
  367. "",
  368. },
  369. {
  370. []byte("URN:cd2:x"),
  371. true,
  372. &URN{
  373. prefix: "URN",
  374. ID: "cd2",
  375. SS: "x",
  376. },
  377. "URN:cd2:x",
  378. "urn:cd2:x",
  379. "",
  380. },
  381. // ok - ID can contain an hyphen (not in its first position, see below)
  382. {
  383. []byte("URN:abcd-:x"),
  384. true,
  385. &URN{
  386. prefix: "URN",
  387. ID: "abcd-",
  388. SS: "x",
  389. },
  390. "URN:abcd-:x",
  391. "urn:abcd-:x",
  392. "",
  393. },
  394. {
  395. []byte("URN:abcd-abcd:x"),
  396. true,
  397. &URN{
  398. prefix: "URN",
  399. ID: "abcd-abcd",
  400. SS: "x",
  401. },
  402. "URN:abcd-abcd:x",
  403. "urn:abcd-abcd:x",
  404. "",
  405. },
  406. {
  407. []byte("URN:a123-456z:x"),
  408. true,
  409. &URN{
  410. prefix: "URN",
  411. ID: "a123-456z",
  412. SS: "x",
  413. },
  414. "URN:a123-456z:x",
  415. "urn:a123-456z:x",
  416. "",
  417. },
  418. // ok - SS can contain the "urn" string, also be exactly equal to it
  419. {
  420. []byte("urn:urnx:urn"),
  421. true,
  422. &URN{
  423. prefix: "urn",
  424. ID: "urnx",
  425. SS: "urn",
  426. },
  427. "urn:urnx:urn",
  428. "urn:urnx:urn",
  429. "",
  430. },
  431. {
  432. []byte("urn:urnurnurn:urn"),
  433. true,
  434. &URN{
  435. prefix: "urn",
  436. ID: "urnurnurn",
  437. SS: "urn",
  438. },
  439. "urn:urnurnurn:urn",
  440. "urn:urnurnurn:urn",
  441. "",
  442. },
  443. {
  444. []byte("urn:hey:urnurnurn"),
  445. true,
  446. &URN{
  447. prefix: "urn",
  448. ID: "hey",
  449. SS: "urnurnurn",
  450. },
  451. "urn:hey:urnurnurn",
  452. "urn:hey:urnurnurn",
  453. "",
  454. },
  455. // ok - SS can contains and discerns multiple colons, also at the end
  456. {
  457. []byte("urn:ciao:a:b:c"),
  458. true,
  459. &URN{
  460. prefix: "urn",
  461. ID: "ciao",
  462. SS: "a:b:c",
  463. },
  464. "urn:ciao:a:b:c",
  465. "urn:ciao:a:b:c",
  466. "",
  467. },
  468. {
  469. []byte("urn:aaa:x:y:"),
  470. true,
  471. &URN{
  472. prefix: "urn",
  473. ID: "aaa",
  474. SS: "x:y:",
  475. },
  476. "urn:aaa:x:y:",
  477. "urn:aaa:x:y:",
  478. "",
  479. },
  480. {
  481. []byte("urn:aaa:x:y:"),
  482. true,
  483. &URN{
  484. prefix: "urn",
  485. ID: "aaa",
  486. SS: "x:y:",
  487. },
  488. "urn:aaa:x:y:",
  489. "urn:aaa:x:y:",
  490. "",
  491. },
  492. // ok - SS can contain (and also start with) some non-alphabetical (ie., OTHER) characters
  493. {
  494. []byte("urn:ciao:-"),
  495. true,
  496. &URN{
  497. prefix: "urn",
  498. ID: "ciao",
  499. SS: "-",
  500. },
  501. "urn:ciao:-",
  502. "urn:ciao:-",
  503. "",
  504. },
  505. {
  506. []byte("urn:ciao::"),
  507. true,
  508. &URN{
  509. prefix: "urn",
  510. ID: "ciao",
  511. SS: ":",
  512. },
  513. "urn:ciao::",
  514. "urn:ciao::",
  515. "",
  516. },
  517. {
  518. []byte("urn:colon:::::nss"),
  519. true,
  520. &URN{
  521. prefix: "urn",
  522. ID: "colon",
  523. SS: "::::nss",
  524. },
  525. "urn:colon:::::nss",
  526. "urn:colon:::::nss",
  527. "",
  528. },
  529. {
  530. []byte("urn:ciao:!"),
  531. true,
  532. &URN{
  533. prefix: "urn",
  534. ID: "ciao",
  535. SS: "!",
  536. },
  537. "urn:ciao:!",
  538. "urn:ciao:!",
  539. "",
  540. },
  541. {
  542. []byte("urn:ciao:!!*"),
  543. true,
  544. &URN{
  545. prefix: "urn",
  546. ID: "ciao",
  547. SS: "!!*",
  548. },
  549. "urn:ciao:!!*",
  550. "urn:ciao:!!*",
  551. "",
  552. },
  553. {
  554. []byte("urn:ciao:-!:-,:x"),
  555. true,
  556. &URN{
  557. prefix: "urn",
  558. ID: "ciao",
  559. SS: "-!:-,:x",
  560. },
  561. "urn:ciao:-!:-,:x",
  562. "urn:ciao:-!:-,:x",
  563. "",
  564. },
  565. {
  566. []byte("urn:ciao:=@"),
  567. true,
  568. &URN{
  569. prefix: "urn",
  570. ID: "ciao",
  571. SS: "=@",
  572. },
  573. "urn:ciao:=@",
  574. "urn:ciao:=@",
  575. "",
  576. },
  577. {
  578. []byte("urn:ciao:@!=%2C(xyz)+a,b.*@g=$_'"),
  579. true,
  580. &URN{
  581. prefix: "urn",
  582. ID: "ciao",
  583. SS: "@!=%2C(xyz)+a,b.*@g=$_'",
  584. },
  585. "urn:ciao:@!=%2C(xyz)+a,b.*@g=$_'",
  586. "urn:ciao:@!=%2c(xyz)+a,b.*@g=$_'",
  587. "",
  588. },
  589. // ok - SS can contain (and also start with) hexadecimal representation of octets
  590. {
  591. []byte("URN:hexes:%25"),
  592. true,
  593. &URN{
  594. prefix: "URN",
  595. ID: "hexes",
  596. SS: "%25",
  597. },
  598. "URN:hexes:%25",
  599. "urn:hexes:%25",
  600. "",
  601. }, // Literal use of the "%" character in a namespace must be encoded using "%25"
  602. {
  603. []byte("URN:x:abc%1Dz%2F%3az"),
  604. true,
  605. &URN{
  606. prefix: "URN",
  607. ID: "x",
  608. SS: "abc%1Dz%2F%3az",
  609. },
  610. "URN:x:abc%1Dz%2F%3az",
  611. "urn:x:abc%1dz%2f%3az",
  612. "",
  613. }, // Literal use of the "%" character in a namespace must be encoded using "%25"
  614. // no - ID can not start with an hyphen
  615. {
  616. []byte("URN:-xxx:x"),
  617. false,
  618. nil,
  619. "",
  620. "",
  621. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  622. },
  623. {
  624. []byte("URN:---xxx:x"),
  625. false,
  626. nil,
  627. "",
  628. "",
  629. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  630. },
  631. // no - ID can not start with a colon
  632. {
  633. []byte("urn::colon:nss"),
  634. false,
  635. nil,
  636. "",
  637. "",
  638. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  639. },
  640. {
  641. []byte("urn::::nss"),
  642. false,
  643. nil,
  644. "",
  645. "",
  646. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  647. },
  648. // no - ID can not contains more than 32 characters
  649. {
  650. []byte("urn:abcdefghilmnopqrstuvzabcdefghilmn:specificstring"),
  651. false,
  652. nil,
  653. "",
  654. "",
  655. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 36]`,
  656. },
  657. // no - ID can not contain special characters
  658. {
  659. []byte("URN:a!?:x"),
  660. false,
  661. nil,
  662. "",
  663. "",
  664. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 5]`,
  665. },
  666. {
  667. []byte("URN:@,:x"),
  668. false,
  669. nil,
  670. "",
  671. "",
  672. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  673. },
  674. {
  675. []byte("URN:#,:x"),
  676. false,
  677. nil,
  678. "",
  679. "",
  680. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  681. },
  682. {
  683. []byte("URN:bc'.@:x"),
  684. false,
  685. nil,
  686. "",
  687. "",
  688. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 6]`,
  689. },
  690. // no - ID can not be equal to "urn"
  691. {
  692. []byte("urn:urn:NSS"),
  693. false,
  694. nil,
  695. "",
  696. "",
  697. `expecting the identifier to not contain the "urn" reserved string [col 7]`,
  698. },
  699. {
  700. []byte("urn:URN:NSS"),
  701. false,
  702. nil,
  703. "",
  704. "",
  705. `expecting the identifier to not contain the "urn" reserved string [col 7]`,
  706. },
  707. {
  708. []byte("URN:URN:NSS"),
  709. false,
  710. nil,
  711. "",
  712. "",
  713. `expecting the identifier to not contain the "urn" reserved string [col 7]`,
  714. },
  715. {
  716. []byte("urn:UrN:NSS"),
  717. false,
  718. nil,
  719. "",
  720. "",
  721. `expecting the identifier to not contain the "urn" reserved string [col 7]`,
  722. },
  723. {
  724. []byte("urn:Urn:NSS"),
  725. false,
  726. nil,
  727. "",
  728. "",
  729. `expecting the identifier to not contain the "urn" reserved string [col 7]`,
  730. },
  731. // no - ID can not contain spaces
  732. {
  733. []byte("urn:white space:NSS"),
  734. false,
  735. nil,
  736. "",
  737. "",
  738. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 9]`,
  739. },
  740. // no - SS can not contain spaces
  741. {
  742. []byte("urn:concat:no spaces"),
  743. false,
  744. nil,
  745. "",
  746. "",
  747. `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 13]`,
  748. },
  749. // no - SS can not contain reserved characters (can accept them only if %-escaped)
  750. {
  751. []byte("urn:a:%"), // the presence of an "%" character in an URN MUST be followed by two characters from the <hex> character set
  752. false,
  753. nil,
  754. "",
  755. "",
  756. `expecting the specific string hex chars to be well-formed (%alnum{2}) [col 7]`,
  757. },
  758. {
  759. []byte("urn:a:?"),
  760. false,
  761. nil,
  762. "",
  763. "",
  764. `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
  765. },
  766. {
  767. []byte("urn:a:#"),
  768. false,
  769. nil,
  770. "",
  771. "",
  772. `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
  773. },
  774. {
  775. []byte("urn:a:/"),
  776. false,
  777. nil,
  778. "",
  779. "",
  780. `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
  781. },
  782. // no - Incomplete URNs
  783. {
  784. []byte("urn:"),
  785. false,
  786. nil,
  787. "",
  788. "",
  789. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  790. },
  791. {
  792. []byte("urn::"),
  793. false,
  794. nil,
  795. "",
  796. "",
  797. `expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col 4]`,
  798. },
  799. {
  800. []byte("urn:a:"),
  801. false,
  802. nil,
  803. "",
  804. "",
  805. `expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col 6]`,
  806. },
  807. // {
  808. // "urn:a",
  809. // false,
  810. // nil,
  811. // "",
  812. // "",
  813. // "",
  814. // },
  815. }
  816. var equivalenceTests = []struct {
  817. eq bool
  818. lx []byte
  819. rx []byte
  820. }{
  821. {
  822. true,
  823. []byte("urn:foo:a123%2C456"),
  824. []byte("URN:FOO:a123%2c456"),
  825. },
  826. {
  827. true,
  828. []byte("urn:foo:AbC123%2C456"),
  829. []byte("URN:FOO:AbC123%2c456"),
  830. },
  831. {
  832. true,
  833. []byte("urn:foo:AbC123%2C456%1f"),
  834. []byte("URN:FOO:AbC123%2c456%1f"),
  835. },
  836. {
  837. true,
  838. []byte("URN:foo:a123,456"),
  839. []byte("urn:foo:a123,456"),
  840. },
  841. {
  842. true,
  843. []byte("URN:foo:a123,456"),
  844. []byte("urn:FOO:a123,456"),
  845. },
  846. {
  847. true,
  848. []byte("urn:foo:a123,456"),
  849. []byte("urn:FOO:a123,456"),
  850. },
  851. {
  852. true,
  853. []byte("urn:ciao:%2E"),
  854. []byte("urn:ciao:%2e"),
  855. },
  856. {
  857. false,
  858. []byte("urn:foo:A123,456"),
  859. []byte("URN:foo:a123,456"),
  860. },
  861. {
  862. false,
  863. []byte("urn:foo:A123,456"),
  864. []byte("urn:foo:a123,456"),
  865. },
  866. {
  867. false,
  868. []byte("urn:foo:A123,456"),
  869. []byte("urn:FOO:a123,456"),
  870. },
  871. }