summaryrefslogtreecommitdiffstats
path: root/c++/test/ttypes.cpp
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /c++/test/ttypes.cpp
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'c++/test/ttypes.cpp')
-rw-r--r--c++/test/ttypes.cpp339
1 files changed, 171 insertions, 168 deletions
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp
index b8846f4..7411e37 100644
--- a/c++/test/ttypes.cpp
+++ b/c++/test/ttypes.cpp
@@ -25,17 +25,17 @@ using std::cerr;
using std::endl;
#include <string>
-#include "H5Cpp.h" // C++ API header file
+#include "H5Cpp.h" // C++ API header file
using namespace H5;
#include "h5test.h"
-#include "h5cpputil.h" // C++ utilility header file
+#include "h5cpputil.h" // C++ utilility header file
/*
* Offset from alinged memory returned by malloc(). This can be used to test
* that type conversions handle non-aligned buffers correctly.
*/
-#define ALIGNMENT 1
+#define ALIGNMENT 1
/*
* Define if you want to test alignment code on a machine that doesn't
@@ -50,35 +50,34 @@ using namespace H5;
#define H5T_FRIEND
#include "H5Tpkg.h"
#endif
-#define SET_ALIGNMENT(TYPE,VAL) \
- H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL)
+#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL)
#endif
- /* #include "H5Tpkg.h"
+/* #include "H5Tpkg.h"
*/
-const char *FILENAME[] = {
- "dtypes1.h5",
- "dtypes2.h5",
- "dtypes3.h5",
- "dtypes4.h5",
- NULL
-};
+const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", "dtypes4.h5", NULL};
/*
* Count up or down depending on whether the machine is big endian or little
* endian. If local variable `endian' is H5T_ORDER_BE then the result will
* be I, otherwise the result will be Z-(I+1).
*/
-#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1))
+#define ENDIAN(Z, I) (H5T_ORDER_BE == endian ? (I) : (Z) - ((I) + 1))
-
-typedef enum flt_t {
- FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER
-} flt_t;
+typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t;
typedef enum int_t {
- INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT,
- INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER
+ INT_CHAR,
+ INT_UCHAR,
+ INT_SHORT,
+ INT_USHORT,
+ INT_INT,
+ INT_UINT,
+ INT_LONG,
+ INT_ULONG,
+ INT_LLONG,
+ INT_ULLONG,
+ INT_OTHER
} int_t;
typedef struct {
@@ -88,7 +87,6 @@ typedef struct {
double d;
} src_typ_t;
-
/*-------------------------------------------------------------------------
* Function: test_classes
*
@@ -100,7 +98,8 @@ typedef struct {
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_classes()
+static void
+test_classes()
{
SUBTEST("PredType::getClass()");
try {
@@ -108,24 +107,23 @@ static void test_classes()
// PredType::NATIVE_INT should be in H5T_INTEGER class
H5T_class_t tcls = PredType::NATIVE_INT.getClass();
- if (H5T_INTEGER!=tcls) {
+ if (H5T_INTEGER != tcls) {
puts(" Invalid type class for H5T_NATIVE_INT");
}
// PredType::NATIVE_DOUBLE should be in H5T_FLOAT class
tcls = PredType::NATIVE_DOUBLE.getClass();
- if (H5T_FLOAT!=tcls) {
- verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__);
+ if (H5T_FLOAT != tcls) {
+ verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__,
+ __FILE__);
}
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_copy
*
@@ -137,7 +135,8 @@ static void test_classes()
* January, 2007
*-------------------------------------------------------------------------
*/
-static void test_copy()
+static void
+test_copy()
{
SUBTEST("DataType::copy() and DataType::operator=");
@@ -148,7 +147,7 @@ static void test_copy()
// Test copying a predefined type using DataType::copy
DataType copied_type;
- copied_type.copy (PredType::STD_B8LE);
+ copied_type.copy(PredType::STD_B8LE);
// Test copying a user-defined type using DataType::operator=
DataType assigned_usertype;
@@ -159,7 +158,7 @@ static void test_copy()
copied_usertype.copy(copied_type);
// Test copying a user-defined int type using DataType::operator=
- IntType orig_int(PredType::STD_B8LE);
+ IntType orig_int(PredType::STD_B8LE);
DataType generic_type;
generic_type = orig_int;
@@ -172,13 +171,11 @@ static void test_copy()
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_detect_type_class
*
@@ -190,29 +187,30 @@ static void test_copy()
* August, 2017
*-------------------------------------------------------------------------
*/
-typedef struct { /* Struct with atomic fields */
- int i;
- float f;
- char c;
- double d;
- short s;
+typedef struct { /* Struct with atomic fields */
+ int i;
+ float f;
+ char c;
+ double d;
+ short s;
} atomic_typ_t;
-typedef struct { /* Struct with complex fields */
- hobj_ref_t arr_r[3][3];
- int i;
- hvl_t vl_f;
- hvl_t vl_s;
- char c;
- short s;
+typedef struct { /* Struct with complex fields */
+ hobj_ref_t arr_r[3][3];
+ int i;
+ hvl_t vl_f;
+ hvl_t vl_s;
+ char c;
+ short s;
} complex_typ_t;
-static void test_detect_type_class()
+static void
+test_detect_type_class()
{
SUBTEST("DataType::detectClass()");
try {
- bool in_class = false; // indicates whether a datatype is in a class
+ bool in_class = false; // indicates whether a datatype is in a class
/*
* Test class of some atomic types.
@@ -260,8 +258,8 @@ static void test_detect_type_class()
*/
// Create an array datatype with an atomic base type
- unsigned rank = 2; // Rank for array datatype
- hsize_t dims[2] = {3,3}; // Dimensions for array datatype
+ unsigned rank = 2; // Rank for array datatype
+ hsize_t dims[2] = {3, 3}; // Dimensions for array datatype
ArrayType atom_arr(PredType::STD_REF_OBJ, rank, dims);
// Make certain that the correct classes can be detected
@@ -367,13 +365,11 @@ static void test_detect_type_class()
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_detect_type_class", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_vltype
*
@@ -385,12 +381,12 @@ static void test_detect_type_class()
* August, 2017
*-------------------------------------------------------------------------
*/
-static void test_vltype()
+static void
+test_vltype()
{
// Output message about test being performed
SUBTEST("VarLenType functions");
- try
- {
+ try {
VarLenType vltype(PredType::NATIVE_INT);
bool in_class = vltype.detectClass(H5T_VLEN);
@@ -408,9 +404,11 @@ static void test_vltype()
in_class = vltype2.detectClass(H5T_VLEN);
verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__);
in_class = vltype2.detectClass(H5T_INTEGER);
- verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__, __FILE__);
+ verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__,
+ __FILE__);
in_class = vltype2.detectClass(H5T_FLOAT);
- verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__, __FILE__);
+ verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__,
+ __FILE__);
// Create a new file to use in this test
H5File file(FILENAME[3], H5F_ACC_TRUNC);
@@ -435,17 +433,16 @@ static void test_vltype()
in_class = vltype2.detectClass(H5T_VLEN);
verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__);
in_class = first_vlt_again.detectClass(H5T_FLOAT);
- verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__, __FILE__);
+ verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__,
+ __FILE__);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_vltype", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_vltype
+} // test_vltype
-
/*-------------------------------------------------------------------------
* Function: test_query
*
@@ -460,14 +457,14 @@ static void test_vltype()
const H5std_string CompT_NAME("Compound_type");
const H5std_string EnumT_NAME("Enum_type");
-static void test_query()
+static void
+test_query()
{
- short enum_val;
+ short enum_val;
// Output message about test being performed
SUBTEST("Query functions of compound and enumeration types");
- try
- {
+ try {
// Create File
H5File file(FILENAME[2], H5F_ACC_TRUNC);
@@ -482,11 +479,11 @@ static void test_query()
// Create a enumerate datatype
EnumType tid2(sizeof(short));
- tid2.insert("RED", (enum_val=0,&enum_val));
- tid2.insert("GREEN", (enum_val=1,&enum_val));
- tid2.insert("BLUE", (enum_val=2,&enum_val));
- tid2.insert("ORANGE", (enum_val=3,&enum_val));
- tid2.insert("YELLOW", (enum_val=4,&enum_val));
+ tid2.insert("RED", (enum_val = 0, &enum_val));
+ tid2.insert("GREEN", (enum_val = 1, &enum_val));
+ tid2.insert("BLUE", (enum_val = 2, &enum_val));
+ tid2.insert("ORANGE", (enum_val = 3, &enum_val));
+ tid2.insert("YELLOW", (enum_val = 4, &enum_val));
// Query member number and member index by name, for compound type
int nmembs = tid1.getNmembers();
@@ -506,10 +503,10 @@ static void test_query()
// prop list, then close it
tid1.commit(file, CompT_NAME);
PropList tcpl = tid1.getCreatePlist();
- if (!IdComponent::isValid(tcpl.getId()))
- {
+ if (!IdComponent::isValid(tcpl.getId())) {
// Throw an invalid action exception
- throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid");
+ throw InvalidActionException("H5Object::createAttribute",
+ "Datatype creation property list is not valid");
}
tcpl.close();
tid1.close();
@@ -518,10 +515,10 @@ static void test_query()
// prop list, then close it
tid2.commit(file, EnumT_NAME);
tcpl = tid2.getCreatePlist();
- if (!IdComponent::isValid(tcpl.getId()))
- {
+ if (!IdComponent::isValid(tcpl.getId())) {
// Throw an invalid action exception
- throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid");
+ throw InvalidActionException("H5Object::createAttribute",
+ "Datatype creation property list is not valid");
}
tcpl.close();
tid2.close();
@@ -560,14 +557,12 @@ static void test_query()
H5File file1(FILENAME[2], H5F_ACC_TRUNC);
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_query
+} // test_query
-
/*-------------------------------------------------------------------------
* Function: test_transient
*
@@ -579,17 +574,18 @@ static void test_query()
* January, 2007
*-------------------------------------------------------------------------
*/
-const char* filename1 = "dtypes1.h5";
+const char *filename1 = "dtypes1.h5";
-static void test_transient ()
+static void
+test_transient()
{
- static hsize_t ds_size[2] = {10, 20};
+ static hsize_t ds_size[2] = {10, 20};
SUBTEST("Transient datatypes");
try {
// Create the file and the dataspace.
- H5File file(filename1, H5F_ACC_TRUNC);
+ H5File file(filename1, H5F_ACC_TRUNC);
DataSpace space(2, ds_size, ds_size);
// Copying a predefined type results in a modifiable copy
@@ -600,8 +596,11 @@ static void test_transient ()
try {
Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space));
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype.");
- } catch (AttributeIException& err) {} // do nothing, failure expected
+ throw InvalidActionException("H5Object::createAttribute",
+ "Attempted to commit a predefined datatype.");
+ }
+ catch (AttributeIException &err) {
+ } // do nothing, failure expected
// Create a dataset from a transient datatype
// type.close(); - put trace in H5Tclose to make sure it's closed
@@ -614,8 +613,11 @@ static void test_transient ()
itype.setPrecision(256);
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!");
- } catch (DataTypeIException& err) {}
+ throw InvalidActionException("PredType::setPrecision",
+ "Dataset datatypes should not be modifiable!");
+ }
+ catch (DataTypeIException &err) {
+ }
itype.close();
// Get a copy of the dataset's datatype by applying DataType::copy()
@@ -635,14 +637,12 @@ static void test_transient ()
type.close();
space.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_transient
+} // test_transient
-
/*-------------------------------------------------------------------------
* Function: test_named
*
@@ -656,12 +656,13 @@ static void test_transient ()
*/
const H5std_string filename2("dtypes2.h5");
-static void test_named ()
+static void
+test_named()
{
static hsize_t ds_size[2] = {10, 20};
- hsize_t i;
- unsigned attr_data[10][20];
- DataType *ds_type = NULL;
+ hsize_t i;
+ unsigned attr_data[10][20];
+ DataType * ds_type = NULL;
SUBTEST("Named datatypes");
try {
@@ -678,15 +679,16 @@ static void test_named ()
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype.");
- } catch (DataTypeIException& err) {}
+ }
+ catch (DataTypeIException &err) {
+ }
// Copy a predefined datatype and commit the copy.
IntType itype(PredType::NATIVE_INT);
itype.commit(file, "native-int");
// Test commit passing in const H5File& for prototype with const
- try
- {
+ try {
// Create random char type
IntType atype(PredType::NATIVE_UCHAR);
@@ -696,9 +698,8 @@ static void test_named ()
// Commit type passing in const group; compilation would fail if
// no matching prototype
atype.commit(const_grp, "random uchar");
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group");
}
@@ -708,11 +709,14 @@ static void test_named ()
// We should not be able to modify a type after it has been committed.
try {
- itype.setPrecision(256); // attempt an invalid action...
+ itype.setPrecision(256); // attempt an invalid action...
// Should FAIL but didn't, so throw an invalid action exception
- throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype.");
- } catch (DataTypeIException& err) {}
+ throw InvalidActionException("IntType::setPrecision",
+ "Attempted to modify a committed datatype.");
+ }
+ catch (DataTypeIException &err) {
+ }
// We should not be able to re-commit a committed type
try {
@@ -720,12 +724,14 @@ static void test_named ()
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype.");
- } catch (DataTypeIException& err) {} // do nothing, failure expected
+ }
+ catch (DataTypeIException &err) {
+ } // do nothing, failure expected
// It should be possible to define an attribute for the named type
Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space);
- for (i=0; i<ds_size[0]*ds_size[1]; i++)
- attr_data[0][i] = (int)i;/*tricky*/
+ for (i = 0; i < ds_size[0] * ds_size[1]; i++)
+ attr_data[0][i] = (int)i; /*tricky*/
attr1.write(PredType::NATIVE_UINT, attr_data);
attr1.close();
@@ -734,13 +740,15 @@ static void test_named ()
IntType trans_type;
trans_type.copy(itype);
bool iscommitted = trans_type.committed();
- verify_val(iscommitted, 0, "DataType::committed() - Copying a named type should result in a transient type!", __LINE__, __FILE__);
+ verify_val(iscommitted, 0,
+ "DataType::committed() - Copying a named type should result in a transient type!",
+ __LINE__, __FILE__);
trans_type.setPrecision(256);
trans_type.close();
// Close the committed type and reopen it. It should be a named type.
itype.close();
- itype = file.openIntType("native-int");
+ itype = file.openIntType("native-int");
iscommitted = itype.committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "Opened named types should be named types!");
@@ -748,8 +756,8 @@ static void test_named ()
// Create a dataset that uses the named type, then get the dataset's
// datatype and make sure it's a named type.
DataSet dset = file.createDataSet("dset1", itype, space);
- ds_type = new DataType(dset.getDataType());
- iscommitted = ds_type->committed();
+ ds_type = new DataType(dset.getDataType());
+ iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "Dataset type should be named type!");
dset.close();
@@ -758,8 +766,8 @@ static void test_named ()
// Reopen the dataset and its type, then make sure the type is
// a named type.
- dset = file.openDataSet("dset1");
- ds_type = new DataType(dset.getDataType());
+ dset = file.openDataSet("dset1");
+ ds_type = new DataType(dset.getDataType());
iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "Dataset type should be named type!");
@@ -773,8 +781,8 @@ static void test_named ()
delete ds_type;
// Reopen the second dataset and make sure the type is shared
- dset = file.openDataSet("dset2");
- ds_type = new DataType(dset.getDataType());
+ dset = file.openDataSet("dset2");
+ ds_type = new DataType(dset.getDataType());
iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!");
@@ -793,17 +801,15 @@ static void test_named ()
space.close();
file.close();
PASSED();
- } // end of try block
- catch (Exception& E)
- {
+ } // end of try block
+ catch (Exception &E) {
issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg());
}
- if(ds_type)
+ if (ds_type)
delete ds_type;
-} // test_named
+} // test_named
-
/*-------------------------------------------------------------------------
* Function: test_encode_decode
*
@@ -816,12 +822,13 @@ static void test_named ()
*-------------------------------------------------------------------------
*/
const H5std_string filename3("encode_decode.h5");
-const int ARRAY1_RANK = 1;
-const int ARRAY1_DIM = 10;
+const int ARRAY1_RANK = 1;
+const int ARRAY1_DIM = 10;
-static void test_encode_decode()
+static void
+test_encode_decode()
{
- short enum_val;
+ short enum_val;
SUBTEST("DataType::encode() and DataType::decode()");
try {
@@ -847,7 +854,7 @@ static void test_encode_decode()
verify_val(cmptyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode compound type's buffer to a new CompType
- CompType* decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode()));
+ CompType *decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode()));
// Verify that the datatype was copied exactly via encoding/decoding
verify_val(cmptyp == *decoded_cmp_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -871,11 +878,11 @@ static void test_encode_decode()
// Create a enumerate datatype
EnumType enumtyp(sizeof(short));
- enumtyp.insert("RED", (enum_val=0,&enum_val));
- enumtyp.insert("GREEN", (enum_val=1,&enum_val));
- enumtyp.insert("BLUE", (enum_val=2,&enum_val));
- enumtyp.insert("ORANGE", (enum_val=3,&enum_val));
- enumtyp.insert("YELLOW", (enum_val=4,&enum_val));
+ enumtyp.insert("RED", (enum_val = 0, &enum_val));
+ enumtyp.insert("GREEN", (enum_val = 1, &enum_val));
+ enumtyp.insert("BLUE", (enum_val = 2, &enum_val));
+ enumtyp.insert("ORANGE", (enum_val = 3, &enum_val));
+ enumtyp.insert("YELLOW", (enum_val = 4, &enum_val));
// Encode compound type in a buffer
enumtyp.encode();
@@ -884,7 +891,7 @@ static void test_encode_decode()
verify_val(enumtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode enumeration type's buffer to a new EnumType
- EnumType* decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode()));
+ EnumType *decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode()));
// Verify that the datatype was copied exactly via encoding/decoding
verify_val(enumtyp == *decoded_enum_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -916,7 +923,7 @@ static void test_encode_decode()
verify_val(vlsttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode the variable-length type's buffer to a new StrType
- StrType* decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode()));
+ StrType *decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode()));
verify_val(vlsttyp == *decoded_str_ptr, true, "DataType::decode", __LINE__, __FILE__);
verify_val(decoded_str_ptr->isVariableStr(), true, "DataType::decode", __LINE__, __FILE__);
@@ -926,7 +933,7 @@ static void test_encode_decode()
// Test decoding the type by way of DataType*
// Decode variable-length string type to a new DataType
- DataType* decoded_vlstr_ptr(vlsttyp.decode());
+ DataType *decoded_vlstr_ptr(vlsttyp.decode());
// Create a StrType instance from the DataType object and verify it
StrType decoded_vlsttyp(decoded_vlstr_ptr->getId());
@@ -951,7 +958,7 @@ static void test_encode_decode()
verify_val(arrtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Create an ArrayType instance from the decoded pointer and verify it
- ArrayType* decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode()));
+ ArrayType *decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode()));
verify_val(arrtyp == *decoded_arr_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -983,7 +990,7 @@ static void test_encode_decode()
verify_val(inttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Create an IntType instance from the decoded pointer and verify it
- IntType* decoded_int_ptr(static_cast<IntType *>(inttyp.decode()));
+ IntType * decoded_int_ptr(static_cast<IntType *>(inttyp.decode()));
H5T_sign_t int_sign = decoded_int_ptr->getSign();
verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__);
verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__);
@@ -1004,27 +1011,25 @@ static void test_encode_decode()
verify_val(flttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__);
// Decode the array type's buffer
- DataType* decoded_flt_ptr(flttyp.decode());
+ DataType *decoded_flt_ptr(flttyp.decode());
// Create a IntType instance from the decoded pointer and verify it
FloatType decoded_flttyp(decoded_flt_ptr->getId());
verify_val(flttyp == decoded_flttyp, true, "DataType::decode", __LINE__, __FILE__);
- //H5std_string norm_string;
- //H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string);
- //verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__);
+ // H5std_string norm_string;
+ // H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string);
+ // verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__);
delete decoded_flt_ptr;
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_encode_decode", __LINE__, __FILE__, E.getCDetailMsg());
}
}
-
/*-------------------------------------------------------------------------
* Function: test_operators
*
@@ -1038,9 +1043,10 @@ static void test_encode_decode()
*/
const H5std_string filename4("h5_type_operators.h5");
-static void test_operators()
+static void
+test_operators()
{
- short enum_val;
+ short enum_val;
SUBTEST("DataType::operator== and DataType::operator!=");
try {
@@ -1073,9 +1079,9 @@ static void test_operators()
// Create an enumerate datatype
EnumType enumtyp(sizeof(short));
- enumtyp.insert("RED", (enum_val=0,&enum_val));
- enumtyp.insert("GREEN", (enum_val=1,&enum_val));
- enumtyp.insert("BLUE", (enum_val=2,&enum_val));
+ enumtyp.insert("RED", (enum_val = 0, &enum_val));
+ enumtyp.insert("GREEN", (enum_val = 1, &enum_val));
+ enumtyp.insert("BLUE", (enum_val = 2, &enum_val));
// Verify that operator== and operator!= work properly
verify_val(cmptyp == enumtyp, false, "DataType::operator==", __LINE__, __FILE__);
@@ -1086,7 +1092,7 @@ static void test_operators()
//
// Create random atomic datatypes
- IntType inttyp(PredType::NATIVE_INT);
+ IntType inttyp(PredType::NATIVE_INT);
FloatType flttyp(PredType::NATIVE_FLOAT);
// Get the NATIVE_INT member from the compound datatype above
@@ -1106,13 +1112,11 @@ static void test_operators()
PASSED();
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_operators", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_operators
+} // test_operators
-
/*-------------------------------------------------------------------------
* Function: test_types
*
@@ -1121,8 +1125,8 @@ static void test_operators()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void test_types()
+extern "C" void
+test_types()
{
// Output message about test being performed
MESSAGE(5, ("Testing Generic Data Types\n"));
@@ -1138,9 +1142,8 @@ void test_types()
test_encode_decode();
test_operators();
-} // test_types()
+} // test_types()
-
/*-------------------------------------------------------------------------
* Function: cleanup_types
*
@@ -1149,9 +1152,9 @@ void test_types()
* Return None
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_types()
+extern "C" void
+cleanup_types()
{
for (int i = 0; i < 3; i++)
HDremove(FILENAME[i]);
-} // cleanup_types
+} // cleanup_types