File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -761,6 +761,8 @@ impl Ini {
761
761
( Some ( 0 ) , Some ( end) ) => {
762
762
section = caser ( trimmed[ 1 ..end] . trim ( ) ) ;
763
763
764
+ map. entry ( section. clone ( ) ) . or_default ( ) ;
765
+
764
766
continue ;
765
767
}
766
768
( Some ( 0 ) , None ) => {
Original file line number Diff line number Diff line change @@ -231,6 +231,25 @@ fn cs() -> Result<(), Box<dyn Error>> {
231
231
Ok ( ( ) )
232
232
}
233
233
234
+ #[ test]
235
+ fn ensure_empty_sections_exist ( ) -> Result < ( ) , Box < dyn Error > > {
236
+ const FILE_CONTENTS : & str = "
237
+ [basic_section]
238
+ basic_option=basic_value
239
+ [empty_section]
240
+ " ;
241
+
242
+ let mut config = Ini :: new ( ) ;
243
+ config. read ( FILE_CONTENTS . to_owned ( ) ) ?;
244
+
245
+ assert_eq ! (
246
+ config. sections( ) ,
247
+ vec![ String :: from( "basic_section" ) , String :: from( "empty_section" ) ]
248
+ ) ;
249
+
250
+ Ok ( ( ) )
251
+ }
252
+
234
253
#[ test]
235
254
#[ cfg( feature = "indexmap" ) ]
236
255
fn sort_on_write ( ) -> Result < ( ) , Box < dyn Error > > {
You can’t perform that action at this time.
0 commit comments