@@ -377,3 +377,62 @@ TEST(FixedArray, CheckFrontAndBack)
377377 itk::RangeGTestUtilities::CheckFrontAndBack (itk::FixedArray<int >({ 0 , 1 , 2 }));
378378 itk::RangeGTestUtilities::CheckFrontAndBack (itk::FixedArray<double >::Filled (std::numeric_limits<double >::max ()));
379379}
380+
381+
382+ // Tests interop with c-style arrays, equality, Set/GetElement, and various index types.
383+ TEST (FixedArray, CArrayInteropAndIndexTypes)
384+ {
385+ // Explicit instantiation to ensure all methods are compiled.
386+ (void )itk::FixedArray<float , 3 >{};
387+
388+ // Test equality operators
389+ constexpr itk::FixedArray<int , 3 > array4{};
390+ EXPECT_EQ (array4, array4);
391+ EXPECT_FALSE (array4 != array4);
392+
393+ // Test Set/GetElement
394+ constexpr unsigned int n{ 20 };
395+ itk::FixedArray<unsigned int , n> array20;
396+ for (unsigned int i = 0 ; i < n; ++i)
397+ {
398+ array20.SetElement (i, i);
399+ }
400+ for (unsigned int k = 0 ; k < n; ++k)
401+ {
402+ EXPECT_EQ (array20.GetElement (k), k);
403+ }
404+
405+ // Test various index types (const access)
406+ #define TRY_INDEX_CONST (T ) \
407+ { \
408+ T in = 10 ; \
409+ EXPECT_EQ (array20[in], 10u ); \
410+ } \
411+ ITK_MACROEND_NOOP_STATEMENT
412+
413+ TRY_INDEX_CONST (short );
414+ TRY_INDEX_CONST (unsigned short );
415+ TRY_INDEX_CONST (int );
416+ TRY_INDEX_CONST (unsigned int );
417+ TRY_INDEX_CONST (long );
418+ TRY_INDEX_CONST (unsigned long );
419+ TRY_INDEX_CONST (long long );
420+ TRY_INDEX_CONST (unsigned long long );
421+
422+ // Test various index types (non-const access)
423+ #define TRY_INDEX (T ) \
424+ { \
425+ T in = 10 ; \
426+ array20[in] = 10 ; \
427+ } \
428+ ITK_MACROEND_NOOP_STATEMENT
429+
430+ TRY_INDEX (short );
431+ TRY_INDEX (unsigned short );
432+ TRY_INDEX (int );
433+ TRY_INDEX (unsigned int );
434+ TRY_INDEX (long );
435+ TRY_INDEX (unsigned long );
436+ TRY_INDEX (long long );
437+ TRY_INDEX (unsigned long long );
438+ }
0 commit comments