~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/serialize/check_length.sh

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
failed=0
4
 
 
5
 
if test -z $BINDIR ; then
6
 
  BINDIR=.
7
 
fi
8
 
 
9
 
check_encode () {
10
 
    bytes=`${BINDIR}/length --hex --encode $1`
11
 
    shift
12
 
    expected="$@"
13
 
    if test "$bytes" != "$expected"; then
14
 
        failed=`expr $failed + 1`
15
 
        echo "Got '$bytes' but expected '$expected'"
16
 
    fi
17
 
}
18
 
 
19
 
check_invertible () {
20
 
    bytes=`${BINDIR}/length --encode $value`
21
 
    result=`${BINDIR}/length --decode $bytes`
22
 
    if test $result -ne $value; then
23
 
        failed=`expr $failed + 1`
24
 
        echo "Got $result but expected $value"
25
 
    fi
26
 
}
27
 
 
28
 
# check that the encoding is correct
29
 
check_encode 2     0x2
30
 
check_encode 255   0xff
31
 
check_encode 256   0x0 0x0 0x1
32
 
check_encode 65535 0x0 0xff 0xff
33
 
 
34
 
# Check that we can decode what we have encoded
35
 
for value in 2 255 256 65535 65536 \
36
 
    `expr 16 "*" 65536` \
37
 
    `expr 16 "*" 65536 + 255`
38
 
do
39
 
    check_invertible $value
40
 
done
41
 
 
42
 
exit $failed