## -*- 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