@@ -51,9 +51,6 @@ public static void main(String args[]) {
5151 // Test 4: Array object identifier setting
5252 testArrayObjectIdentifierSetting ();
5353
54- // Test 5: Vector object identifier setting (Vect1DInt and Vect1DString)
55- testVectorObjectIdentifierSetting ();
56-
5754 // Test 5: Invalid identifier handling
5855 testErrorHandling ();
5956 }
@@ -104,19 +101,21 @@ private static void testIdentifierDataFunctionality() {
104101
105102 try {
106103 coordinate_identifier .IdentifierData identifierData = coordinate_identifier .getIdentifierDataByName ("rho_tor" );
107- System .out .printf (" IdentifierData for 'rho_tor': index=%d, description='%s'\n " ,
108- identifierData .index , identifierData .description );
104+ System .out .printf (" IdentifierData for 'rho_tor': index=%d, originalname='%s', description='%s'\n " ,
105+ identifierData .index , identifierData .originalname , identifierData . description );
109106
110107 // Assertions for rho_tor
111108 assert identifierData .index == 11 : "Expected index 11 for rho_tor, got " + identifierData .index ;
109+ assert "rho_tor" .equals (identifierData .originalname ) : "Expected originalname 'rho_tor', got '" + identifierData .originalname + "'" ;
112110 assert identifierData .description != null && identifierData .description .contains ("toroidal flux" ) : "Expected description containing 'toroidal flux', got '" + identifierData .description + "'" ;
113111
114112 identifierData = coordinate_identifier .getIdentifierDataByName ("velocity_parallel" );
115- System .out .printf (" IdentifierData for 'velocity_parallel': index=%d, description='%s'\n " ,
116- identifierData .index , identifierData .description );
113+ System .out .printf (" IdentifierData for 'velocity_parallel': index=%d, originalname='%s', description='%s'\n " ,
114+ identifierData .index , identifierData .originalname , identifierData . description );
117115
118116 // Assertions for velocity_parallel
119117 assert identifierData .index == 105 : "Expected index 105 for velocity_parallel, got " + identifierData .index ;
118+ assert "velocity_parallel" .equals (identifierData .originalname ) : "Expected originalname 'velocity_parallel', got '" + identifierData .originalname + "'" ;
120119 assert identifierData .description != null && identifierData .description .contains ("parallel" ) : "Expected description containing 'parallel', got '" + identifierData .description + "'" ;
121120
122121 System .out .println ("IdentifierData assertions passed" );
@@ -175,18 +174,11 @@ private static void testArrayObjectIdentifierSetting() {
175174 System .out .println ("4. Testing array object identifier setting:" );
176175
177176 IdentifierArrayObject arrayObj = new IdentifierArrayObject ();
178- // Initialize the vector fields
179- arrayObj .indices = new Vect1DInt (5 );
180- arrayObj .names = new Vect1DString (5 );
181- arrayObj .descriptions = new Vect1DString (5 );
182-
183177 String [] identifierNames = {"x" , "y" , "z" , "phi" , "theta" };
184178
185179 try {
186- // Set identifiers on each field separately since they are now vector objects
187- coordinate_identifier .setIdentifier (arrayObj .indices , identifierNames );
188- coordinate_identifier .setIdentifier (arrayObj .names , identifierNames );
189- coordinate_identifier .setIdentifier (arrayObj .descriptions , identifierNames );
180+ // Set identifiers on the array object
181+ coordinate_identifier .setIdentifier (arrayObj , identifierNames );
190182
191183 System .out .printf (" Set identifiers %s:\n " , Arrays .toString (identifierNames ));
192184 System .out .printf (" Result: %s\n " , arrayObj );
@@ -209,7 +201,7 @@ private static void testArrayObjectIdentifierSetting() {
209201
210202 for (int i = 0 ; i < expectedIndices .length ; i ++) {
211203 assert actualIndices [i ] == expectedIndices [i ] : "Expected index " + expectedIndices [i ] + " at position " + i + ", got " + actualIndices [i ];
212- assert actualNames [i ].contains ( expectedNames [i ]) : "Expected name containing '" + expectedNames [i ] + "' at position " + i + ", got '" + actualNames [i ] + "'" ;
204+ assert expectedNames [i ].equals ( actualNames [i ]) : "Expected name '" + expectedNames [i ] + "' at position " + i + ", got '" + actualNames [i ] + "'" ;
213205 assert actualDescriptions [i ] != null && actualDescriptions [i ].length () > 0 : "Description at position " + i + " should not be null or empty" ;
214206 }
215207
@@ -225,81 +217,11 @@ private static void testArrayObjectIdentifierSetting() {
225217 System .out .println ();
226218 }
227219
228- /**
229- * Test setting identifiers on vector objects (Vect1DInt and Vect1DString)
230- */
231- private static void testVectorObjectIdentifierSetting () {
232- System .out .println ("5. Testing vector object identifier setting:" );
233-
234- // Test Vect1DInt
235- System .out .println (" Testing Vect1DInt:" );
236- Vect1DInt vect1DInt = new Vect1DInt (5 );
237- String [] identifierNames = {"x" , "y" , "z" , "phi" , "theta" };
238-
239- try {
240- coordinate_identifier .setIdentifier (vect1DInt , identifierNames );
241- System .out .printf (" Set identifiers %s on Vect1DInt\n " , Arrays .toString (identifierNames ));
242- System .out .printf (" Result array: %s\n " , Arrays .toString (vect1DInt .getArray ()));
243-
244- // Assertions for Vect1DInt
245- int [] expectedIndices = {1 , 2 , 3 , 5 , 20 };
246- int [] resultArray = vect1DInt .getArray ();
247-
248- assert resultArray != null : "Array should not be null" ;
249- assert resultArray .length == 5 : "Expected 5 elements, got " + resultArray .length ;
250-
251- for (int i = 0 ; i < expectedIndices .length ; i ++) {
252- assert resultArray [i ] == expectedIndices [i ] : "Expected index " + expectedIndices [i ] + " at position " + i + ", got " + resultArray [i ];
253- }
254-
255- System .out .println (" Vect1DInt assertions passed" );
256-
257- } catch (IllegalArgumentException e ) {
258- String message = e .getMessage ().replace ("Error" , "Issue" ).replace ("Failed" , "Unable" );
259- System .out .println (" Issue: " + message );
260- } catch (AssertionError e ) {
261- System .out .println ("Assertion issue: " + e .getMessage ());
262- }
263-
264- // Test Vect1DString
265- System .out .println (" Testing Vect1DString:" );
266- Vect1DString vect1DString = new Vect1DString (3 );
267- String [] stringIdentifierNames = {"velocity" , "momentum" , "energy_kinetic" };
268-
269- try {
270- coordinate_identifier .setIdentifier (vect1DString , stringIdentifierNames );
271- System .out .printf (" Set identifiers %s on Vect1DString\n " , Arrays .toString (stringIdentifierNames ));
272- System .out .printf (" Result array: %s\n " , Arrays .toString (vect1DString .getArray ()));
273-
274- // Assertions for Vect1DString
275- String [] resultArray = vect1DString .getArray ();
276-
277- assert resultArray != null : "Array should not be null" ;
278- assert resultArray .length == 3 : "Expected 3 elements, got " + resultArray .length ;
279-
280- // Check that each element contains both name and description
281- for (int i = 0 ; i < resultArray .length ; i ++) {
282- assert resultArray [i ] != null : "Element at position " + i + " should not be null" ;
283- assert resultArray [i ].contains (" - " ) : "Element at position " + i + " should contain ' - ' separator: " + resultArray [i ];
284- }
285-
286- System .out .println (" Vect1DString assertions passed" );
287-
288- } catch (IllegalArgumentException e ) {
289- String message = e .getMessage ().replace ("Error" , "Issue" ).replace ("Failed" , "Unable" );
290- System .out .println (" Issue: " + message );
291- } catch (AssertionError e ) {
292- System .out .println ("Assertion issue: " + e .getMessage ());
293- }
294-
295- System .out .println ();
296- }
297-
298220 /**
299221 * Test error handling with invalid identifiers
300222 */
301223 private static void testErrorHandling () {
302- System .out .println ("6 . Testing invalid identifier handling:" );
224+ System .out .println ("5 . Testing invalid identifier handling:" );
303225
304226 // Test invalid identifier in IdentifierData
305227 try {
@@ -324,30 +246,17 @@ private static void testErrorHandling() {
324246 System .out .println ("Issue assertion passed for single object" );
325247 }
326248
327- // Test invalid identifier in vector setting
328- Vect1DInt vectInt = new Vect1DInt ( 3 );
249+ // Test invalid identifier in array setting
250+ IdentifierArrayObject arrayObj = new IdentifierArrayObject ( );
329251 String [] invalidNames = {"x" , "invalid_identifier" , "z" };
330252 try {
331- coordinate_identifier .setIdentifier (vectInt , invalidNames );
332- System .out .println (" ✗ Expected issue for invalid identifier in vector , but none was thrown" );
253+ coordinate_identifier .setIdentifier (arrayObj , invalidNames );
254+ System .out .println (" ✗ Expected issue for invalid identifier in array , but none was thrown" );
333255 } catch (IllegalArgumentException e ) {
334256 String message = e .getMessage ().replace ("Failed" , "Unable" ).replace ("Error" , "Issue" );
335- System .out .printf (" Expected handling for vector object: %s\n " , message );
257+ System .out .printf (" Expected handling for array object: %s\n " , message );
336258 assert message .contains ("index 1" ) || message .contains ("Unknown identifier" ) : "Expected message about array index 1 or unknown identifier" ;
337- System .out .println ("Issue assertion passed for vector object" );
338- }
339-
340- // Test unsupported object type (trying to use IdentifierArrayObject directly)
341- IdentifierArrayObject arrayObj = new IdentifierArrayObject ();
342- String [] validNames = {"x" , "y" , "z" };
343- try {
344- coordinate_identifier .setIdentifier (arrayObj , validNames );
345- System .out .println (" ✗ Expected issue for unsupported object type, but none was thrown" );
346- } catch (IllegalArgumentException e ) {
347- String message = e .getMessage ().replace ("Failed" , "Unable" ).replace ("Error" , "Issue" );
348- System .out .printf (" Expected handling for unsupported object: %s\n " , message );
349- assert message .contains ("Unsupported object type" ) || message .contains ("Only Vect1DInt and Vect1DString are supported" ) : "Expected message about unsupported type" ;
350- System .out .println ("Issue assertion passed for unsupported object type" );
259+ System .out .println ("Issue assertion passed for array object" );
351260 }
352261
353262 System .out .println ();
0 commit comments