@@ -10,41 +10,36 @@ Rebol [
10
10
11
11
===start-group=== "enbase basic"
12
12
;from https://tools.ietf.org/html/rfc4648#section-10
13
- --test-- "enbase-1" --assert "" = enbase ""
14
- --test-- "enbase-2" --assert "Zg==" = enbase "f"
15
- --test-- "enbase-3" --assert "Zm8=" = enbase "fo"
16
- --test-- "enbase-4" --assert "Zm9v" = enbase "foo"
17
- --test-- "enbase-5" --assert "Zm9vYg==" = enbase "foob"
18
- --test-- "enbase-6" --assert "Zm9vYmE=" = enbase "fooba"
19
- --test-- "enbase-7" --assert "Zm9vYmFy" = enbase "foobar"
20
-
21
- --test-- "enbase-8" --assert "" = enbase /base "" 16
22
- --test-- "enbase-9" --assert "66" = enbase /base "f" 16
23
- --test-- "enbase-10" --assert "666F" = enbase /base "fo" 16
24
- --test-- "enbase-11" --assert "666F6F" = enbase /base "foo" 16
25
- --test-- "enbase-12" --assert "666F6F62" = enbase /base "foob" 16
26
- --test-- "enbase-13" --assert "666F6F6261" = enbase /base "fooba" 16
27
- --test-- "enbase-14" --assert "666F6F626172" = enbase /base "foobar" 16
13
+ --test-- "enbase-1" --assert "" = enbase "" 64
14
+ --test-- "enbase-2" --assert "Zg==" = enbase "f" 64
15
+ --test-- "enbase-3" --assert "Zm8=" = enbase "fo" 64
16
+ --test-- "enbase-4" --assert "Zm9v" = enbase "foo" 64
17
+ --test-- "enbase-5" --assert "Zm9vYg==" = enbase "foob" 64
18
+ --test-- "enbase-6" --assert "Zm9vYmE=" = enbase "fooba" 64
19
+ --test-- "enbase-7" --assert "Zm9vYmFy" = enbase "foobar" 64
20
+
21
+ --test-- "enbase-8" --assert "" = enbase "" 16
22
+ --test-- "enbase-9" --assert "66" = enbase "f" 16
23
+ --test-- "enbase-10" --assert "666F" = enbase "fo" 16
24
+ --test-- "enbase-11" --assert "666F6F" = enbase "foo" 16
25
+ --test-- "enbase-12" --assert "666F6F62" = enbase "foob" 16
26
+ --test-- "enbase-13" --assert "666F6F6261" = enbase "fooba" 16
27
+ --test-- "enbase-14" --assert "666F6F626172" = enbase "foobar" 16
28
28
===end-group===
29
29
30
30
===start-group=== "enbase with position not at head"
31
31
;@@ https://github.com/rebol/rebol-issues/issues/319
32
32
bin: #{ FF00FF00 }
33
- --test-- "enbase-2" --assert #{ 00FF00 } = debase /base enbase /base next bin 2 2
34
- --test-- "enbase-16" --assert #{ 00FF00 } = debase /base enbase /base next bin 16 16
35
- --test-- "enbase-64" --assert #{ 00FF00 } = debase enbase next bin
33
+ --test-- "enbase-2" --assert #{ 00FF00 } = debase enbase next bin 2 2
34
+ --test-- "enbase-16" --assert #{ 00FF00 } = debase enbase next bin 16 16
35
+ --test-- "enbase-64" --assert #{ 00FF00 } = debase enbase next bin 64 64
36
36
===end-group===
37
37
38
38
===start-group=== "debase 64"
39
-
40
39
--test-- "debase 64 1"
41
- --assert strict-equal? "A simple string" to string! debase "QSBzaW1wbGUgc3RyaW5n"
40
+ --assert strict-equal? "A simple string" to string! debase "QSBzaW1wbGUgc3RyaW5n" 64
42
41
--test-- "debase 64 2"
43
- --assert strict-equal? "A multi-line\nstring" to string! debase "QSBtdWx0aS1saW5lXG5zdHJpbmc="
44
- --test-- "debase 64 3"
45
- --assert strict-equal? "A simple string" to string! debase /base "QSBzaW1wbGUgc3RyaW5n" 64
46
- --test-- "debase 64 4"
47
- --assert strict-equal? "A multi-line\nstring" to string! debase /base "QSBtdWx0aS1saW5lXG5zdHJpbmc=" 64
42
+ --assert strict-equal? "A multi-line\nstring" to string! debase "QSBtdWx0aS1saW5lXG5zdHJpbmc=" 64
48
43
49
44
===end-group===
50
45
@@ -58,37 +53,37 @@ Rebol [
58
53
0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv
59
54
hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB
60
55
p0igcN_IoypGlUPQGe77Rw
61
- } ]
56
+ } 64 ]
62
57
--assert binary? try [debase {
63
58
cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7
64
59
AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4
65
60
BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K
66
61
0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv
67
62
hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB
68
63
p0igcN_IoypGlUPQGe77Rw
69
- } ]
64
+ } 64 ]
70
65
--test-- "debase 64 url 2 - missing padding in the input"
71
66
;should be ok with the padding
72
67
--assert binary? try [debase {
73
68
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
74
69
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ==
75
- } ]
70
+ } 64 ]
76
71
;should throw error when missing padding and not /url refinement is used
77
72
--assert error? try [debase {
78
73
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
79
74
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
80
- } ]
75
+ } 64 ]
81
76
--assert binary? try [debase /url {
82
77
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
83
78
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
84
- } ]
79
+ } 64 ]
85
80
--test-- "debase 64 url 3"
86
81
key1: "qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA=="
87
- bin: try [debase /url key1]
88
- --assert true? all [binary? bin key1 = enbase /url bin]
82
+ bin: try [debase /url key1 64 ]
83
+ --assert true? all [binary? bin key1 = enbase /url bin 64 ]
89
84
;debase is working also when input is missing the padding
90
85
key2: "qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA"
91
- --assert bin = try [debase /url key2]
86
+ --assert bin = try [debase /url key2 64 ]
92
87
93
88
===end-group===
94
89
@@ -97,11 +92,11 @@ Rebol [
97
92
--test-- "debase 16 1"
98
93
--assert strict-equal?
99
94
"A simple string"
100
- to string! debase /base "412073696d706c6520737472696e67" 16
95
+ to string! debase "412073696d706c6520737472696e67" 16
101
96
--test-- "debase 16 2"
102
97
--assert strict-equal?
103
98
"A multi-line\nstring"
104
- to string! debase /base "41206d756c74692d6c696e655c6e737472696e67" 16
99
+ to string! debase "41206d756c74692d6c696e655c6e737472696e67" 16
105
100
106
101
===end-group===
107
102
@@ -110,12 +105,12 @@ Rebol [
110
105
--test-- "debase 2 1"
111
106
--assert strict-equal?
112
107
"^(04)^(01) "
113
- to string! debase /base "0000010000000001" 2
108
+ to string! debase "0000010000000001" 2
114
109
115
110
===end-group===
116
111
117
112
if any [
118
- not error? err: try [enbase /base "a" 85 ]
113
+ not error? err: try [enbase "a" 85 ]
119
114
err/id <> 'feature-na
120
115
][
121
116
base85-str-tests: [
@@ -157,25 +152,25 @@ if any [
157
152
158
153
159
154
===start-group=== "enbase-85"
160
- --test-- "enbase/base str 85"
155
+ --test-- "enbase str 85"
161
156
foreach [inp out] base85-str-tests [
162
- --assert out = enbase /base inp 85
157
+ --assert out = enbase inp 85
163
158
]
164
159
===end-group===
165
160
166
161
===start-group=== "debase-85"
167
- --test-- "debase/base str 85"
162
+ --test-- "debase str 85"
168
163
foreach [out inp] base85-str-tests [
169
- --assert out = probe to-string debase /base inp 85
164
+ --assert out = to-string debase inp 85
170
165
]
171
166
--test-- "debase 85 with spaces"
172
167
foreach [out inp] base85-spaces-tests [
173
- --assert out = debase /base inp 85
168
+ --assert out = debase inp 85
174
169
]
175
170
--test-- "invalid debase85 input"
176
- --assert error? try [debase /base "abcx" 85 ]
177
- --assert error? try [debase /base "~>" 85 ]
178
- --assert error? try [debase /base {s8W-"} 85 ]
171
+ --assert error? try [debase "abcx" 85 ]
172
+ --assert error? try [debase "~>" 85 ]
173
+ --assert error? try [debase {s8W-"} 85 ]
179
174
===end-group===
180
175
]
181
176
0 commit comments