1169d9 | 2004-05-02 | Martin Nilsson | | START_MARKER
dnl $Id: testsuite.in,v 1.15 2004/05/02 18:26:43 nilsson Exp $
|
f5d023 | 2004-02-23 | Martin Nilsson | |
dnl - ADT.BitBuffer
test_do( add_constant( "B", ADT.BitBuffer() ) )
test_eq( B->drain(), "" )
test_eq( B->feed(""), B )
test_eval_error( B->feed("\400") )
test_eq( B->drain(), "" )
test_eq( sizeof(B), 0 )
test_eq( B->put(3,3), B )
test_eq( sizeof(B), 3 )
test_eq( B->get(2), 1 )
test_eq( sizeof(B), 1 )
test_eq( B->drain(), "" )
test_eq( B->feed("foo"), B )
test_eq( sizeof(B), 3*8+1 )
test_eq( B->drain(), "\xb3""7\xb7" )
test_eq( sizeof(B), 1 )
|
48236f | 2004-05-01 | Martin Nilsson | | test_eq( B->get(1), 1 )
|
01432c | 2004-05-01 | Marcus Agehall | |
|
48236f | 2004-05-01 | Martin Nilsson | | test_eq( B->feed("\xff\0"), B )
test_eq( B->get(7), 127 )
|
01432c | 2004-05-01 | Marcus Agehall | | test_eq( B->get(4), 8 )
test_eq( B->get(5), 0 )
|
fee563 | 2004-05-01 | Martin Nilsson | | test_eq( B->put1(9), B )
test_eq( B->get(9), 0b111111111 )
test_eq( B->put1(1), B )
test_eq( B->put0(4), B )
test_eq( sizeof(B), 5 )
test_eq( B->put1(4), B )
test_eq( sizeof(B), 9 )
test_eq( B->get(1), 1 )
test_eq( B->drain(), "\17" )
test_eq( sizeof(B), 0 )
test_eq( B->drain(), "" )
test_eval_error( B->get(1) )
|
f5d023 | 2004-02-23 | Martin Nilsson | |
test_do( add_constant( "B" ) )
|
f0a91f | 2002-08-03 | Martin Nilsson | |
|
75457f | 2002-10-19 | Martin Nilsson | | dnl - ADT.History
test_eq(sizeof(ADT.History(2)),0)
test_do(add_constant("adth", ADT.History(2)))
test_eq(adth->get_maxsize(),2)
test_any([[
adth->push(17);
return sizeof(adth);
]], 1)
test_any([[
adth->push(18);
return sizeof(adth);
]], 2)
test_any([[
adth->push(19);
return sizeof(adth);
]], 2)
test_eq(adth->get_latest_entry_num(),3)
test_eq(adth->get_first_entry_num(),2)
test_eval_error(return adth[0])
test_eval_error(return adth[1])
test_eq(adth[2],18)
test_eq(adth[3],19)
test_eq(adth[-1],19)
test_eq(adth[-2],18)
test_eval_error(return adth[-3])
test_do( adth->set_maxsize(4) )
test_eq(adth->get_maxsize(),4)
test_eq(sizeof(adth),2)
test_eq(adth[-1],19)
test_eq(adth[-2],18)
test_eval_error(return adth[-3])
test_do( adth->push(20); adth->push(21); adth->push(22); )
test_eq(adth[3],19)
test_eq(adth[6],22)
test_do( adth->flush() )
test_eq(adth->get_latest_entry_num(),6)
test_eq(adth->get_first_entry_num(),0)
test_do( adth->set_maxsize(0) )
test_do( adth->push(23) )
test_eq(sizeof(adth),0)
|
dcc2da | 2002-10-19 | Martin Nilsson | | test_do( adth->set_maxsize(2) )
test_eq(adth->query_no_adjacent_duplicates(), 0)
test_do( adth->set_no_adjacent_duplicates(1), 0)
test_do( adth->push(24) )
test_do( adth->push(25) )
test_do( adth->push(25) )
test_do( adth->push(25) )
test_eq(adth[-2],24)
test_do( adth->set_no_adjacent_duplicates(0), 0)
test_do( adth->push(26) )
test_do( adth->push(26) )
test_eq(adth[-2],26)
test_do( adth[-1]=27 )
test_equal(indices(adth),[[ ({9,10}) ]])
test_equal(values(adth),[[ ({26,27}) ]])
|
75457f | 2002-10-19 | Martin Nilsson | | test_do(add_constant("adth"))
|
dcc2da | 2002-10-19 | Martin Nilsson | |
|
75457f | 2002-10-19 | Martin Nilsson | | dnl - ADT.Stack
|
79f953 | 2002-08-02 | Martin Nilsson | |
test_any([[
object s = ADT.Stack();
s->push(1);
return s->pop();
]], 1)
|
76719c | 2002-08-04 | Martin Nilsson | | test_eval_error(return ADT.Stack()->pop())
|
79f953 | 2002-08-02 | Martin Nilsson | | test_any([[
|
76719c | 2002-08-04 | Martin Nilsson | | object s = ADT.Stack();
for(int i; i<1000; i++)
s->push(i);
for(int i; i<1000; i++)
s->pop();
for(int i; i<1000; i++)
s->push(i);
return s->pop();
]], 999)
test_equal_any([[
|
79f953 | 2002-08-02 | Martin Nilsson | | object s = ADT.Stack();
s->push(2);
s->push(3);
s->push(4);
|
76719c | 2002-08-04 | Martin Nilsson | | s->pop();
return s->pop(2);
]], ({2,3}) )
|
79f953 | 2002-08-02 | Martin Nilsson | |
test_any([[
object s = ADT.Stack();
s->push(5);
return s->top();
]], 5)
|
f0a91f | 2002-08-03 | Martin Nilsson | |
|
76719c | 2002-08-04 | Martin Nilsson | | test_eval_error(return ADT.Stack()->top())
test_any([[
object s = ADT.Stack();
for(int i; i<1000; i++)
s->push(i);
for(int i; i<1000; i++)
s->quick_pop();
for(int i; i<1000; i++)
s->push(i);
return sizeof(s);
]], 1000)
test_any([[
object s = ADT.Stack();
for(int i; i<1000; i++)
s->push(i);
return sizeof(s);
]], 1000)
test_any([[
object s = ADT.Stack();
s->push(3);
s->reset();
return sizeof(s);
]], 0)
test_any([[
object s = ADT.Stack();
s->set_stack( "1234"/1 );
s->push("5");
return s->pop()+sizeof(s);
]], "54")
test_any([[
object s = ADT.Stack();
s->push("a");
s->push("b");
return values(s)*",";
]], [["a,b"]])
test_any([[
object s = ADT.Stack();
s->set_stack( "1234"/1 );
object t = ADT.Stack();
t->push("5");
return values(s+t)*"";
]], "12345")
|
f0a91f | 2002-08-03 | Martin Nilsson | |
|
a416ae | 2003-01-04 | Martin Nilsson | | dnl - ADT.Struct
test_do([[
class Test {
inherit ADT.Struct;
Item one = Byte();
Item two = Word(2);
Item three = Chars(3);
};
add_constant("Test", Test);
]])
test_equal( sizeof(Test()), 6 )
test_equal( indices(Test()), ({ "one", "two", "three" }) )
test_equal( values(Test()), ({ 0, 2, "\0\0\0" }) )
test_eq( (string)Test("123456"), "123456" )
test_eq( (string)Test("1234567"), "123456" )
test_equal( (array)Test("123456"), ({ "1", "23", "456" }) )
test_any([[
Test test=Test();
test->one=1;
test->two=3;
test->three="klm";
return (string)test;
]], "\1\0\3klm")
test_any([[
Test test=Test();
test["one"]=1;
test["two"]=3;
test["three"]="klm";
return (string)test;
]], "\1\0\3klm")
test_any([[
Test test=Test();
return sprintf("%O%O%O", test->one, test->two, test->three);
]], "02\"\\0\\0\\0\"")
test_any([[
Test test=Test();
return sprintf("%O%O%O", test["one"], test["two"], test["three"]);
]], "02\"\\0\\0\\0\"")
test_any([[
Test test=Test();
test->decode("123456");
return test->encode();
]], "123456")
test_eval_error([[
Test test=Test();
test->one=-1;
]])
test_eval_error([[
Test test=Test();
test->one=256;
]])
test_eval_error([[
Test test=Test();
test->two=-1;
]])
test_eval_error([[
Test test=Test();
test->two=65536;
]])
test_eval_error([[
Test test=Test();
test->three="";
]])
test_eval_error([[
Test test=Test();
test->three="xx\0777";
]])
test_do( add_constant("Test") )
test_do([[
class Test {
inherit ADT.Struct;
};
add_constant( "Test", Test );
]])
test_equal( sizeof(Test()), 0 )
test_equal( indices(Test()), ({}) )
test_equal( values(Test()), ({}) )
test_equal( (string)Test(), "" )
test_do( Test()->decode("123") )
test_do( Test()->decode("") )
test_do( add_constant("Test") )
test_any([[
class Test {
inherit ADT.Struct;
Item one = Byte(1);
Item two = Word();
Item three = Chars(3, "klm");
};
return (string)Test();
]], "\1\0\0klm")
|
82c651 | 2003-07-04 | Martin Nilsson | | test_any([[
class Test {
inherit ADT.Struct;
Item a = Word(0x1234);
Item b = Drow(0x1234);
Item c = Long(0x12345678);
Item d = Gnol(0x12345678);
};
return (string)Test();
]], "\22""44\22\22""4VxxV4\22");
|
d797a3 | 2003-10-22 | Martin Nilsson | | test_do([[
class Test {
inherit ADT.Struct;
Item a = Varchars();
Item b = Varchars(1,3);
Item c = Chars(1);
};
add_constant("Test",Test);
]])
test_eq( (string)Test("a\0b\0c"), "a\0b\0c" )
test_eq( (string)Test("a\0b\0c\0"), "a\0b\0c" )
test_eval_error( Test("a\0\0c") )
test_eval_error( Test("a\0bbbb\0c") )
test_eval_error( Test("a\0b\0") )
test_eq( sizeof(Test("aa\0b\0c")), 6 )
|
b5cd4d | 2003-12-01 | Martin Nilsson | | test_do( add_constant("Test"); )
|
a416ae | 2003-01-04 | Martin Nilsson | |
|
75457f | 2002-10-19 | Martin Nilsson | | dnl - ADT.Table
|
f0a91f | 2002-08-03 | Martin Nilsson | |
test_true(ADT.Table.table(
({ ({ "a", "b", 42 }),
({ "c", "b", 41 }),
({ "a", "a", 76 }) }),
({ "X", "Y", "z" }))->select("x", 2)->sum("Z")->distinct(0)->rsort("X")
->rename(0, "fOo")->sort("foO")->cast("array"),
({ ({ "a", 118 }),
({ "c", 41 }) }))
|
947c78 | 2003-03-08 | Martin Nilsson | |
dnl - ADT.struct
define(test_put,[[
test_any([[
object s=ADT.struct();
s->$1;
return s->pop_data()+"\7777"+s->pop_data();
]],$2"\7777")
test_any_equal([[
object s=ADT.struct($2);
return s->$3;
]], $4)
]])
test_put(add_data("hej"), "hej", get_fix_string(3), "hej")
test_put(put_uint(17,1), "\21", get_uint(1), 17)
test_put(put_uint(17,2), "\0\21", get_uint(2), 17)
test_put(put_var_string("hej",1), "\3hej", get_var_string(1), "hej")
cond([[ master()->resolv("Gmp")->mpz ]],[[
test_put(put_bignum(Gmp.mpz(123456789)), "\0\4\7[\315\25", get_bignum(),
Gmp.mpz(123456789))
]])
test_put(put_fix_string("hej"), "hej", get_fix_string(3), "hej")
test_put(put_fix_uint_array(({1,2,3,4}), 1), "\1\2\3\4", get_fix_uint_array(1,4),
({1,2,3,4}))
test_put(put_var_uint_array(({1,2,3,4}),1,1), "\4\1\2\3\4", get_var_uint_array(1,1),
({1,2,3,4}))
test_any([[
object s=ADT.struct("abcdefghijk");
return s->get_fix_string(3)+" "+s->contents()+" "+s->get_fix_string(3);
]], "abc defghijk def")
test_any([[
object s=ADT.struct("abcdefghijk");
return s->get_fix_string(3)+" "+s->get_rest();
]], "abc defghijk")
test_eval_error([[
object s=ADT.struct("abc");
s->get_rest();
s->get_fix_string(1);
]])
|
1169d9 | 2004-05-02 | Martin Nilsson | | END_MARKER
|