Browse Source

a few more tests

master
Felix von Leitner 19 years ago
parent
commit
3744795561
  1. 26
      test/b64decode.c
  2. 24
      test/b64encode.c
  3. 14
      test/byte_copy.c
  4. 7
      test/urlencode.c

26
test/b64decode.c

@ -0,0 +1,26 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);
unsigned int dlen;
scan_base64(c,buf,&dlen);
buffer_put(buffer_1,buf,dlen);
buffer_putnlflush(buffer_1);
}
main(int argc,char* argv[]) {
int i;
for (i=1; i<argc; ++i) {
b64encode(argv[i]);
}
if (argc<2) {
char src[1024];
int len=read(0,src,sizeof(src)-1);
if (len==-1) return(1);
src[len]=0;
b64encode(src);
}
return 0;
}

24
test/b64encode.c

@ -0,0 +1,24 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);
buffer_put(buffer_1,buf,fmt_base64(buf,c,strlen(c)));
buffer_putnlflush(buffer_1);
}
main(int argc,char* argv[]) {
int i;
for (i=1; i<argc; ++i) {
b64encode(argv[i]);
}
if (argc<2) {
char src[1024];
int len=read(0,src,sizeof(src)-1);
if (len==-1) return(1);
src[len]=0;
b64encode(src);
}
return 0;
}

14
test/byte_copy.c

@ -0,0 +1,14 @@
#include "byte.h"
#include <write12.h>
int main() {
char buf[4096];
__write1("both aligned\n");
byte_copy(buf,16,"this is a test!\n");
__write1("destination aligned, source unaligned\n");
byte_copy(buf,1000,buf+1);
__write1("destination unaligned, source aligned\n");
byte_copy(buf+1,1000,buf);
__write1("both unaligned\n");
byte_copy(buf+1,1000,buf+3);
}

7
test/urlencode.c

@ -13,5 +13,12 @@ main(int argc,char* argv[]) {
for (i=1; i<argc; ++i) {
urlencode(argv[i]);
}
if (argc<2) {
char src[1024];
int len=read(0,src,sizeof(src)-1);
if (len==-1) return(1);
src[len]=0;
urlencode(src);
}
return 0;
}

Loading…
Cancel
Save