@@ -640,3 +640,110 @@ fn multiple_names() {
640640
641641 assert_eq ! ( actual, expected) ;
642642}
643+
644+ #[ test]
645+ fn multiple_names_max_depth_2 ( ) {
646+ let workspace = SampleWorkspace :: default ( ) ;
647+ let actual = Command :: new ( PDU )
648+ . with_current_dir ( & workspace)
649+ . with_arg ( "--quantity=apparent-size" )
650+ . with_arg ( "--total-width=100" )
651+ . with_arg ( "--max-depth=2" )
652+ . with_arg ( "nested" )
653+ . with_arg ( "flat" )
654+ . with_arg ( "empty-dir" )
655+ . pipe ( stdio)
656+ . output ( )
657+ . expect ( "spawn command" )
658+ . pipe ( stdout_text) ;
659+ eprintln ! ( "ACTUAL:\n {actual}\n " ) ;
660+
661+ let mut data_tree = [ "nested" , "flat" , "empty-dir" ]
662+ . iter ( )
663+ . map ( |name| {
664+ let builder = FsTreeBuilder {
665+ root : workspace. to_path_buf ( ) . join ( name) ,
666+ size_getter : GetApparentSize ,
667+ reporter : ErrorOnlyReporter :: new ( ErrorReport :: SILENT ) ,
668+ max_depth : 1 ,
669+ } ;
670+ let mut data_tree: DataTree < OsStringDisplay , _ > = builder. into ( ) ;
671+ * data_tree. name_mut ( ) = OsStringDisplay :: os_string_from ( name) ;
672+ data_tree
673+ } )
674+ . pipe ( |children| {
675+ DataTree :: dir (
676+ OsStringDisplay :: os_string_from ( "(total)" ) ,
677+ 0 . into ( ) ,
678+ children. collect ( ) ,
679+ )
680+ } )
681+ . into_par_sorted ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
682+ data_tree. par_cull_insignificant_data ( 0.01 ) ;
683+ let visualizer = Visualizer :: < OsStringDisplay , _ > {
684+ data_tree : & data_tree,
685+ bytes_format : BytesFormat :: MetricUnits ,
686+ direction : Direction :: BottomUp ,
687+ bar_alignment : BarAlignment :: Left ,
688+ column_width_distribution : ColumnWidthDistribution :: total ( 100 ) ,
689+ } ;
690+ let expected = format ! ( "{visualizer}" ) ;
691+ let expected = expected. trim_end ( ) ;
692+ eprintln ! ( "EXPECTED:\n {expected}\n " ) ;
693+
694+ assert_eq ! ( actual, expected) ;
695+ }
696+
697+ #[ test]
698+ fn multiple_names_max_depth_1 ( ) {
699+ let workspace = SampleWorkspace :: default ( ) ;
700+ let actual = Command :: new ( PDU )
701+ . with_current_dir ( & workspace)
702+ . with_arg ( "--quantity=apparent-size" )
703+ . with_arg ( "--total-width=100" )
704+ . with_arg ( "--max-depth=1" )
705+ . with_arg ( "nested" )
706+ . with_arg ( "flat" )
707+ . with_arg ( "empty-dir" )
708+ . pipe ( stdio)
709+ . output ( )
710+ . expect ( "spawn command" )
711+ . pipe ( stdout_text) ;
712+ eprintln ! ( "ACTUAL:\n {actual}\n " ) ;
713+
714+ let mut data_tree = [ "nested" , "flat" , "empty-dir" ]
715+ . iter ( )
716+ . map ( |name| {
717+ let builder = FsTreeBuilder {
718+ root : workspace. to_path_buf ( ) . join ( name) ,
719+ size_getter : GetApparentSize ,
720+ reporter : ErrorOnlyReporter :: new ( ErrorReport :: SILENT ) ,
721+ max_depth : 10 ,
722+ } ;
723+ let mut data_tree: DataTree < OsStringDisplay , _ > = builder. into ( ) ;
724+ * data_tree. name_mut ( ) = OsStringDisplay :: os_string_from ( name) ;
725+ data_tree
726+ } )
727+ . pipe ( |children| {
728+ DataTree :: dir (
729+ OsStringDisplay :: os_string_from ( "(total)" ) ,
730+ 0 . into ( ) ,
731+ children. collect ( ) ,
732+ )
733+ } )
734+ . into_par_retained ( |_, _| false )
735+ . into_par_sorted ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
736+ data_tree. par_cull_insignificant_data ( 0.01 ) ;
737+ let visualizer = Visualizer :: < OsStringDisplay , _ > {
738+ data_tree : & data_tree,
739+ bytes_format : BytesFormat :: MetricUnits ,
740+ direction : Direction :: BottomUp ,
741+ bar_alignment : BarAlignment :: Left ,
742+ column_width_distribution : ColumnWidthDistribution :: total ( 100 ) ,
743+ } ;
744+ let expected = format ! ( "{visualizer}" ) ;
745+ let expected = expected. trim_end ( ) ;
746+ eprintln ! ( "EXPECTED:\n {expected}\n " ) ;
747+
748+ assert_eq ! ( actual, expected) ;
749+ }
0 commit comments