summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c++/Makefile.in4
-rw-r--r--c++/examples/Makefile.in6
-rw-r--r--c++/examples/expected.out82
-rwxr-xr-xc++/examples/testexamples.sh55
4 files changed, 144 insertions, 3 deletions
diff --git a/c++/Makefile.in b/c++/Makefile.in
index 0c25a90..d7d6558 100644
--- a/c++/Makefile.in
+++ b/c++/Makefile.in
@@ -15,7 +15,9 @@ srcdir=@srcdir@
@COMMENCE@
# Subdirectories in build-order (not including `examples')
-SUBDIRS=src test
+# We include examples now since those are our "tests" at this time. We
+# can remove it later.
+SUBDIRS=src test examples
##############################################################################
## T A R G E T S
diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in
index eb67898..2a928b6 100644
--- a/c++/examples/Makefile.in
+++ b/c++/examples/Makefile.in
@@ -27,14 +27,16 @@ TEST_OBJ=$(TEST_SRC:.cpp=.lo)
## These are the programs that `make all' or `make tests' will build and which
## `make check' will run. List them in the order they should be run.
-TEST_PROGS=$(TEST_SRC:.cpp=)
+PROGS=$(TEST_SRC:.cpp=)
+
+TEST_SCRIPTS=testexamples.sh
## These are the files that `make clean' (and derivatives) will remove from
## this directory.
CLEAN=
## How to build the programs... they all depend on the Fortran & C hdf5 libraries
-$(TEST_PROGS): $(LIB) $(LIBHDF5)
+$(PROGS): $(LIB) $(LIBHDF5)
compound: compound.lo
@$(LT_LINK_EXE) $(CXXFLAGS) -o $@ compound.lo $(LDFLAGS) $(LIB) $(LIBS) $(LIBHDF5)
diff --git a/c++/examples/expected.out b/c++/examples/expected.out
new file mode 100644
index 0000000..dc7a97d
--- /dev/null
+++ b/c++/examples/expected.out
@@ -0,0 +1,82 @@
+Data set has INTEGER type
+Little endian byte ordering (0)
+Data size is 4
+rank 2, dimensions 5 x 6
+0 0 0 0 0 0 0
+0 0 0 0 0 0 0
+0 0 0 0 0 0 0
+3 4 5 6 0 0 0
+4 5 6 7 0 0 0
+5 6 7 8 0 0 0
+0 0 0 0 0 0 0
+53 1 2 0 3 4 0 5 6 0 7 8
+0 9 10 0 11 12 0 13 14 0 15 16
+0 17 18 0 19 20 0 21 22 0 23 24
+0 0 0 59 0 61 0 0 0 0 0 0
+0 25 26 0 27 28 0 29 30 0 31 32
+0 33 34 0 35 36 67 37 38 0 39 40
+0 41 42 0 43 44 0 45 46 0 47 48
+0 0 0 0 0 0 0 0 0 0 0 0
+Normalization type is H5T_NORM_IMPLIED (0)
+
+Field c :
+1 0.5 0.333333 0.25 0.2 0.166667 0.142857 0.125 0.111111 0.1
+
+Field a :
+0 1 2 3 4 5 6 7 8 9
+
+Field b :
+0 1 4 9 16 25 36 49 64 81
+1 1 1 3 3
+1 1 1 3 3
+1 1 1 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+dataset rank = 2, dimensions 10 x 5
+chunk rank 2dimensions 2 x 5
+
+Dataset:
+1 1 1 3 3
+1 1 1 3 3
+1 1 1 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+2 0 0 0 0
+
+Third column:
+1
+1
+1
+0
+0
+0
+0
+0
+0
+0
+
+Chunk:
+1 1 1 0 0
+2 0 0 0 0
+dataset "/Data/Compressed_Data" is open
+dataset "/Data_new/Compressed_Data" is open
+
+Iterating over elements in the file
+Name : Data
+Name : Data_new
+
+Unlinking...
+"Data" is unlinked
+
+Iterating over elements in the file again
+Name : Data_new
+
diff --git a/c++/examples/testexamples.sh b/c++/examples/testexamples.sh
new file mode 100755
index 0000000..54141c0
--- /dev/null
+++ b/c++/examples/testexamples.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+CMP='cmp -s'
+DIFF='diff -c'
+
+nerrors=0
+verbose=yes
+
+actual=sample.out
+expect=expected.out
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+TESTING()
+{
+ SPACES=" "
+ echo "Testing $* $SPACES" |cut -c1-70 |tr -d '\012'
+}
+
+TESTING C++ Examples
+
+(
+ ./create
+ ./readdata
+ ./writedata
+ ./compound
+ ./extend_ds
+ ./chunks
+ ./h5group
+) > $actual
+
+if $CMP $expect $actual; then
+ echo " PASSED"
+else
+ echo "*FAILED*"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual | sed 's/^/ /'
+fi
+
+# Clean up output file
+if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual
+fi
+
+if test $nerrors -eq 0 ; then
+ echo "All tests passed."
+fi
+
+exit $nerrors