You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by fi...@apache.org on 2010/07/21 18:58:33 UTC

svn commit: r966314 [31/41] - in /incubator/etch/branches/etch-c: ./ binding-c/ binding-c/compiler/ binding-c/compiler/src/ binding-c/compiler/src/main/ binding-c/compiler/src/main/java/ binding-c/compiler/src/main/java/org/ binding-c/compiler/src/main...

Added: incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_type.c
URL: http://svn.apache.org/viewvc/incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_type.c?rev=966314&view=auto
==============================================================================
--- incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_type.c (added)
+++ incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_type.c Wed Jul 21 16:58:23 2010
@@ -0,0 +1,698 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * test_type.c 
+ * test etch_type
+ */
+
+#include "etch_runtime.h"
+#include "etch_type.h"
+#include "etch_validator.h"
+#include "etch_field.h"
+#include "etch_objecttypes.h"
+#include "etch_serializer.h"
+#include "etch_arraylist.h"
+
+#include <stdio.h>
+#include "CUnit.h"
+#include "Basic.h"
+#include "Automated.h"
+#include <wchar.h>
+
+#define IS_DEBUG_CONSOLE FALSE
+
+// extern types
+extern apr_pool_t* g_etch_main_pool;
+
+static int init_suite(void)
+{
+    etch_status_t etch_status = ETCH_SUCCESS;
+
+    etch_status = etch_runtime_initialize(NULL);
+    if(etch_status != NULL) {
+        // error
+    }
+    return 0;
+}
+
+static int clean_suite(void)
+{
+    //this_teardown();
+    etch_runtime_shutdown();
+    return 0;
+}
+
+int this_setup()
+{
+    return 0;
+}
+
+/*
+ * test_type
+ */
+static void test_type(void)
+{
+    int result = 0;
+    etch_type *type1 = NULL, *type2 = NULL;
+
+    const wchar_t* nametext1 = L"abracadabra";
+
+    const wchar_t* nametext2 = L"gilgamesh";
+    
+#ifdef ETCH_DEBUGALLOC
+    alloc_a = etch_showmem(0, FALSE);
+#endif
+    type1   = new_type(NULL);
+    CU_ASSERT_PTR_NULL(type1);
+
+#ifdef ETCH_DEBUGALLOC
+    alloc_b = etch_showmem(0, FALSE);
+    CU_ASSERT_EQUAL(alloc_a, alloc_b); 
+#endif
+
+    type1   = new_type(nametext1);
+    CU_ASSERT_PTR_NOT_NULL_FATAL(type1);
+    CU_ASSERT_TRUE(is_good_type(type1));
+
+    type2   = new_type(nametext1);
+    CU_ASSERT_TRUE(is_equal_types(type1, type2));
+    result = memcmp(type1->name, type2->name, type1->namebytelen);
+    CU_ASSERT_EQUAL(result,0);
+
+    etch_object_destroy(type1);
+    etch_object_destroy(type2);
+
+#ifdef ETCH_DEBUGALLOC
+    alloc_a = etch_showmem(0, FALSE);
+    CU_ASSERT_EQUAL(alloc_a, alloc_b); 
+#endif
+
+    type1 = new_type(nametext1);
+    type2 = new_type(nametext2);
+
+    CU_ASSERT_FALSE(is_equal_types(type1, type2));
+
+    etch_object_destroy(type1);
+    etch_object_destroy(type2);
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_type_hashfunc
+ * test wire hashing function
+ */
+static void test_type_hashfunc(void)
+{
+    unsigned hash1 = 0, hash2 = 0;
+    etch_type *type1 = NULL, *type2 = NULL;
+
+    const wchar_t* nametext1 = L"abracadabra";
+    const size_t   numelts1  = wcslen(nametext1);
+    const size_t   numbytes1 = sizeof(wchar_t) * ( numelts1 + 1 );
+
+    const wchar_t* nametext2 = L"gilgamesh";
+    const size_t   numelts2  = wcslen(nametext2);
+    const size_t   numbytes2 = sizeof(wchar_t) * ( numelts2 + 1 );
+ 
+    hash1 = compute_type_id_from_widename(nametext1);
+    hash2 = compute_type_id_from_widename(nametext2);
+
+    CU_ASSERT_NOT_EQUAL(hash1, hash2);
+
+    type1 = new_type(nametext1);
+    type2 = new_type(nametext2);
+    CU_ASSERT_EQUAL(type1->namebytelen, numbytes1);
+    CU_ASSERT_EQUAL(type2->namebytelen, numbytes2);
+    CU_ASSERT_EQUAL(type1->id, hash1);
+    CU_ASSERT_EQUAL(type2->id, hash2);
+
+    etch_object_destroy(type1);
+    etch_object_destroy(type2);
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * function pointers used by test_getset()
+ */
+static int bogus_stubhelper (void* stub, void* delsvc, void* obj, void* whofrom, void* msg) { return 0; }
+
+
+
+/**
+ * test_getset
+ * test mutators
+ */
+static void test_getset(void)
+{
+    unsigned int this_class  = 0, old_class = 0;
+    unsigned char   cur_flag = 0, old_flag = 0;
+    unsigned int cur_timeout = 0, old_timeout = 0;
+    opaque_stubhelper cur_helper = NULL, old_helper = NULL;
+    etch_serializer *cur_impexphelper, *old_impexphelper;
+    etch_type *type1 = new_type(L"abracadabra");
+    etch_type *type2 = new_type(L"gilgamesh"), *cur_type = NULL, *old_type  = NULL;
+    etch_field *fld1 = new_field(L"field1"),  *cur_field = NULL, *old_field = NULL;
+    etch_serializer* impxhelp1 = (etch_serializer*) new_object(sizeof(etch_object), ETCHTYPEB_ETCHOBJECT, CLASSID_NONE);
+    const unsigned int TEST_CLASS = (ETCHTYPEB_PRIMITIVE << 16) | CLASSID_PRIMITIVE_INT32;
+
+    /* component type */
+    this_class = etchtype_get_component_type(type1);
+    CU_ASSERT_EQUAL(this_class, 0);
+
+    old_class = etchtype_set_component_type(type1, TEST_CLASS);
+    CU_ASSERT_EQUAL(old_class, 0);
+
+    this_class = etchtype_get_component_type(type1);
+    CU_ASSERT_EQUAL(this_class, TEST_CLASS);
+
+    old_class = etchtype_set_component_type(type1, 0);
+    CU_ASSERT_EQUAL(old_class, TEST_CLASS);
+
+    /* timeout */
+    cur_timeout = etchtype_get_timeout(type1);
+    CU_ASSERT_EQUAL(cur_timeout, 0);
+
+    old_timeout = etchtype_set_timeout(type1, 1000);
+    CU_ASSERT_EQUAL(old_timeout, 0);
+
+    cur_timeout = etchtype_get_timeout(type1);
+    CU_ASSERT_EQUAL(cur_timeout, 1000);
+
+    old_timeout = etchtype_set_timeout(type1, 0);
+    CU_ASSERT_EQUAL(old_timeout, 1000);
+
+    /* result type */
+    cur_type = etchtype_get_result_type(type1);
+    CU_ASSERT_PTR_EQUAL(cur_type, NULL);
+
+    old_type = etchtype_set_result_type(type1, type2);
+    CU_ASSERT_PTR_EQUAL(old_type, NULL);
+
+    cur_type = etchtype_get_result_type(type1);
+    CU_ASSERT_PTR_EQUAL(cur_type, type2);
+
+    old_type = etchtype_set_result_type(type1, NULL);
+    CU_ASSERT_PTR_EQUAL(old_type, type2);
+
+    /* super type */
+    cur_type = etchtype_get_super_type(type1);
+    CU_ASSERT_PTR_EQUAL(cur_type, NULL);
+
+    old_type = etchtype_set_super_type(type1, type2);
+    CU_ASSERT_PTR_EQUAL(old_type, NULL);
+
+    cur_type = etchtype_get_super_type(type1);
+    CU_ASSERT_PTR_EQUAL(cur_type, type2);
+
+    old_type = etchtype_set_super_type(type1, NULL);
+    CU_ASSERT_PTR_EQUAL(old_type, type2);
+
+    /* response field */
+    cur_field = etchtype_get_response_field(type1);
+    CU_ASSERT_PTR_EQUAL(cur_field, NULL);
+
+    old_field = etchtype_set_response_field(type1, type2);
+    CU_ASSERT_PTR_EQUAL(old_field, NULL);
+
+    cur_field = etchtype_get_response_field(type1);
+    CU_ASSERT_PTR_EQUAL(cur_field, type2);
+
+    old_field = etchtype_set_response_field(type1, NULL);
+    CU_ASSERT_PTR_EQUAL(old_field, type2);
+
+    /* run validators */
+    cur_flag = etchtype_get_run_validators(type1);
+    CU_ASSERT_EQUAL(cur_flag, FALSE);
+
+    old_flag = etchtype_set_run_validators(type1, TRUE);
+    CU_ASSERT_EQUAL(old_flag, FALSE);
+
+    cur_flag = etchtype_get_run_validators(type1);
+    CU_ASSERT_EQUAL(cur_flag, TRUE);
+
+    old_flag = etchtype_set_run_validators(type1,FALSE);
+    CU_ASSERT_EQUAL(old_flag, TRUE);
+
+    /* stub helper */
+    cur_helper = etchtype_get_type_stubhelper(type1);
+    CU_ASSERT_PTR_EQUAL(cur_helper, NULL);
+
+    old_helper = etchtype_set_type_stubhelper(type1, bogus_stubhelper);
+    CU_ASSERT_PTR_EQUAL(old_helper, NULL);
+
+    old_helper = etchtype_get_type_stubhelper(type1);
+    CU_ASSERT_PTR_EQUAL(old_helper, bogus_stubhelper);
+
+    old_helper = etchtype_set_type_stubhelper(type1, NULL);
+    CU_ASSERT_PTR_EQUAL(old_helper, bogus_stubhelper);
+
+    /* import/export helper */      
+    cur_impexphelper = etchtype_get_impexphelper(type1);
+    CU_ASSERT_PTR_EQUAL(cur_impexphelper, NULL);
+
+    old_impexphelper = etchtype_set_impexphelper(type1, impxhelp1);
+    CU_ASSERT_PTR_EQUAL(old_impexphelper, NULL);
+
+    cur_impexphelper = etchtype_get_impexphelper(type1);
+    CU_ASSERT_PTR_EQUAL(cur_impexphelper, impxhelp1);
+
+    old_impexphelper = etchtype_set_impexphelper(type1, NULL);
+    CU_ASSERT_PTR_EQUAL(old_impexphelper, impxhelp1);
+
+
+    etch_object_destroy(fld1);
+    etch_object_destroy(type2);
+    etch_object_destroy(type1);
+    etch_object_destroy(impxhelp1);
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_assignable()
+ * test is_assignable_from()
+ */
+static void test_assignable(void)
+{
+    int result = 0;
+    const unsigned short TEST_SUPERCLASS_ID = 0xffff;
+    etch_type* type1 = new_type(L"type1");
+    etch_type* type2 = new_type(L"type2");
+    ((etch_object*)type1)->class_id  = TEST_SUPERCLASS_ID;
+    etchtype_set_super_type(type2, type1);
+
+    result = etchtype_is_assignable_from(type1, type2);
+    CU_ASSERT_EQUAL(result, TRUE); 
+
+    result = etchtype_is_assignable_from(type2, type1);
+    CU_ASSERT_EQUAL(result, FALSE); 
+
+    result = etchtype_is_assignable_from(type2, NULL);
+    CU_ASSERT_EQUAL(result, FALSE); 
+
+    result = etchtype_is_assignable_from(NULL, type1);
+    CU_ASSERT_EQUAL(result, FALSE); 
+
+    etch_object_destroy(type1);
+    etch_object_destroy(type2);
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_validators_access
+ * test put and get validators
+ */
+static void test_validators_access(void)
+{
+    etch_iterator iterator;
+    etch_field* vtor1_key = new_field(L"vtor1");
+    etch_field* vtor2_key = new_field(L"vtor2");
+    etch_field* bogus_key = new_field(L"bogus");
+    etch_type *type1 = new_type(L"abracadabra");
+    etch_type *typev = new_type(L"struct"); /* struct validator type */
+    etch_validator* vtor1 = etchvtor_int32_get(0);
+    etch_validator* vtor2 = etchvtor_struct_get(typev, 0);
+    etch_validator* vtor_return = NULL;
+
+    int result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor1);
+    CU_ASSERT_EQUAL(result, 0);
+
+    vtor_return = (etch_validator*) etchtype_get_validator_by_name(type1, vtor1_key->name);
+    CU_ASSERT_PTR_NOT_NULL(vtor_return);   
+    CU_ASSERT_PTR_EQUAL(vtor_return, vtor1);
+
+    vtor_return = (etch_validator*) etchtype_get_validator_by_id(type1, vtor1_key->id);
+    CU_ASSERT_PTR_NOT_NULL(vtor_return);
+    CU_ASSERT_PTR_EQUAL(vtor_return, vtor1);
+
+    result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor2_key), (etch_object*) vtor2);
+    CU_ASSERT_EQUAL(result, 0);
+
+    result = etchtype_validators_count(type1);
+    CU_ASSERT_EQUAL(result, 2);
+
+    vtor_return = (etch_validator*) etchtype_get_validator_by_name(type1, vtor1_key->name);
+    CU_ASSERT_PTR_NOT_NULL(vtor_return);
+    CU_ASSERT_PTR_EQUAL(vtor_return, vtor1);
+
+    vtor_return = (etch_validator*) etchtype_get_validator_by_id(type1, vtor1_key->id);
+    CU_ASSERT_PTR_NOT_NULL(vtor_return);
+    CU_ASSERT_PTR_EQUAL(vtor_return, vtor1);
+
+    vtor_return = (etch_validator*) etchtype_get_validator_by_name(type1, vtor2_key->name);
+    CU_ASSERT_PTR_NOT_NULL(vtor_return);
+    CU_ASSERT_PTR_EQUAL(vtor_return, vtor2);
+
+    vtor_return = (etch_validator*) etchtype_get_validator_by_id(type1, vtor2_key->id);
+    CU_ASSERT_PTR_NOT_NULL(vtor_return);
+    CU_ASSERT_PTR_EQUAL(vtor_return, vtor2);
+
+    /* iterate over the validators map */
+    result = etchtype_set_validators_iterator(type1, &iterator);
+    CU_ASSERT_EQUAL_FATAL(result, 0);
+
+    while(iterator.has_next(&iterator))
+    {   
+        const etch_validator* this_vtor = (etch_validator*) iterator.current_value;
+
+        if  (this_vtor == vtor1)
+             result = TRUE;
+        else
+        if  (this_vtor == vtor2)
+             result = TRUE; 
+        else result = FALSE;  
+             
+        CU_ASSERT_EQUAL_FATAL(result, TRUE);
+
+        iterator.next(&iterator);
+    }
+
+    /* etchtype_clear_validators() is superfluous here, destruction of the type
+     * has the same result, however we may as well test it */
+    result = etchtype_clear_validators(type1);
+    CU_ASSERT_EQUAL(result, 2); /* result of clear is cleared count */
+
+    result = etchtype_validators_count(type1);
+    CU_ASSERT_EQUAL(result, 0);
+
+    /* etchtype_put_validator() was given clones of these fields as validator 
+     * keys, which were freed during etchtype_clear_validators. this is the model
+     * to use in the binding, i.e. clone a static etch_field for put_validator().
+     */
+    etch_object_destroy(vtor1_key);
+    etch_object_destroy(vtor2_key);
+    etch_object_destroy(bogus_key);
+
+    /* vtor1 will not have been freed during etchtype_clear_validators(), 
+     * since it is a cached validator. likewise, calling its destructor  
+     * would have no effect, etchtype_clear_validators() has already tried.
+     * etchvtor_clear_cache() will free it and any other cached validators.
+     * vtor2 will however have been freed during etchtype_clear_validators(),  
+     * since a struct validator is not one of the cached validator types. 
+     * in any case, we don't need to be concerned here about which validators
+     * are cached and which are not, since etchtype_clear_validators() will
+     * free the uncached ones, and etchvtor_clear_cache() the cached ones.
+     */ 
+    etch_object_destroy(typev);
+    etch_object_destroy(type1);
+    etchvtor_clear_cache(); /* destroy cached validators (vtor1 in this case) */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_fields_access
+ */
+static void test_fields_access(void)
+{
+    etch_iterator iterator;
+    etch_field* field1 = new_field(L"field1");
+    etch_field* field2 = new_field(L"field2");
+    etch_field* field3 = new_field(L"field3");
+    etch_field* fieldx = new_field(L"fieldx");
+    etch_field* field_return = NULL;
+    etch_field* field_clone  = NULL;
+    etch_arraylist* list_return = NULL;
+    etch_type *type1 = new_type(L"abracadabra");
+    const int EXPECTED_FIELDS_COUNT = 3;
+    int result = 0, newfield_id = 0;
+
+    field_clone = (etch_field*)etch_object_clone_func(field1);
+    field_return = etchtype_add_field(type1, field_clone);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_PTR_EQUAL(field_return, field_clone);
+
+    /* ensure that trying to add a duplicate field returns the existing field.
+     * note that the new clone is destroyed by etchtype_add_field when it 
+     * determines that the supplied field can't be added */
+    field_return = etchtype_add_field(type1, (etch_field*)etch_object_clone_func(field1));
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_PTR_EQUAL(field_return, field_clone);
+
+    /* add a couple more fields */
+    field_clone = (etch_field*)etch_object_clone_func(field2);
+    field_return = etchtype_add_field(type1, field_clone);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_PTR_EQUAL(field_return, field_clone);
+
+    field_clone = (etch_field*)etch_object_clone_func(field3);
+    field_return = etchtype_add_field(type1, field_clone);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_PTR_EQUAL(field_return, field_clone);
+
+    result = etchtype_fields_count(type1);
+    CU_ASSERT_EQUAL(result, EXPECTED_FIELDS_COUNT);
+
+    /* test accessors */
+    field_return = etchtype_get_field_by_name(type1, field1->name);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_EQUAL(is_equal_fields(field_return, field1), TRUE);
+
+    field_return = etchtype_get_field_by_id(type1, field1->id);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_EQUAL(is_equal_fields(field_return, field1), TRUE);
+
+    field_return = etchtype_get_field_by_name(type1, field2->name);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_EQUAL(is_equal_fields(field_return, field2), TRUE);
+
+    field_return = etchtype_get_field_by_id(type1, field2->id);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_EQUAL(is_equal_fields(field_return, field2), TRUE);
+
+    field_return = etchtype_get_field_by_name(type1, field3->name);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_EQUAL(is_equal_fields(field_return, field3), TRUE);
+
+    field_return = etchtype_get_field_by_id(type1, field3->id);
+    CU_ASSERT_PTR_NOT_NULL(field_return);
+    CU_ASSERT_EQUAL(is_equal_fields(field_return, field3), TRUE);
+
+    /* test that a "get" of an unrecognized field name, adds a new field
+     * with that name. this is consistent with the java binding */
+    field_return = etchtype_get_field_by_name(type1, fieldx->name);
+    CU_ASSERT_PTR_NOT_NULL_FATAL(field_return);  
+    result = etchtype_fields_count(type1);
+    CU_ASSERT_EQUAL(result, EXPECTED_FIELDS_COUNT+1);
+    newfield_id = field_return->id;
+
+    /* iterate over the type's fieldmap */
+    result = etchtype_set_fields_iterator(type1, &iterator);
+    CU_ASSERT_EQUAL_FATAL(result, 0);
+
+    while(iterator.has_next(&iterator))
+    {   
+        const unsigned this_id = ((etch_field*)iterator.current_key)->id;
+
+        if  (this_id == field1->id)
+             result = TRUE;
+        else
+        if  (this_id == field2->id)
+             result = TRUE; 
+        else
+        if  (this_id == field3->id)
+             result = TRUE; 
+        else
+        if  (this_id == newfield_id)
+             result = TRUE; 
+        else result = FALSE; 
+              
+        CU_ASSERT_EQUAL(result, TRUE);
+
+        iterator.next(&iterator);
+    }
+
+    /* get a list of all the type's fields. 
+     * we own the returned list, which does not own its content */
+    list_return = (etch_arraylist*) etchtype_get_fields(type1);
+
+    CU_ASSERT_EQUAL_FATAL(is_etch_arraylist(list_return), TRUE);
+    CU_ASSERT_EQUAL(list_return->count, EXPECTED_FIELDS_COUNT+1);
+
+    /* iterate over the list of fields */
+    set_iterator(&iterator, list_return, &list_return->iterable);
+
+    while(iterator.has_next(&iterator))
+    {   
+        const unsigned this_id = ((etch_field*)iterator.current_value)->id;
+
+        if  (this_id == field1->id)
+             result = TRUE;
+        else
+        if  (this_id == field2->id)
+             result = TRUE; 
+        else
+        if  (this_id == field3->id)
+             result = TRUE; 
+        else
+        if  (this_id == newfield_id)
+             result = TRUE; 
+        else result = FALSE;  
+          
+        CU_ASSERT_EQUAL(result, TRUE);
+
+        iterator.next(&iterator);
+    }
+
+    etch_object_destroy(list_return);
+    etch_object_destroy(field1);
+    etch_object_destroy(field2);
+    etch_object_destroy(field3);
+    etch_object_destroy(fieldx);
+    etch_object_destroy(type1);
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_validators_chained
+ * test memory mangement of chained validators
+ */
+static void test_validators_chained(void)
+{
+    etch_field* vtor1_key = new_field(L"vtor1");
+    etch_field* vtor2_key = new_field(L"vtor2");
+    etch_type *structtype = new_type(L"struct"); /* struct validator type */
+    etch_validator* vtor1 = etchvtor_int32_get(0);
+    etch_validator* vtor2 = etchvtor_int16_get(0);
+    etch_validator* vtor3 = etchvtor_byte_get(0);
+    etch_validator* vtor4 = etchvtor_int32_get(0);
+    etch_validator* vtor5 = etchvtor_struct_get(structtype, 0);
+    etch_validator* vtor6 = etchvtor_struct_get(structtype, 0);
+    etch_validator* vtor7 = etchvtor_struct_get(structtype, 0);
+    etch_validator* vtor8 = etchvtor_string_get(0);
+    etch_type *type1 = new_type(L"abracadabra");
+
+    /* test 3 validators with the same key. when a validator is put to a type
+     * and the type already has one or more validators with the specified key, 
+     * the new validator is chained to the existing validator */
+    int result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor1);
+    CU_ASSERT_EQUAL(result, 0);
+
+    result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor2);
+
+    result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor3);
+
+    /* etchtype_clear_validators is needed here, since we want to begin 
+     * a new test with the type emptied of validators.
+     */
+    etchtype_clear_validators(type1); 
+
+     /* test 3 validators with the same key, and 2 validators with another key.
+      * note that the c binding convention is to always get a "fresh" validator 
+      * when we add a validator to a type, even though the get will return the 
+      * same object when the validator type we get is cached. */
+
+     result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor4);
+     result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor5);
+     result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor1_key), (etch_object*) vtor6);
+
+     result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor2_key), (etch_object*) vtor7);
+     result = etchtype_put_validator(type1, (etch_field*)etch_object_clone_func(vtor2_key), (etch_object*) vtor8);
+
+    /* etchtype_clear_validators is superfluous here, so we test not doing it. 
+     * when we destroy type1 below, the destructor for the type's instance data 
+     * object destroys the type's hashtables, which causes the hashtables to 
+     * first clear their content, as etchtype_clear_validators() would do.
+     */
+    /* etchtype_clear_validators(type1); */
+
+    /* etchtype_put_validator() was given clones of these fields as validator 
+     * keys, which were freed during etchtype_clear_validators. this is the model
+     * to use in the binding, i.e. clone a static etch_field for put_validator().
+     */
+    etch_object_destroy(vtor1_key);
+    etch_object_destroy(vtor2_key);
+
+    etch_object_destroy(structtype); 
+
+    /* the destroy() of type1 clears the type's fields and validators maps,
+     * which causes the fields, validator field keys, and non-cached validators,
+     * to be destroyed.
+     */
+    etch_object_destroy(type1);
+    etchvtor_clear_cache(); /* destroy any singleton cached validators */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+
+/**
+ * main   
+ */
+//int wmain( int argc, wchar_t* argv[], wchar_t* envp[])
+CU_pSuite test_etch_type_suite()
+{    
+    CU_pSuite ps = CU_add_suite("type test suite", init_suite, clean_suite);
+
+    CU_add_test(ps, "test etch_type constructors/destructors", test_type);  
+    CU_add_test(ps, "test etch_type hashing", test_type_hashfunc); 
+    CU_add_test(ps, "test getters/setters", test_getset);  
+    CU_add_test(ps, "test assignability", test_assignable);  
+    CU_add_test(ps, "test validators access", test_validators_access);  
+    CU_add_test(ps, "test fields access", test_fields_access);  
+    CU_add_test(ps, "test chained validators", test_validators_chained);
+
+    return ps;
+}

Added: incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_validator.c
URL: http://svn.apache.org/viewvc/incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_validator.c?rev=966314&view=auto
==============================================================================
--- incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_validator.c (added)
+++ incubator/etch/branches/etch-c/binding-c/runtime/c/src/test/message/test_validator.c Wed Jul 21 16:58:23 2010
@@ -0,0 +1,1515 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * test_validator.c
+ * test etch_validator
+ */
+#include "etch_runtime.h"
+#include "etch_validator.h"
+#include "etch_tagged_data.h"
+#include "etch_nativearray.h"
+#include "etch_structval.h"
+#include "etch_objecttypes.h"
+
+#include <stdio.h>
+#include "CUnit.h"
+#include "Basic.h"
+#include "Automated.h"
+
+#define IS_DEBUG_CONSOLE FALSE
+
+/* - - - - - - - - - - - - - - 
+ * unit test infrastructure
+ * - - - - - - - - - - - - - -
+ */
+
+static int init_suite(void)
+{
+    etch_status_t etch_status = ETCH_SUCCESS;
+
+    etch_status = etch_runtime_initialize(NULL);
+    if(etch_status != NULL) {
+        // error
+    }
+    return 0;
+}
+
+static int clean_suite(void)
+{
+    etch_runtime_shutdown();
+    return 0;
+}
+
+static etch_type*    testtype;
+static etch_boolean* objbool_false;
+static etch_boolean* objbool_true;
+static etch_byte*    objbyte_one;
+static etch_int16*   objshort_two;
+static etch_int32*   objint_three;
+static etch_int64*   objlong_four;
+static etch_float*   objfloat_five;
+static etch_double*  objdouble_six;
+static etch_string*  objstring_abc;
+static etch_object*  objobject_null;
+static etch_nativearray* arraydim1;
+static etch_nativearray* arraydim2;
+static etch_nativearray* arraydim3;
+
+
+static void create_testobjects()
+{
+    testtype = new_type(L"abc");
+    objbool_false  = new_boolean(FALSE);
+    objbool_true   = new_boolean(TRUE);
+    objbyte_one    = new_byte(1);
+    objshort_two   = new_int16(2);
+    objint_three   = new_int32(3);
+    objlong_four   = new_int64(4);
+    objfloat_five  = new_float(5.0);
+    objdouble_six  = new_double(6.0);
+    objstring_abc  = new_stringw(L"abc");
+    objobject_null = (etch_object*) new_primitive(sizeof(etch_object), CLASSID_NONE);
+    arraydim1  = new_etch_nativearray(CLASSID_ARRAY_BOOL, 1, 1, 4, 0, 0);
+    arraydim2  = new_etch_nativearray(CLASSID_ARRAY_BOOL, 1, 2, 4, 3, 0);
+    arraydim3  = new_etch_nativearray(CLASSID_ARRAY_BOOL, 1, 3, 4, 3, 2);
+}
+
+
+static void destroy_testobjects()
+{
+    etch_object_destroy(testtype); testtype = NULL;
+    etch_object_destroy(objbool_false); objbool_false = NULL;
+    etch_object_destroy(objbool_true);  objbool_true  = NULL;
+    etch_object_destroy(objbyte_one);   objbyte_one   = NULL;
+    etch_object_destroy(objshort_two);  objshort_two  = NULL;
+    etch_object_destroy(objint_three);  objint_three  = NULL;
+    etch_object_destroy(objlong_four);  objlong_four  = NULL;
+    etch_object_destroy(objfloat_five); objfloat_five = NULL;
+    etch_object_destroy(objdouble_six); objdouble_six = NULL;
+    etch_object_destroy(objstring_abc); objstring_abc = NULL;
+    etch_object_destroy(objobject_null);objobject_null= NULL;
+    etch_object_destroy(arraydim1);  arraydim1 = NULL;
+    etch_object_destroy(arraydim2);  arraydim2 = NULL;
+    etch_object_destroy(arraydim3);  arraydim3 = NULL;
+}
+
+
+/**
+ * do_boolean_test()
+ * common test template for the boolean validator tests
+ */
+static void do_boolean_test(int dims, char* name, byte in_typecode, 
+    unsigned short validated_class_id, etch_object* objgood, etch_object* objbad)
+{
+    int result = 0; 
+    byte out_typecode = 0;
+    etch_validator* vtor = etchvtor_boolean_get(dims);
+
+    CU_ASSERT_PTR_NOT_NULL_FATAL(vtor);
+    CU_ASSERT_EQUAL(vtor->numdimensions, dims); 
+    CU_ASSERT_EQUAL(validated_class_id, vtor->expected_class_id); 
+    CU_ASSERT_STRING_EQUAL(name, vtor->description);
+
+    result = vtor->validate(vtor, objgood);
+    CU_ASSERT_EQUAL(result,0);
+
+    result = vtor->validate(vtor, objbad);
+    CU_ASSERT_EQUAL(result,-1);
+    if (result != -1)
+        result = 1;
+
+    result = vtor->check_value(vtor, objgood, &out_typecode);
+    CU_ASSERT_EQUAL(result, 0);   
+    CU_ASSERT_EQUAL(in_typecode, out_typecode);   
+
+    result = vtor->check_value(vtor, objbad, &out_typecode);
+    CU_ASSERT_EQUAL(result, -1);  
+
+    CU_ASSERT_EQUAL(vtor->is_cached, TRUE);
+    etch_object_destroy(vtor); /* test that vtor is cached */
+    CU_ASSERT_EQUAL(result, -1);  /* and cannot be destroyed */ 
+}
+
+
+/**
+ * test_boolean_validator()
+ */
+static void test_boolean_validator(void)  
+{
+    char* strbool0 = "bool[0]"; 
+    create_testobjects();
+
+	do_boolean_test(0, "bool[0]", ETCH_XTRNL_TYPECODE_BOOLEAN_FALSE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_false, (etch_object*) objbyte_one);
+
+	do_boolean_test(0, "bool[0]", ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, (etch_object*) objshort_two);
+
+	do_boolean_test(0, "bool[0]", ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, (etch_object*) objint_three);
+
+	do_boolean_test(0, strbool0, ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, (etch_object*) objlong_four);
+
+	do_boolean_test(0, strbool0, ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, (etch_object*) objfloat_five);
+
+	do_boolean_test(0, strbool0, ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, (etch_object*) objdouble_six);
+
+	do_boolean_test(0, strbool0, ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, (etch_object*) objstring_abc);
+
+	do_boolean_test(0, strbool0, ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE, 
+        CLASSID_PRIMITIVE_BOOL, (etch_object*) objbool_true, objobject_null);
+
+	do_boolean_test(1, "bool[1]", ETCH_XTRNL_TYPECODE_ARRAY,
+        CLASSID_ARRAY_BOOL, (etch_object*) arraydim1, (etch_object*) objbool_true);
+
+	do_boolean_test(2, "bool[2]", ETCH_XTRNL_TYPECODE_ARRAY,
+        CLASSID_ARRAY_BOOL, (etch_object*) arraydim2, (etch_object*) arraydim1);
+
+	do_boolean_test(3, "bool[3]", ETCH_XTRNL_TYPECODE_ARRAY,
+        CLASSID_ARRAY_BOOL, (etch_object*) arraydim3, (etch_object*) arraydim2);
+
+    destroy_testobjects(); 
+    etchvtor_clear_cache();  /* destroy cached validators */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * do_recursive_test()
+ * run a validate on an anonymous object. if the object is a nativearray, 
+ * this method is invoked recursively until the array elements are validated.
+ * the caller relinquishes ownership of valobj to this method.
+ */
+static void do_recursive_test(etch_validator* vtor, const int dims, byte* typecodes, etch_object* valobj)
+{
+    int  result = 0;
+    signed char expected_typecode = 0, validated_typecode = 0;
+    //++debug_count;
+    //if (debug_count == 0x28)
+    //    result = 0; // debugger target    
+
+    result = vtor->validate(vtor, (etch_object*) valobj);
+    CU_ASSERT_EQUAL(result, 0);
+
+    expected_typecode = typecodes[dims];
+    result = vtor->check_value(vtor, (etch_object*) valobj, (unsigned char*)&validated_typecode);
+    CU_ASSERT_EQUAL(result,0);
+    if  (expected_typecode == validated_typecode)
+         result = TRUE;  
+    else result = FALSE;  // debugger target 
+    CU_ASSERT_EQUAL(result, TRUE);
+
+    if  (dims)
+    {   /* if validating an array, iterate the array and recursively validate 
+         * each array element, which could itself be an array. todo -- this
+         * is coded for nativearray, we may need to generalize to arrayvalue
+         */
+        int itemcount = 0, i = 0;
+        etch_nativearray* a = NULL;
+        etch_validator* element_vtor = vtor->element_validator(vtor);
+        CU_ASSERT_EQUAL_FATAL(is_etch_nativearray(valobj), TRUE);
+
+        a = (etch_nativearray*) valobj; 
+        itemcount = (int) a->dimension[dims-1];
+
+        for(; i < (const int) itemcount; i++)
+        {
+            etch_object* subobj = etch_nativearray_get_element(a, i); 
+
+            CU_ASSERT_PTR_NOT_NULL_FATAL(subobj);
+             
+            do_recursive_test(element_vtor, dims-1, typecodes, subobj);
+
+        } 
+
+        etch_object_destroy(valobj);
+    }
+    
+}
+
+
+/*
+ * test_array_boolean()
+ * test validator on arrays of boolean using the recursive test
+ */
+static void test_array_boolean(void)  
+{
+    const int numdimensions = 2, dim0count = 3, dim1count = 2;
+    boolean x1[2][3] = { { FALSE,FALSE,FALSE,}, { FALSE,FALSE,FALSE,}, };
+    boolean x2[2][3] = { { TRUE, TRUE, TRUE, }, { TRUE, TRUE, TRUE, }, };
+    byte typecodz[3] = { ETCH_XTRNL_TYPECODE_BOOLEAN_FALSE, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+    etch_nativearray* a1 = NULL, *a2 = NULL;
+
+    /* test validate boolean array x1/a1 */
+    etch_validator* vtor = etchvtor_boolean_get(numdimensions);
+
+	
+    a1 = new_etch_nativearray_from(&x1, CLASSID_ARRAY_BOOL,  
+        sizeof(boolean), numdimensions, dim0count, dim1count, 0);  
+	a1->is_content_owned = FALSE;
+    /* fyi we relinquish ownership of array a1 here */
+    do_recursive_test(vtor, numdimensions, typecodz, (etch_object*) a1);
+
+    /* test validate boolean array x2/a2 */
+    typecodz[0] = ETCH_XTRNL_TYPECODE_BOOLEAN_TRUE; 
+    vtor = etchvtor_boolean_get(numdimensions); 
+
+    a2 = new_etch_nativearray_from(&x2, CLASSID_ARRAY_BOOL,  
+        sizeof(boolean), numdimensions, dim0count, dim1count, 0);  
+
+	a2->is_content_owned = FALSE;
+    /* fyi we relinquish ownership of array a2 here */
+    do_recursive_test(vtor, numdimensions, typecodz, (etch_object*) a2);
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_byte()
+ * test validator on arrays of byte using the recursive test
+ */
+static void test_array_byte(void)  
+{
+    const int numdimensions = 2, dim0count = 3, dim1count = 2;
+    byte x1[2][3] = { { 'a',  'b',  'c', }, { 'd',  'e',  'f',}, };
+    byte x2[2][3] = { { ETCHTYPE_MIN_BYTE,0xff,0},{ ETCHTYPE_MAX_BYTE,0xff,0, }, };
+    byte typecodz[3] = { ETCH_XTRNL_TYPECODE_BYTE, 
+        ETCH_XTRNL_TYPECODE_BYTES, ETCH_XTRNL_TYPECODE_ARRAY };
+    etch_nativearray* a1 = NULL, *a2 = NULL;
+
+    /* test validate byte array x1/a1 */
+    etch_validator* vtor = etchvtor_byte_get(numdimensions);
+
+    a1 = new_etch_nativearray_from(&x1, CLASSID_ARRAY_BYTE,  
+        sizeof(byte), numdimensions, dim0count, dim1count, 0);  
+
+    /* fyi we relinquish ownership of array a1 here */
+    do_recursive_test(vtor, numdimensions, typecodz, (etch_object*) a1);
+
+    /* test validate byte array x2/a2 */
+    vtor = etchvtor_byte_get(numdimensions); 
+
+    a2 = new_etch_nativearray_from(&x2, CLASSID_ARRAY_BYTE,  
+        sizeof(byte), numdimensions, dim0count, dim1count, 0);  
+
+    /* fyi we relinquish ownership of array a2 here */
+    do_recursive_test(vtor, numdimensions, typecodz, (etch_object*) a2);
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_int16()
+ * test validator on arrays of short using the recursive test
+ */
+static void test_array_int16(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+
+    short x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+    short x2[2][3][4] = 
+      { { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+        { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+      };
+    short x3[2][3][4] = 
+      { { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+        { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+      };
+    short x4[2][3][4] = 
+      { { { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+        },
+        { { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+        },
+      };
+    short x5[2][3][4] = 
+      { { { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+        },
+        { { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+        },
+      };
+    short x6[2][3][4] = 
+      { { { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+        },
+        { { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+        },
+      };
+    short x7[2][3][4] = 
+      { { { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+        },
+        { { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+        },
+      };
+
+    byte typecodz1[4] = { ETCH_XTRNL_TYPECODE_BYTE, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    byte typecodz2[4] = { ETCH_XTRNL_TYPECODE_SHORT, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    etch_validator* vtor = etchvtor_int16_get(numdimensions); /* vtor for all tests */
+
+    /* test validate short array x1/tc1 (1-byte shorts) */
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_INT16,  
+         sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate short array x2/tc1 (1-byte shorts) */
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_INT16,  
+           sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+ 
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+   /* test validate short array x3/tc1 (1-byte shorts) */
+    a = new_etch_nativearray_from(&x3, CLASSID_ARRAY_INT16,  
+           sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate short array x4/tc1 (1-byte shorts) */
+    a = new_etch_nativearray_from(&x4, CLASSID_ARRAY_INT16,  
+           sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate short array x5/tc1 (1-byte shorts) */
+    a = new_etch_nativearray_from(&x5, CLASSID_ARRAY_INT16,  
+           sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate short array x6/tc2 (2-byte shorts) */
+    a = new_etch_nativearray_from(&x6, CLASSID_ARRAY_INT16,  
+           sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* test validate short array x7/tc2 (2-byte shorts) */
+    a = new_etch_nativearray_from(&x7, CLASSID_ARRAY_INT16,  
+           sizeof(short), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_int32()
+ * test validator on arrays of int using the recursive test
+ */
+static void test_array_int32(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+
+    int x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+    int x2[2][3][4] = 
+      { { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+        { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+      };
+    int x3[2][3][4] = 
+      { { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+        { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+      };
+    int x4[2][3][4] = 
+      { { { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+        },
+        { { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+        },
+      };
+    int x5[2][3][4] = 
+      { { { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+        },
+        { { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+        },
+      };
+    int x6[2][3][4] = 
+      { { { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+        },
+        { { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+        },
+      };
+    int x7[2][3][4] = 
+      { { { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+        },
+        { { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+        },
+      };
+
+    byte typecodz1[4] = { ETCH_XTRNL_TYPECODE_BYTE, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    byte typecodz2[4] = { ETCH_XTRNL_TYPECODE_SHORT, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+
+    /* test validate int array x1/tc1 (1-byte ints) */
+    etch_validator* vtor = etchvtor_int32_get(numdimensions);  /* allocates object */
+
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_INT32,  
+         sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int array x2/tc1 (1-byte ints) */
+    vtor = etchvtor_int32_get(numdimensions);  /* gets cached object */
+
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+ 
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int array x3/tc1 (1-byte ints) */
+    a = new_etch_nativearray_from(&x3, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int array x4/tc1 (1-byte ints) */
+    a = new_etch_nativearray_from(&x4, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int array x5/tc1 (1-byte ints) */
+    a = new_etch_nativearray_from(&x5, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int array x6/tc2 (2-byte ints) */
+    a = new_etch_nativearray_from(&x6, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* test validate int array x7/tc2 (2-byte ints) */
+    a = new_etch_nativearray_from(&x7, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* test validate int array x8/tc4 (4-byte ints) */
+    a = new_etch_nativearray_from(&x6, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* test validate int array x9/tc4 (4-byte ints) */
+    a = new_etch_nativearray_from(&x7, CLASSID_ARRAY_INT32,  
+           sizeof(int), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_int64()
+ * test validator on arrays of long long using the recursive test
+ */
+static void test_array_int64(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+
+    int64 x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+    int64 x2[2][3][4] = 
+      { { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+        { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+      };
+    int64 x3[2][3][4] = 
+      { { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+        { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+      };
+    int64 x4[2][3][4] = 
+      { { { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+        },
+        { { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+          { ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE,ETCHTYPE_MAX_BYTE, }, 
+        },
+      };
+    int64 x5[2][3][4] = 
+      { { { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+        },
+        { { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+          { ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE,ETCHTYPE_MIN_BYTE, }, 
+        },
+      };
+    int64 x6[2][3][4] = 
+      { { { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+        },
+        { { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+          { ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16,ETCHTYPE_MAX_INT16, }, 
+        },
+      };
+    int64 x7[2][3][4] = 
+      { { { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+        },
+        { { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+          { ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16,ETCHTYPE_MIN_INT16, }, 
+        },
+      };
+    int64 x8[2][3][4] = 
+      { { { ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32, }, 
+          { ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32, }, 
+          { ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32, }, 
+        },
+        { { ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32, }, 
+          { ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32, }, 
+          { ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32,ETCHTYPE_MAX_INT32, }, 
+        },
+      };
+    int64 x9[2][3][4] = 
+      { { { ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32, }, 
+          { ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32, }, 
+          { ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32, }, 
+        },
+        { { ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32, }, 
+          { ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32, }, 
+          { ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32,ETCHTYPE_MIN_INT32, }, 
+        },
+      };
+    int64 x10[2][3][4] = 
+      { { { ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64, }, 
+          { ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64, }, 
+          { ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64, }, 
+        },
+        { { ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64, }, 
+          { ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64, }, 
+          { ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64,ETCHTYPE_MAX_INT64, }, 
+        },
+      };
+    int64 x11[2][3][4] = 
+      { { { ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64, }, 
+          { ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64, }, 
+          { ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64, }, 
+        },
+        { { ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64, }, 
+          { ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64, }, 
+          { ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64,ETCHTYPE_MIN_INT64, }, 
+        },
+      };
+
+    byte typecodz1[4] = { ETCH_XTRNL_TYPECODE_BYTE, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    byte typecodz2[4] = { ETCH_XTRNL_TYPECODE_SHORT, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    byte typecodz4[4] = { ETCH_XTRNL_TYPECODE_INT, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    byte typecodz8[4] = { ETCH_XTRNL_TYPECODE_LONG, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    /* test validate int array x1/tc1 (1-byte ints) */
+    etch_validator* vtor = etchvtor_int64_get(numdimensions);  /* allocates object */
+
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_INT64,  
+         sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int64 array x2/tc1 (1-byte longs) */
+    vtor = etchvtor_int64_get(numdimensions);  /* gets cached object */
+
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+ 
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int64 array x3/tc1 (1-byte longs) */
+    a = new_etch_nativearray_from(&x3, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int64 array x4/tc1 (1-byte longs) */
+    a = new_etch_nativearray_from(&x4, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int64 array x5/tc1 (1-byte longs) */
+    a = new_etch_nativearray_from(&x5, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate int64 array x6/tc2 (2-byte longs) */
+    a = new_etch_nativearray_from(&x6, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* test validate int64 array x7/tc2 (2-byte longs) */
+    a = new_etch_nativearray_from(&x7, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* test validate int64 array x8/tc4 (4-byte longs) */
+    a = new_etch_nativearray_from(&x8, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz4, (etch_object*) a);
+
+
+    /* test validate int64 array x9/tc4 (4-byte longs) */
+    a = new_etch_nativearray_from(&x9, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz4, (etch_object*) a);
+
+
+    /* test validate int64 array x10/tc8 (8-byte longs) */
+    a = new_etch_nativearray_from(&x10, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz8, (etch_object*) a);
+
+
+    /* test validate int64 array x11/tc8 (8-byte longs) */
+    a = new_etch_nativearray_from(&x11, CLASSID_ARRAY_INT64,  
+           sizeof(int64), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz8, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_float()
+ * test validator on arrays of float using the recursive test
+ */
+static void test_array_float(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+
+    float x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+    float x2[2][3][4] = 
+      { { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+        { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+      };
+    float x3[2][3][4] = 
+      { { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+        { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+      };
+    float x4[2][3][4] = 
+      { { { ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT, }, 
+          { ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT, }, 
+          { ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT, }, 
+        },
+        { { ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT, }, 
+          { ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT, }, 
+          { ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT,ETCHTYPE_MAX_FLOAT, }, 
+        },
+      };
+    float x5[2][3][4] = 
+      { { { ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT, }, 
+          { ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT, }, 
+          { ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT, }, 
+        },
+        { { ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT, }, 
+          { ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT, }, 
+          { ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT,ETCHTYPE_MIN_FLOAT, }, 
+        },
+      };
+
+    byte typecodz1[4] = { ETCH_XTRNL_TYPECODE_FLOAT, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    etch_validator* vtor = etchvtor_float_get(numdimensions); /* vtor for all tests */
+
+    /* test validate float array x1/tc1 (1-byte floats) */
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_FLOAT,  
+         sizeof(float), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate float array x2/tc1 (1-byte floats) */
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_FLOAT,  
+           sizeof(float), numdimensions, dim0count, dim1count, dim2count);  
+ 
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+   /* test validate float array x3/tc1 (1-byte floats) */
+    a = new_etch_nativearray_from(&x3, CLASSID_ARRAY_FLOAT,  
+           sizeof(float), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate float array x4/tc1 (1-byte floats) */
+    a = new_etch_nativearray_from(&x4, CLASSID_ARRAY_FLOAT,  
+           sizeof(float), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate float array x5/tc1 (1-byte floats) */
+    a = new_etch_nativearray_from(&x5, CLASSID_ARRAY_FLOAT,  
+           sizeof(float), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_double()
+ * test validator on arrays of double using the recursive test
+ */
+static void test_array_double(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+
+    double x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+    double x2[2][3][4] = 
+      { { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+        { { 1,1,1,1, }, { 1,1,1,1, }, { 1,1,1,1, }, },
+      };
+    double x3[2][3][4] = 
+      { { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+        { { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, { -1,-1,-1,-1, }, },
+      };
+    double x4[2][3][4] = 
+      { { { ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE, }, 
+          { ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE, }, 
+          { ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE, }, 
+        },
+        { { ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE, }, 
+          { ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE, }, 
+          { ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE,ETCHTYPE_MAX_DOUBLE, }, 
+        },
+      };
+    double x5[2][3][4] = 
+      { { { ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE, }, 
+          { ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE, }, 
+          { ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE, }, 
+        },
+        { { ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE, }, 
+          { ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE, }, 
+          { ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE,ETCHTYPE_MIN_DOUBLE, }, 
+        },
+      };
+
+    byte typecodz1[4] = { ETCH_XTRNL_TYPECODE_DOUBLE, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    etch_validator* vtor = etchvtor_double_get(numdimensions); /* vtor for all tests */
+
+    /* test validate double array x1/tc1 (1-byte doubles) */
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_DOUBLE,  
+         sizeof(double), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate double array x2/tc1 (1-byte doubles) */
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_DOUBLE,  
+           sizeof(double), numdimensions, dim0count, dim1count, dim2count);  
+ 
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+   /* test validate double array x3/tc1 (1-byte doubles) */
+    a = new_etch_nativearray_from(&x3, CLASSID_ARRAY_DOUBLE,  
+           sizeof(double), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate double array x4/tc1 (1-byte doubles) */
+    a = new_etch_nativearray_from(&x4, CLASSID_ARRAY_DOUBLE,  
+           sizeof(double), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate double array x5/tc1 (1-byte doubles) */
+    a = new_etch_nativearray_from(&x5, CLASSID_ARRAY_DOUBLE,  
+           sizeof(double), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_string()
+ * test validator on arrays of etch_string* using the recursive test
+ */
+static void test_array_string(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+    int i = 0, j = 0, k = 0;
+    const wchar_t* emptystring = L"";
+    const wchar_t* nonemptystring = L"abc";
+
+    etch_string* x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+
+    etch_string* x2[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+
+    byte typecodz1[4] = { ETCH_XTRNL_TYPECODE_EMPTY_STRING, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    byte typecodz2[4] = { ETCH_XTRNL_TYPECODE_STRING,
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY };
+
+    etch_validator* vtor = etchvtor_string_get(numdimensions); /* vtor for all tests */
+
+    for(i=0; i < dim2count; i++) /* populate test data arrays */
+    for(j=0; j < dim1count; j++)  
+    for(k=0; k < dim0count; k++)  
+    {
+        x1[i][j][k] = new_stringw(emptystring);
+        x2[i][j][k] = new_stringw(nonemptystring);
+    }
+
+    /* test validate etch_string* array x1/tc1 (empty string) */
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_STRING,  
+         sizeof(etch_string*), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz1, (etch_object*) a);
+
+
+    /* test validate etch_string* array x2/tc2 (nonempty string) */
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_STRING,  
+         sizeof(etch_string*), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz2, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/*
+ * test_array_object()
+ * test validator on arrays of etch_object* using the recursive test
+ */
+static void test_array_object(void)  
+{
+    const int numdimensions = 3, dim0count = 4, dim1count = 3, dim2count = 2;
+    etch_nativearray* a = NULL;
+    etch_object* obj = NULL;
+    int i = 0, j = 0, k = 0;
+    int sequence = 0;
+
+    etch_object* x1[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+
+    etch_object* x2[2][3][4] = 
+      { { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+        { { 0,0,0,0, }, { 0,0,0,0, }, { 0,0,0,0, }, },
+      };
+
+    byte typecodz[4] = { ETCH_XTRNL_TYPECODE_ANY, 
+        ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY, ETCH_XTRNL_TYPECODE_ARRAY};
+
+    etch_validator* vtor = etchvtor_object_get(numdimensions); /* vtor for all tests */
+
+    for(i=0; i < dim2count; i++) /* populate test data arrays */
+    for(j=0; j < dim1count; j++)  
+    for(k=0; k < dim0count; k++)  
+    {
+        sequence = i*j*k; 
+        obj = (etch_object*)new_int32(sequence);
+        x1[i][j][k] = obj;
+
+        obj = (etch_object*)&sequence;
+        x2[i][j][k] = obj;
+    }
+
+    /* test validate etch_object* array x1/tc (object owning object content) */
+    a = new_etch_nativearray_from(&x1, CLASSID_ARRAY_OBJECT,  
+         sizeof(etch_object*), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz, (etch_object*) a);
+
+
+    /* test validate etch_object* array x2/tc (object not owning its content) */
+    a = new_etch_nativearray_from(&x2, CLASSID_ARRAY_OBJECT,  
+         sizeof(etch_object*), numdimensions, dim0count, dim1count, dim2count);  
+
+    do_recursive_test(vtor, numdimensions, typecodz, (etch_object*) a);
+
+
+    /* done */
+    etchvtor_clear_cache();  /* destroy cached validator */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+
+/**
+ * do_struct_element_vtor_test()
+ * common test template for the structvalue element_validator tests
+ */
+static void do_struct_element_vtor_test(int testdims, char* name, unsigned short expected_class_id, etch_type* thistype)
+{
+    etch_validator* vtor = etchvtor_struct_get(thistype, testdims);
+
+    CU_ASSERT_PTR_NOT_NULL_FATAL(vtor); 
+    CU_ASSERT_EQUAL(vtor->numdimensions, testdims); 
+    CU_ASSERT_EQUAL(vtor->expected_class_id, expected_class_id); 
+    CU_ASSERT_STRING_EQUAL(vtor->description, name); 
+    CU_ASSERT_EQUAL(is_equal_types(vtor->struct_type, thistype), TRUE);
+
+    /* validator destructor is benign if validator is marked cached
+     * however a struct validator is not cached */
+    etch_object_destroy(vtor);
+}
+
+
+/**
+ * test_struct_element_validator()
+ */
+static void test_struct_element_validator(void)  
+{
+    etch_type* typeabc = new_type(L"abc");
+
+    do_struct_element_vtor_test(0, "struct_abc[0]", CLASSID_STRUCTVALUE,  typeabc);
+    do_struct_element_vtor_test(1, "struct_abc[1]", CLASSID_ARRAY_OBJECT, typeabc);
+    do_struct_element_vtor_test(2, "struct_abc[2]", CLASSID_ARRAY_OBJECT, typeabc);
+    do_struct_element_vtor_test(3, "struct_abc[3]", CLASSID_ARRAY_OBJECT, typeabc);
+
+    etch_object_destroy(typeabc);
+    etchvtor_clear_cache();    /* not needed since struct validator not cached  */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * do_struct_goodvalue_test()
+ */
+static void do_struct_goodvalue_test(int testdims, const byte expected_typecode, 
+     etch_object* value, etch_type* thistype, const int is_expected_newobject)
+{
+    int result = 0;
+    byte validated_typecode = 0;
+    etch_object* validated_value = NULL;
+
+    etch_validator* vtor = etchvtor_struct_get(thistype, testdims);
+    CU_ASSERT_PTR_NOT_NULL_FATAL(vtor); 
+
+    result = vtor->check_value(vtor, value, &validated_typecode);
+    CU_ASSERT_EQUAL_FATAL(result,0); 
+    CU_ASSERT_EQUAL(validated_typecode, expected_typecode); 
+
+    result = vtor->validate(vtor, value);
+    CU_ASSERT_EQUAL_FATAL(result,0); 
+
+    validated_value = vtor->validate_value(vtor, value);
+    CU_ASSERT_PTR_NOT_NULL_FATAL(validated_value); 
+
+    if  (is_expected_newobject)
+    {
+         CU_ASSERT_PTR_NOT_EQUAL_FATAL(value, validated_value);
+    }
+    else CU_ASSERT_PTR_EQUAL_FATAL(value, validated_value);
+
+    /* validated_value can return the same object as paassed, or a different
+     * object. for example when we expect etch_byte but validate against an
+     * etch_int32, we would pass an etch_int32 and get back an etch_byte.  
+     * in the real world, we would replace the passed value with the validated
+     * value; however in this test the caller is not prepared to handle this
+     * situation, so we free the new object, and let caller free the original */
+    if (validated_value != value)
+        etch_object_destroy(validated_value);       
+
+    /* validator destructor is benign if validator is marked cached
+     * however a struct validator is not cached */
+    etch_object_destroy(vtor);      
+}
+
+
+
+/**
+ * do_struct_badvalue_test()
+ */
+static void do_struct_badvalue_test(int testdims, etch_object* value, etch_type* thistype)
+{
+    int result = 0;
+    byte validated_typecode = 0;
+    etch_object* validated_value = NULL;
+
+    etch_validator* vtor = etchvtor_struct_get(thistype, testdims);
+    CU_ASSERT_PTR_NOT_NULL_FATAL(vtor); 
+
+    result = vtor->check_value(vtor, value, &validated_typecode);
+    CU_ASSERT_EQUAL_FATAL(result,-1); 
+
+    result = vtor->validate(vtor, value);
+    CU_ASSERT_EQUAL_FATAL(result,-1); 
+
+    validated_value = vtor->validate_value(vtor, value);
+    CU_ASSERT_PTR_NULL_FATAL(validated_value); 
+
+    if (validated_value && validated_value != value)
+        etch_object_destroy(validated_value);       
+
+    /* validator destructor is benign if validator is marked cached
+     * however a struct validator is not cached */
+    etch_object_destroy(vtor);      
+}
+
+
+/**
+ * test_struct_good_values()
+ */
+static void test_struct_good_values(void)  
+{
+    etch_type* typeabc = new_type(L"abc");
+    etch_nativearray* array_of_struct = NULL;
+    const int NUMDIMS0 = 0, NUMDIMS1 = 1, NUMDIMS2 = 2, DIMSIZE4 = 4;
+
+    etch_structvalue* sv = new_structvalue(typeabc, 0);
+    do_struct_goodvalue_test(NUMDIMS0, ETCH_XTRNL_TYPECODE_CUSTOM, (etch_object*) sv, typeabc, FALSE);
+
+    /* following tests create an empty array of structvalue objects */
+    array_of_struct = new_etch_nativearray_of(((etch_object*)sv)->obj_type, ((etch_object*)sv)->class_id, NUMDIMS1, DIMSIZE4, 0, 0);
+    do_struct_goodvalue_test(NUMDIMS1, ETCH_XTRNL_TYPECODE_ARRAY, (etch_object*) array_of_struct, typeabc, FALSE);
+    etch_object_destroy(array_of_struct);
+
+    array_of_struct = new_etch_nativearray_of(((etch_object*)sv)->obj_type, ((etch_object*)sv)->class_id, NUMDIMS2, DIMSIZE4, DIMSIZE4, 0);
+    do_struct_goodvalue_test(NUMDIMS2, ETCH_XTRNL_TYPECODE_ARRAY, (etch_object*) array_of_struct, typeabc, FALSE);
+    etch_object_destroy(array_of_struct);
+
+    etch_object_destroy(sv);          
+    etch_object_destroy(typeabc); /* in practice this would have been a static type */
+    etchvtor_clear_cache();    /* not needed since struct validator not cached  */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_struct_bad_values()  
+ */
+static void test_struct_bad_values(void)  
+{
+    etch_type* type_expected = new_type(L"abc");
+    etch_type* type_unexpect = new_type(L"def");
+    etch_nativearray* array_of_struct = NULL;
+    const int NUMDIMS0 = 0, NUMDIMS1 = 1, NUMDIMS2 = 2, NUMDIMS3 = 3, DIMSIZE4 = 4;
+
+    etch_structvalue* sv = new_structvalue(type_expected, 0);
+    etch_structvalue* svbogus = new_structvalue(type_unexpect, 0);
+    etch_int32*  intobj  = new_int32(1);
+    etch_object* objobj  = (etch_object*)intobj;
+
+    do_struct_badvalue_test(0, (etch_object*) intobj, type_expected);
+    do_struct_badvalue_test(0, objobj,  type_expected);
+    do_struct_badvalue_test(0, (etch_object*) svbogus, type_expected);
+    do_struct_badvalue_test(0, (etch_object*) sv, type_unexpect);
+
+    do_struct_badvalue_test(1, (etch_object*) intobj, type_expected);
+    do_struct_badvalue_test(1, objobj, type_expected);
+    do_struct_badvalue_test(1, (etch_object*) svbogus, type_expected);
+    do_struct_badvalue_test(1, (etch_object*) sv, type_unexpect);
+
+    /* following tests create an empty array of structvalue objects */
+    array_of_struct = new_etch_nativearray_of(((etch_object*)sv)->obj_type, ((etch_object*)sv)->class_id, NUMDIMS1, DIMSIZE4, 0, 0);
+    do_struct_badvalue_test(NUMDIMS0, (etch_object*) array_of_struct, type_expected);
+    etch_object_destroy(array_of_struct);
+
+    array_of_struct = new_etch_nativearray_of(((etch_object*)sv)->obj_type, ((etch_object*)sv)->class_id, NUMDIMS2, DIMSIZE4, DIMSIZE4, 0);
+    do_struct_badvalue_test(NUMDIMS1, (etch_object*) array_of_struct, type_expected);
+    do_struct_badvalue_test(NUMDIMS0, (etch_object*) array_of_struct, type_expected);
+    etch_object_destroy(array_of_struct);
+
+    array_of_struct = new_etch_nativearray_of(((etch_object*)sv)->obj_type, ((etch_object*)sv)->class_id, NUMDIMS3, DIMSIZE4, DIMSIZE4, DIMSIZE4);
+    do_struct_badvalue_test(NUMDIMS2, (etch_object*) array_of_struct, type_expected);
+    do_struct_badvalue_test(NUMDIMS1, (etch_object*) array_of_struct, type_expected);
+    do_struct_badvalue_test(NUMDIMS0, (etch_object*) array_of_struct, type_expected);
+    etch_object_destroy(array_of_struct);
+  
+    etch_object_destroy(objobj);
+    etch_object_destroy(sv);   
+    etch_object_destroy(svbogus);       
+    etch_object_destroy(type_expected); /* in real world these are static types */
+    etch_object_destroy(type_unexpect);  
+    etchvtor_clear_cache();  /* however struct validator is not cached */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_combo_validator_1()
+ */
+static void test_combo_validator_1(void)  
+{
+    int result = 0; 
+    etch_validator *vtor1 = 0, *vtor2 = 0, *vtor3 = 0;
+    create_testobjects();
+
+    /* one cached validator */
+    vtor1  = etchvtor_boolean_get(0);
+    vtor2  = NULL;
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    result = is_etch_combo_validator(vtor3);
+    CU_ASSERT_EQUAL_FATAL(result, TRUE);
+    result = vtor3->validate(vtor3, (etch_object*) objbool_true);
+    CU_ASSERT_EQUAL(result,0);
+    etch_object_destroy(vtor3);
+
+    /* one cached validator */
+    vtor1  = NULL;
+    vtor2  = etchvtor_boolean_get(0);
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    result = vtor3->validate(vtor3, (etch_object*) objbool_true);
+    CU_ASSERT_EQUAL(result,0);
+    etch_object_destroy(vtor3);
+
+    /* two cached validators */
+    vtor1  = etchvtor_boolean_get(0);
+    vtor2  = etchvtor_int32_get(0);
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    result = vtor3->validate(vtor3, (etch_object*) objint_three);
+    CU_ASSERT_EQUAL(result,0);
+    etch_object_destroy(vtor3);
+
+    destroy_testobjects(); 
+    etchvtor_clear_cache();  /* destroy cached validators */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_combo_validator_2()
+ */
+static void test_combo_validator_2(void)  
+{
+    int result = 0; 
+    etch_validator *vtor1 = 0, *vtor2 = 0, *vtor3 = 0, *vtor4 = 0, *vtor5 = 0;
+    create_testobjects();
+
+    /* chain 1 of cached validators and combos */
+    vtor1  = etchvtor_boolean_get(0);
+    vtor2  = etchvtor_boolean_get(0);
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    vtor4  = etchvtor_boolean_get(0);
+    vtor5  = new_combo_validator(vtor4, vtor3);
+    result = vtor5->validate(vtor5, (etch_object*) objbool_true);
+    CU_ASSERT_EQUAL(result,0);
+    etch_object_destroy(vtor5);
+
+    /* chain 2 of cached validators and combos */
+    vtor1  = etchvtor_boolean_get(0);
+    vtor2  = etchvtor_boolean_get(0);
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    vtor4  = etchvtor_boolean_get(0);
+    vtor5  = new_combo_validator(vtor3, vtor4);
+    result = vtor5->validate(vtor5, (etch_object*) objbool_true);
+    CU_ASSERT_EQUAL(result,0);
+    etch_object_destroy(vtor5);
+
+    destroy_testobjects(); 
+    etchvtor_clear_cache();  /* destroy cached validators */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * test_combo_validator_3()
+ */
+static void test_combo_validator_3(void)  
+{
+    int result = 0; 
+    etch_validator *vtor1 = 0, *vtor2 = 0, *vtor3 = 0, *vtor4 = 0, *vtor5 = 0;
+    create_testobjects();
+
+    /* chain 1 of cached and non-cached validators and combos */
+    vtor1  = etchvtor_boolean_get(0);
+    vtor2  = etchvtor_int32_get(0);
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    vtor4  = etchvtor_struct_get(testtype, 0);
+    vtor5  = new_combo_validator(vtor4, vtor3);
+    result = vtor5->validate(vtor5, (etch_object*) objint_three);
+    CU_ASSERT_EQUAL(result, 0); 
+    etch_object_destroy(vtor5);
+
+    /* chain 2 of cached and non-cached validators and combos */
+    vtor1  = etchvtor_int32_get(0);
+    vtor2  = etchvtor_boolean_get(0);
+    vtor3  = new_combo_validator(vtor1, vtor2);
+    vtor4  = etchvtor_struct_get(testtype, 0);  
+    vtor5  = new_combo_validator(vtor3, vtor4);
+    result = vtor5->validate(vtor5, (etch_object*) objint_three);
+    CU_ASSERT_EQUAL(result, 0);
+    etch_object_destroy(vtor5);
+
+    destroy_testobjects(); 
+    etchvtor_clear_cache();  /* destroy cached validators */
+
+#ifdef ETCH_DEBUGALLOC
+   g_bytes_allocated = etch_showmem(0,IS_DEBUG_CONSOLE);  /* verify all memory freed */
+   CU_ASSERT_EQUAL(g_bytes_allocated, 0);
+   // start fresh for next test
+   memtable_clear();
+#endif
+}
+
+
+/**
+ * main   
+ */
+//int wmain( int argc, wchar_t* argv[], wchar_t* envp[])
+CU_pSuite test_etch_validator_suite()
+{
+    CU_pSuite ps = CU_add_suite("validator test suite", init_suite, clean_suite);
+
+    CU_add_test(ps, "test boolean validator", test_boolean_validator);
+    CU_add_test(ps, "test validate boolean arrays", test_array_boolean);
+    CU_add_test(ps, "test validate byte arrays", test_array_byte);
+    CU_add_test(ps, "test validate int16 arrays", test_array_int16);
+    CU_add_test(ps, "test validate int32 arrays", test_array_int32);
+    CU_add_test(ps, "test validate int64 arrays", test_array_int64);
+    CU_add_test(ps, "test validate float arrays", test_array_float);
+    CU_add_test(ps, "test validate double arrays", test_array_double);
+    CU_add_test(ps, "test validate etch_string* arrays", test_array_string);
+    CU_add_test(ps, "test validate etch_object* arrays", test_array_object);
+    CU_add_test(ps, "test struct element validator", test_struct_element_validator);   
+    CU_add_test(ps, "test struct good values", test_struct_good_values); 
+    CU_add_test(ps, "test struct bad values",  test_struct_bad_values);  
+    CU_add_test(ps, "test combo validator 1",  test_combo_validator_1); 
+    CU_add_test(ps, "test combo validator 2",  test_combo_validator_2); 
+    CU_add_test(ps, "test combo validator 3",  test_combo_validator_3);         
+
+    return ps;
+}