@@ -887,37 +887,40 @@ mod tests {
887887 fn test_add_to_history ( ) {
888888 let temp_file = create_temp_log_file ( & [ "line" ] ) ;
889889 let mut app = App :: new ( vec ! [ temp_file. path( ) . to_path_buf( ) ] , false ) . unwrap ( ) ;
890+ let initial_len = app. filter_history . len ( ) ;
890891
891892 // Add patterns to history
892893 app. add_to_history ( "ERROR" . to_string ( ) , FilterMode :: plain ( ) ) ;
893894 app. add_to_history ( "WARN" . to_string ( ) , FilterMode :: plain ( ) ) ;
894895 app. add_to_history ( "INFO" . to_string ( ) , FilterMode :: plain ( ) ) ;
895896
896- assert_eq ! ( app. filter_history. len( ) , 3 ) ;
897+ assert_eq ! ( app. filter_history. len( ) , initial_len + 3 ) ;
897898 }
898899
899900 #[ test]
900901 fn test_add_to_history_skips_duplicates ( ) {
901902 let temp_file = create_temp_log_file ( & [ "line" ] ) ;
902903 let mut app = App :: new ( vec ! [ temp_file. path( ) . to_path_buf( ) ] , false ) . unwrap ( ) ;
904+ let initial_len = app. filter_history . len ( ) ;
903905
904- app. add_to_history ( "ERROR " . to_string ( ) , FilterMode :: plain ( ) ) ;
905- app. add_to_history ( "ERROR " . to_string ( ) , FilterMode :: plain ( ) ) ; // Duplicate - should not add
906+ app. add_to_history ( "ERROR_DUP_TEST " . to_string ( ) , FilterMode :: plain ( ) ) ;
907+ app. add_to_history ( "ERROR_DUP_TEST " . to_string ( ) , FilterMode :: plain ( ) ) ; // Duplicate - should not add
906908
907- assert_eq ! ( app. filter_history. len( ) , 1 ) ;
909+ assert_eq ! ( app. filter_history. len( ) , initial_len + 1 ) ;
908910 }
909911
910912 #[ test]
911913 fn test_add_to_history_same_pattern_different_mode ( ) {
912914 let temp_file = create_temp_log_file ( & [ "line" ] ) ;
913915 let mut app = App :: new ( vec ! [ temp_file. path( ) . to_path_buf( ) ] , false ) . unwrap ( ) ;
916+ let initial_len = app. filter_history . len ( ) ;
914917
915- app. add_to_history ( "error " . to_string ( ) , FilterMode :: plain ( ) ) ;
916- app. add_to_history ( "error " . to_string ( ) , FilterMode :: regex ( ) ) ; // Different mode - should add
918+ app. add_to_history ( "error_mode_test " . to_string ( ) , FilterMode :: plain ( ) ) ;
919+ app. add_to_history ( "error_mode_test " . to_string ( ) , FilterMode :: regex ( ) ) ; // Different mode - should add
917920
918- assert_eq ! ( app. filter_history. len( ) , 2 ) ;
919- assert ! ( !app. filter_history[ 0 ] . mode. is_regex( ) ) ;
920- assert ! ( app. filter_history[ 1 ] . mode. is_regex( ) ) ;
921+ assert_eq ! ( app. filter_history. len( ) , initial_len + 2 ) ;
922+ assert ! ( !app. filter_history[ initial_len ] . mode. is_regex( ) ) ;
923+ assert ! ( app. filter_history[ initial_len + 1 ] . mode. is_regex( ) ) ;
921924 }
922925
923926 #[ test]
0 commit comments