@@ -461,5 +461,152 @@ public void ProcessorType_EnumValues_AreAccessible()
461461 Assert . Equal ( ProcessorType . GPU , ProcessorType . GPU ) ;
462462 Assert . NotEqual ( ProcessorType . CPU , ProcessorType . GPU ) ;
463463 }
464+ [ Fact ]
465+ public void UnifiedProcessor_LargeNumberOfFiles_ProcessesAll ( )
466+ {
467+ for ( int i = 0 ; i < 10 ; i ++ )
468+ {
469+ CreateTestImageFloat ( TestDirInput , $ "test{ i : D3} .jpg", 10 , 10 ) ;
470+ }
471+
472+ var config = new UnifiedProcessorConfig
473+ {
474+ CpuWorkers = 2 ,
475+ GpuWorkers = 1 ,
476+ ReaderThreads = 2 ,
477+ WriterThreads = 2
478+ } ;
479+
480+ using var processor = new UnifiedProcessor ( config ) ;
481+ processor . ProcessDirectory ( TestDirInput , TestDirOutput ) ;
482+
483+ Assert . Equal ( 10 , Directory . GetFiles ( TestDirOutput ) . Length ) ;
484+ }
485+
486+ [ Fact ]
487+ public void ConvolveGpu_EdgePixels_ExtendStrategy ( )
488+ {
489+ using var gpuProcessor = new GpuConvolutionProcessor ( ) ;
490+ var image = new float [ 5 , 5 ] ;
491+ for ( int y = 0 ; y < 5 ; y ++ )
492+ for ( int x = 0 ; x < 5 ; x ++ )
493+ image [ y , x ] = ( y == 0 || x == 0 || y == 4 || x == 4 ) ? 255f : 128f ;
494+
495+ var result = gpuProcessor . ConvolveGpu ( image , Kernels . BlurBoxFloat , EdgeStrategy . Extend ) ;
496+
497+ Assert . NotNull ( result ) ;
498+ Assert . True ( result [ 0 , 0 ] > 0 ) ;
499+ Assert . True ( result [ 4 , 4 ] > 0 ) ;
500+ }
501+
502+ [ Fact ]
503+ public void ConvolveGpu_EdgePixels_ZeroPaddingStrategy ( )
504+ {
505+ using var gpuProcessor = new GpuConvolutionProcessor ( ) ;
506+ var image = new float [ 5 , 5 ] ;
507+ for ( int y = 0 ; y < 5 ; y ++ )
508+ for ( int x = 0 ; x < 5 ; x ++ )
509+ image [ y , x ] = 200f ;
510+
511+ var result = gpuProcessor . ConvolveGpu ( image , Kernels . BlurBoxFloat , EdgeStrategy . ZeroPadding ) ;
512+
513+ Assert . NotNull ( result ) ;
514+ Assert . True ( result [ 0 , 0 ] < result [ 2 , 2 ] ) ;
515+ }
516+
517+ [ Fact ]
518+ public void UnifiedProcessor_MixedImageSizes_OnlyProcessesFirst ( )
519+ {
520+ CreateTestImageFloat ( TestDirInput , "small.jpg" , 5 , 5 ) ;
521+ CreateTestImageFloat ( TestDirInput , "medium.jpg" , 10 , 10 ) ;
522+ CreateTestImageFloat ( TestDirInput , "large.jpg" , 15 , 15 ) ;
523+
524+ var config = new UnifiedProcessorConfig
525+ {
526+ CpuWorkers = 1 ,
527+ GpuWorkers = 0
528+ } ;
529+
530+ using var processor = new UnifiedProcessor ( config ) ;
531+ processor . ProcessDirectory ( TestDirInput , TestDirOutput ) ;
532+
533+ Assert . True ( Directory . Exists ( TestDirOutput ) ) ;
534+ var files = Directory . GetFiles ( TestDirOutput ) ;
535+ Assert . True ( files . Length >= 1 ) ;
536+ }
537+
538+ [ Fact ]
539+ public void ProcessDirectory_MultipleIdenticalSizeImages_ProcessesAll ( )
540+ {
541+ for ( int i = 0 ; i < 3 ; i ++ )
542+ {
543+ CreateTestImageFloat ( TestDirInput , $ "image{ i } .jpg", 20 , 20 ) ;
544+ }
545+
546+ GpuConvolutionProcessor . ProcessDirectory ( TestDirInput , TestDirOutput , Kernels . SharpenFloat , EdgeStrategy . ZeroPadding ) ;
547+
548+ Assert . Equal ( 3 , Directory . GetFiles ( TestDirOutput ) . Length ) ;
549+ }
550+
551+ [ Fact ]
552+ public void UnifiedProcessor_OnlyGpuWorkers_ProcessesCorrectly ( )
553+ {
554+ CreateTestImageFloat ( TestDirInput , "gpu1.jpg" , 10 , 10 ) ;
555+ CreateTestImageFloat ( TestDirInput , "gpu2.jpg" , 10 , 10 ) ;
556+ CreateTestImageFloat ( TestDirInput , "gpu3.jpg" , 10 , 10 ) ;
557+
558+ var config = new UnifiedProcessorConfig
559+ {
560+ CpuWorkers = 0 ,
561+ GpuWorkers = 2 ,
562+ ReaderThreads = 1 ,
563+ WriterThreads = 1
564+ } ;
565+
566+ using var processor = new UnifiedProcessor ( config ) ;
567+ processor . ProcessDirectory ( TestDirInput , TestDirOutput ) ;
568+
569+ Assert . Equal ( 3 , Directory . GetFiles ( TestDirOutput ) . Length ) ;
570+ }
571+
572+ [ Fact ]
573+ public void UnifiedProcessor_HighParallelism_ProcessesCorrectly ( )
574+ {
575+ for ( int i = 0 ; i < 8 ; i ++ )
576+ {
577+ CreateTestImageFloat ( TestDirInput , $ "parallel{ i } .jpg", 10 , 10 ) ;
578+ }
579+
580+ var config = new UnifiedProcessorConfig
581+ {
582+ CpuWorkers = 4 ,
583+ GpuWorkers = 1 ,
584+ ReaderThreads = 4 ,
585+ WriterThreads = 4
586+ } ;
587+
588+ using var processor = new UnifiedProcessor ( config ) ;
589+ processor . ProcessDirectory ( TestDirInput , TestDirOutput ) ;
590+
591+ Assert . Equal ( 8 , Directory . GetFiles ( TestDirOutput ) . Length ) ;
592+ }
593+
594+ [ Fact ]
595+ public void ConvolveGpu_AllKernelTypes_Work ( )
596+ {
597+ using var gpuProcessor = new GpuConvolutionProcessor ( ) ;
598+ var image = new float [ 10 , 10 ] ;
599+ for ( int y = 0 ; y < 10 ; y ++ )
600+ for ( int x = 0 ; x < 10 ; x ++ )
601+ image [ y , x ] = 100f ;
602+
603+ var blurResult = gpuProcessor . ConvolveGpu ( image , Kernels . BlurBoxFloat , EdgeStrategy . Extend ) ;
604+ var sharpenResult = gpuProcessor . ConvolveGpu ( image , Kernels . SharpenFloat , EdgeStrategy . Extend ) ;
605+ var laplacianResult = gpuProcessor . ConvolveGpu ( image , Kernels . LaplacianFloat , EdgeStrategy . Extend ) ;
606+
607+ Assert . NotNull ( blurResult ) ;
608+ Assert . NotNull ( sharpenResult ) ;
609+ Assert . NotNull ( laplacianResult ) ;
610+ }
464611 }
465612}
0 commit comments