Forumwarz is the first "Massively Single-Player" online RPG completely built around Internet culture.

You are currently looking at Flamebate, our community forums. Players can discuss the game here, strategize, and role play as their characters.

You need to be logged in to post and to see the uncensored versions of these forums.

Log in or Learn about Forumwarz

Role Playing
Switch to Civil Discussion Role-Playing

Viewing a Post

Strykerblade

Avatar: 96387 Mon Feb 02 18:04:35 -0500 2009

[De Laiceps]

Level 23 Troll

“Dick in a Box”

Log in to see images!#!/usr/bin/env python

‘Specific unit tests for the char_audit program’

import re

import sys

#import dbg

import tester

#d = dbg.Debug(2, sys.argv[0][:-3]) #The name without the .py

if len(sys.argv) != 1:

raise ValueError, ‘Error: argument supplied. Invoke with no argument values’

uut = tester.UUT(‘python char_audit.py ’, nil_output_match = ’^\r?$’Log in to see images!

#The ”\r?” in the above match string allows for the extra carriage return

#character that DOS/Windows Python emits.

#d.trace(1, ‘uut is %s’ % uut)

#uut.re_flags = re.MULTILINE

#Test response to invalid arguments

err_re = ‘^(.*\n)*ErrorLog in to see images!.*\n)*Usage:’ #To check for Error and Usage messages

ret_re = ‘^1$’ #To check return code is 1

print uut.hit(args = ’’,

errm = err_re,

retm = ret_re,

label = ‘No arguments’Log in to see images!

print uut.hit(args = ‘file file’,

errm = err_re,

retm = ret_re,

label = ‘File specified twice’Log in to see images!

print uut.hit(args = ‘file1 file2 file3’,

errm = err_re,

retm = ret_re,

label = ‘File specified three times’Log in to see images!

print uut.hit(args = ’- file1’,

errm = err_re,

retm = ret_re,

label = ‘Stdin and file specified’Log in to see images!

print uut.hit(args = ‘file1 -’,

errm = err_re,

retm = ret_re,

label = ‘File and stdin specified’Log in to see images!

print uut.hit(args = ’- -max’,

errm = err_re,

retm = ret_re,

label = ‘No max value specified’Log in to see images!

print uut.hit(args = ’- -max -5’,

errm = err_re,

retm = ret_re,

label = ‘Negative max specified’Log in to see images!

print uut.hit(args = ’- -max 1.1’,

errm = err_re,

retm = ret_re,

label = ‘Non-integer max specified’Log in to see images!

print uut.hit(args = ’- -max 256’,

errm = err_re,

retm = ret_re,

label = ‘Max too high’Log in to see images!

print uut.hit(args = ’~~’,

errm = ‘Cannot open(.*\n)*Usage:’,

retm = ret_re,

label = ‘Nonexistent file’Log in to see images!

#Test response to valid arguments

source = sys.argv[0] #Provide the name of a file to read

print uut.hit(args = ’- -max 0’,

label = ‘Lowest permitted max’Log in to see images!

print uut.hit(args = ’- -max 255’,

label = ‘Highest permitted max’Log in to see images!

print uut.hit(args = source + ’ -max 255’,

outm = ‘^(.*\n)*126: ’, #Code 126 for a tilde (~)

label = ‘Search for any tildes in %s’ % source)

print uut.hit(args = source,

outm = ‘^(.*\n)*9: 2’,

label = ‘Search for tabs’Log in to see images! #Dummy tabs: 1 2

#Test runs

print uut.hit(args = ’-’,

label = ‘No input’Log in to see images!

print uut.hit(args = ’-’,

input = ‘a’,

label = ‘One non-audited character’Log in to see images!

print uut.hit(args = ’-’,

input = ‘ab’,

label = ‘Two non-audited characters’Log in to see images!

print uut.hit(args = ’-’,

input = ’\x00’,

outm = ‘^0: 1(\r?)\n$’,

label = ‘One null character’Log in to see images!

print uut.hit(args = ’-’,

input = ’\x01\x01’,

outm = ‘^1: 2(\r?)\n$’,

label = ‘Two \\x01 characters’Log in to see images!

print uut.hit(args = ’-’,

input = ’\x01\x02’,

outm = ‘^1: 1(\r?)\n2: 1(\r?)\n$’,

label = ’\\x01 & \\x02’Log in to see images!

print uut.hit(args = ’- -max 255’,

input = ’ 000000000000aa’,

outm = ‘^32: 1(\r?)\n48: 12(\r?)\n97: 2(\r?)\n$’,

label = ‘Mixture of printable audited’Log in to see images!

print uut.hit(args = ‘-max 255 -’,

input = ’\x0a\x0a\xff\t\t\x00 \t’,

outm = ‘^0: 1(\r?)\n9: 3(\r?)\n10: 2(\r?)\n32: 2(\r?)\n255: 1(\r?)\n$’,

label = ‘Null, 0xff, two spaces, two Unix newlines and three tabs’Log in to see images!

print uut.hit(args = ’-’,

input = ’\t\t’,

outm = ‘9: 2’,

label = ‘Count tabs’Log in to see images!

#Now create a new UUT with “python -u” (turns off stdin preprocessing)

uut = tester.UUT(‘python -u char_audit.py ‘Log in to see images!

#d.trace(1, ‘uut is %s’ % uut)

print uut.hit(args = ’-’,

input = ’\r\n\r\n\r\n’,

outm = ‘^10: 3(\r?)\n13: 3(\r?)\n\(13,10\): 3(\r?)\n$’,

#Note above ’\’ before ‘(’ and ‘Log in to see images!

label = ‘Three CRLFs’

)

/*

* Read an asn.1 object id element and convert to binary

*/

unsigned long asn1objelrd (unsigned char **pp0) {

/* Advance the pointer past this element and return the element’s value */

unsigned long tot;

unsigned char *pp;

pp = *pp0;

tot = 0;

while (*pp & 0x80) {

tot = (tot << 7) + (*pp++ & 0x7f);

}

tot = (tot << 7) + *pp++;

*pp0 = pp;

return tot;

}

To write an object id element.

/*

* Write as asn.1 object id element.

*/

int asn1objelwr (unsigned char *dest0, unsigned long val0) {

/* Write an object id element, converting from numeric ascii to

binary. */

register int i;

int numbytes;

unsigned long val1, mask;

unsigned char *p1;

val1 = val0;

/* We can store seven bits of the number in each output octcet,

leaving the msbit as zero for end of number or one to indicate

that more octets are to follow. */

/* The value is to be written msbit first. For a maximum sized value

of 32 bits there will be 32/7 rounded up, ie 5 octects in the output. */

mask = ~ 0x7f; /* Lower 7 bits only set to zero. */

if ((val1 & mask) == 0) numbytes=1;

else if ((val1 & (mask=mask<<7)) == 0) numbytes=2;

else if ((val1 & (mask=mask<<7)) == 0) numbytes=3;

else if ((val1 & (mask=mask<<7)) == 0) numbytes=4;

else numbytes=5;

mask = 0; /* Now use mask to indicate whether more bytes are required. */

/* Start from the further end, writing the bytes as required. */

for (i=0, p1 = dest0 + numbytes; i<numbytes; i++) {

*—p1 = (unsigned char) ((val1 & 0x7f) | mask);

mask = 0x80; /* Change mask for all bytes before the first. */

val1 = val1 >> 7;

}

return numbytes;

}

****ty thread is…...more ****tified.

YAY FOR ME!


IMMA CHARGIN’ MAH LAZOR!!!

O o

/¯________________________

| IMMA FIRIN’ MAH LAZOR!!!

\_¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

SHOOP DA WHOOP!!!

Internet Delay Chat
Have fun playing!
To chat with other players, you must Join Forumwarz or Log In now!