
use Data::Dumper;
sub test_encode {
	my $object = shift;
	my $string = shift;
	my $expect = shift;
	
	my $result = $object->encode($string);

	
	if (ref($expect) eq 'ARRAY') {
		my $name = ref($object).': '.$expect->[0].' for '.$string;
		unless (ref($result) eq 'ARRAY'
			&& scalar(@$result) == scalar(@$expect)) {
			fail($name.' length differs'.scalar(@$result));
			return;
		}
		for (0..(scalar @$expect -1)) {		
			next if (! defined $expect->[$_] && ! defined $result->[$_]);	
			unless ($expect->[$_] eq $result->[$_]) {
				fail($name.' got '. $result->[$_]);
			}
		}
		pass($name);
	} else {
		my $name = ref($object).': '.$expect.' for '.$string;
		is($result,$expect,$name);
	}
}

1;