@@ -79,26 +79,29 @@ else {
7979// Setup selector to process all fields (so cluster gets loaded)
8080const selector = new TSelector ( ) ,
8181 fields = [ 'IntField' , 'FloatField' , 'DoubleField' ,
82- 'Float16Field' ,
82+ 'Float16Field' , 'Real32Trunc' ,
8383 'StringField' , 'BoolField' ,
8484 'ArrayInt' , 'VariantField' , 'TupleField' ,
8585 'VectString' , 'VectInt' , 'VectBool' , 'Vect2Float' , 'Vect2Bool' , 'MultisetField' ,
86- 'MapStringFloat' , 'MapIntDouble' , 'MapStringBool' ] ;
86+ 'MapStringFloat' , 'MapIntDouble' , 'MapStringBool' ] ,
87+ epsilonValues = { Real32Trunc : 0.5 , Float16Field : 1e-2 } ;
88+
8789for ( const f of fields )
8890 selector . addBranch ( f ) ;
8991
9092selector . Begin = ( ) => {
9193 console . log ( '\nBegin processing to load cluster data...' ) ;
9294} ;
9395
96+
9497// Now validate entry data
9598const EPSILON = 1e-7 ;
9699
97100let any_error = false ;
98101
99- function compare ( expected , value ) {
102+ function compare ( expected , value , eps ) {
100103 if ( typeof expected === 'number' )
101- return Math . abs ( value - expected ) < EPSILON ;
104+ return Math . abs ( value - expected ) < ( eps ?? EPSILON ) ;
102105 if ( typeof expected === 'object' ) {
103106 if ( expected . length !== undefined ) {
104107 if ( expected . length !== value . length )
@@ -126,6 +129,7 @@ selector.Process = function(entryIndex) {
126129 FloatField : entryIndex * entryIndex ,
127130 DoubleField : entryIndex * 0.5 ,
128131 Float16Field : entryIndex * 0.1987333 ,
132+ Real32Trunc : 123.45 * entryIndex ,
129133 StringField : `entry_${ entryIndex } ` ,
130134 BoolField : entryIndex % 3 === 1 ,
131135 ArrayInt : [ entryIndex + 1 , entryIndex + 2 , entryIndex + 3 , entryIndex + 4 , entryIndex + 5 ] ,
@@ -175,7 +179,7 @@ selector.Process = function(entryIndex) {
175179 const value = this . tgtobj [ field ] ,
176180 expected = expectedValues [ field ] ;
177181
178- if ( ! compare ( expected , value ) ) {
182+ if ( ! compare ( expected , value , epsilonValues [ field ] ) ) {
179183 console . error ( `FAILURE: ${ field } at entry ${ entryIndex } expected ${ JSON . stringify ( expected ) } , got ${ JSON . stringify ( value ) } ` ) ;
180184 any_error = true ;
181185 } else
0 commit comments