Copyright 2019, Erik N. Johnson
This software is distributed under the MIT 3-clause license (../License.ENJ).
This test file tests the autoObject mechanism for fields consisting of arrays of data elements, using mostly the uint8_t handler type. It tests single and multi-field objects, and objects that combine scalar and array fields. Individual mixin type classes are fully tested in other test files.
Preamble for all tests
package require tcltest
namespace import ::tcltest::*
lappend auto_path ".."
package require autoObject
Series of tests creating and testing the functions of an object with a single field consisting of an array of uint8_t's.
puts ""
puts ""
puts "\tArray Field Tests - 1 Field Object"
puts ""
test oneArray_create {Create object with array of 5 uint8_t fields} -body {
set oneArrayObj [autoObject new {
firstArray {0 5 uint8_t[5] {1 2 3 4 5} }
}]
} -match glob -result "::oo::Obj*"
test oneArray_validate {1 field object: validate} -body {
$oneArrayObj validate
} -constraints {
$::AutoObject::AUTOOBJECT_VERSION >= 1.0
} -result true
test oneArray_configInit {1 field object: config -initialized} -body {
$oneArrayObj configure -initialized true
} -result ""
test oneArray_emptyGet {1 field object: get with no args} -body {
$oneArrayObj get
} -result {firstArray {1 2 3 4 5}}
test oneArray_toString {1 field object: toString} -body {
$oneArrayObj toString
} -result " firstArray: 1 2 3 4 5 "
test oneArray_toList {1 field object: toList} -body {
$oneArrayObj toList
} -result {1 2 3 4 5}
test oneArray_fromList {1 field object: fromList} -body {
$oneArrayObj fromList {10 9 8 7 6}
} -result {}
test oneArray_toString2 {1 field object: toString} -body {
$oneArrayObj toString
} -result " firstArray: 10 9 8 7 6 "
test oneArray_getField {1 field object: get firstArray} -body {
$oneArrayObj get firstArray
} -result {10 9 8 7 6}
cleanupTests