add base64url support
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include "array.h"
|
||||
#include "textcode.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <write12.h>
|
||||
|
||||
array a;
|
||||
|
||||
@@ -26,5 +29,11 @@ int main() {
|
||||
buf[n]=0;
|
||||
puts(buf);
|
||||
|
||||
assert(fmt_base64(buf,"fnörd",6)==8 && !memcmp(buf,"Zm7DtnJk",8));
|
||||
assert(scan_base64("Zm7DtnJk",buf,&n)==8 && n==6 && !memcmp(buf,"fnörd",6));
|
||||
assert(fmt_base64(buf,"x",1)==4 && !memcmp(buf,"eA==",4));
|
||||
assert(scan_base64("eA====",buf,&n)==4 && n==1 && buf[0]=='x');
|
||||
assert(fmt_base64url(buf,"\xef\xbf\xbdx",4)==6 && !memcmp(buf,"77-9eA",6));
|
||||
assert(scan_base64url("77-9eA",buf,&n)==6 && n==4 && !memcmp(buf,"\xef\xbf\xbdx",4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user