]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/base64/base64-tests.factor
factor: add newlines to .factor files
[factor.git] / basis / base64 / base64-tests.factor
index a63f6b3bc63e900f065e309775536b5dfb2d3159..ef7e809c8836689bd89f170d594793e760683d0a 100644 (file)
@@ -1,5 +1,7 @@
-USING: base64 io.encodings.ascii io.encodings.string kernel
-sequences splitting strings tools.test ;
+USING: base64 byte-arrays io.encodings.ascii io.encodings.string
+kernel sequences splitting strings tools.test ;
+
+{ t } [ 256 <iota> >byte-array dup >base64 base64> = ] unit-test
 
 { "abcdefghijklmnopqrstuvwxyz" } [ "abcdefghijklmnopqrstuvwxyz" ascii encode >base64 base64> ascii decode
 ] unit-test
@@ -39,3 +41,16 @@ sequences splitting strings tools.test ;
     "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY"
     "." split [ base64> ] map
 ] unit-test
+
+{ "01a+b/cd" } [ "\xd3V\xbeo\xf7\x1d" >base64 "" like ] unit-test
+{ "\xd3V\xbeo\xf7\x1d" } [ "01a+b/cd" base64> "" like ] unit-test
+
+{ "01a-b_cd" } [ "\xd3V\xbeo\xf7\x1d" >urlsafe-base64 "" like ] unit-test
+{ "\xd3V\xbeo\xf7\x1d" } [ "01a-b_cd" urlsafe-base64> "" like ] unit-test
+
+{ "eyJhIjoiYmNkIn0" }
+[ "{\"a\":\"bcd\"}" >urlsafe-base64-jwt >string ] unit-test
+
+{ "{\"a\":\"bcd\"}" }
+[ "{\"a\":\"bcd\"}" >urlsafe-base64-jwt urlsafe-base64> >string ] unit-test
+