@@ -505,6 +505,22 @@ func TestSlices(t *testing.T) {
505
505
}
506
506
507
507
// Check result dimensions
508
+ checkSlicesDimensions (t , result , data )
509
+
510
+ // Test that non-empty values are deidentified
511
+ checkNonEmptyValuesDeidentified (t , result , data )
512
+
513
+ // Test that empty values remain empty
514
+ checkEmptyValuesRemainEmpty (t , result )
515
+
516
+ // Test deterministic behavior
517
+ checkDeterministicBehavior (t , d , data , columnTypes , columnNames , result )
518
+
519
+ // Test with different column names (should produce different results)
520
+ checkDifferentColumnNames (t , data , columnTypes , result )
521
+ }
522
+
523
+ func checkSlicesDimensions (t * testing.T , result , data [][]string ) {
508
524
if len (result ) != len (data ) {
509
525
t .Errorf ("Expected %d rows, got %d" , len (data ), len (result ))
510
526
}
@@ -514,21 +530,24 @@ func TestSlices(t *testing.T) {
514
530
t .Errorf ("Row %d: expected %d columns, got %d" , i , len (data [i ]), len (row ))
515
531
}
516
532
}
533
+ }
517
534
518
- // Test that non-empty values are deidentified
535
+ func checkNonEmptyValuesDeidentified ( t * testing. T , result , data [][] string ) {
519
536
if result [0 ][0 ] == data [0 ][0 ] && data [0 ][0 ] != "" {
520
537
t .Error ("Name should be deidentified" )
521
538
}
522
539
if result [0 ][1 ] == data [0 ][1 ] && data [0 ][1 ] != "" {
523
540
t .Error ("Email should be deidentified" )
524
541
}
542
+ }
525
543
526
- // Test that empty values remain empty
544
+ func checkEmptyValuesRemainEmpty ( t * testing. T , result [][] string ) {
527
545
if result [3 ][0 ] != "" || result [3 ][1 ] != "" {
528
546
t .Error ("Empty values should remain empty" )
529
547
}
548
+ }
530
549
531
- // Test deterministic behavior
550
+ func checkDeterministicBehavior ( t * testing. T , d * Deidentifier , data [][] string , columnTypes [] DataType , columnNames [] string , result [][] string ) {
532
551
result2 , err := d .Slices (data , columnTypes , columnNames )
533
552
if err != nil {
534
553
t .Fatalf ("Second Slices failed: %v" , err )
@@ -537,8 +556,9 @@ func TestSlices(t *testing.T) {
537
556
if result [0 ][0 ] != result2 [0 ][0 ] {
538
557
t .Error ("Deidentification should be deterministic" )
539
558
}
559
+ }
540
560
541
- // Test with different column names (should produce different results)
561
+ func checkDifferentColumnNames ( t * testing. T , data [][] string , columnTypes [] DataType , result [][] string ) {
542
562
// Create a fresh deidentifier to ensure clean mapping table
543
563
d2 := NewDeidentifier ("test-secret-key-3" )
544
564
differentColumnNames := []string {"customer_name" , "customer_email" , "customer_phone" , "customer_ssn" }
0 commit comments