1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
## -*- sh -*-
## autoptr.test - Testing AutoPtr class
##
## $Id: autoptr.test,v 1.3 2005/03/19 17:19:24 vlg Exp $
# Common definitions
self="[autoptr] "
if test -z "$srcdir" ; then
srcdir=`echo "$0" | sed 's,[^/]*$,,'`
test "$srcdir" = "$0" && srdir=.
test -z "$srcdir" && srcdir=.
test "${VERBOSE+set}" != set && VERBOSE=1
fi
. $srcdir/defs
# this is the output we should expect to see
cat <<\EOF >ok
*** Testing memory allocation/deallocation ***
Calling leak_mem()
-- leak_mem --
-- VParent::VParent --
I'm a VParent class!
copies on heap still allocated: 1 ... ok
Calling no_leak_mem()
-- no_leak_mem --
-- VParent::VParent --
I'm a VParent class!
-- VParent::~VParent --
copies on heap still allocated: 0 ... ok
-- VParent::VParent --
-- VParent::~VParent --
*** Testing ownership transfer by function ***
-- VParent::VParent --
-- VParent::VParent --
-- VParent::~VParent --
-- VParent::VParent --
-- VParent::~VParent --
-- VParent::~VParent --
*** Testing ownership transfer ***
-- VParent::VParent --
Uninitialized AutoPtr is a '0' pointer ... ok
Ownership transfer by assignment ... ok
Ownership transfer by copy constructor ... ok
-- VParent::~VParent --
*** Testing inheritance handling ***
-- VParent::VParent --
-- VParent::VParent --
-- VParent::~VParent --
-- VParent::~VParent --
ok
*** Testing AutoPtrArray handling ***
-- VParent::VParent --
-- VParent::VParent --
-- VParent::VParent --
-- VParent::VParent --
-- VParent::VParent --
-- VParent::VParent --
-- VParent::~VParent --
-- VParent::~VParent --
-- VParent::~VParent --
-- VParent::~VParent --
-- VParent::~VParent --
-- VParent::~VParent --
ok
Test done!
EOF
# Unexpected output
cat <<\EOF >errok
EOF
# Run test
RUNTEST="${top_builddir}/tests/autoptr_test"
$RUNTEST 2> err | tee -i out >&2
# Test against expected output
if ${CMP} -s out ok; then
:
else
echo "ok:" >&2
cat ok >&2
exit 1
fi
# Mungle error output to remove leading directories, 'lt-' or
# trailing '.exe'
sed -e "s,^[^:]*[lt-]*autoptr_test[.ex]*:,autoptr_test;," err >sederr && mv sederr err
# Show stderr if doesn't match expected output if VERBOSE=1
if "$CMP" -s err errok; then
:
else
echo "err:" >&2
cat err >&2
echo "errok:" >&2
cat errok >&2
exit 1
fi
|