@@ -10,18 +10,20 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
1010 let mut test_buf = [ 0u16 ; 128 ] ;
1111
1212 /* Test retrieving list of environment variable names */
13- let cur_env_vec = shell. get_envs ( ) ;
13+ let mut cur_env_vec = shell. get_envs ( ) ;
1414 assert_eq ! (
15- * cur_env_vec. first ( ) . unwrap( ) ,
15+ cur_env_vec. next ( ) . unwrap( ) ,
1616 CStr16 :: from_str_with_buf( "path" , & mut test_buf) . unwrap( )
1717 ) ;
1818 assert_eq ! (
19- * cur_env_vec. get ( 1 ) . unwrap( ) ,
19+ cur_env_vec. next ( ) . unwrap( ) ,
2020 CStr16 :: from_str_with_buf( "nonesting" , & mut test_buf) . unwrap( )
2121 ) ;
22- let default_len = cur_env_vec. len ( ) ;
22+ let cur_env_vec = shell. get_envs ( ) ;
23+ let default_len = cur_env_vec. count ( ) ;
2324
2425 /* Test setting and getting a specific environment variable */
26+ let cur_env_vec = shell. get_envs ( ) ;
2527 let mut test_env_buf = [ 0u16 ; 32 ] ;
2628 let test_var = CStr16 :: from_str_with_buf ( "test_var" , & mut test_env_buf) . unwrap ( ) ;
2729 let mut test_val_buf = [ 0u16 ; 32 ] ;
@@ -34,10 +36,24 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
3436 . expect ( "Could not get environment variable" ) ;
3537 assert_eq ! ( cur_env_str, test_val) ;
3638
37- assert ! ( !cur_env_vec. contains( & test_var) ) ;
39+ let mut found_var = false ;
40+ for env_var in cur_env_vec {
41+ if env_var == test_var {
42+ found_var = true ;
43+ }
44+ }
45+ assert ! ( !found_var) ;
3846 let cur_env_vec = shell. get_envs ( ) ;
39- assert ! ( cur_env_vec. contains( & test_var) ) ;
40- assert_eq ! ( cur_env_vec. len( ) , default_len + 1 ) ;
47+ let mut found_var = false ;
48+ for env_var in cur_env_vec {
49+ if env_var == test_var {
50+ found_var = true ;
51+ }
52+ }
53+ assert ! ( found_var) ;
54+
55+ let cur_env_vec = shell. get_envs ( ) ;
56+ assert_eq ! ( cur_env_vec. count( ) , default_len + 1 ) ;
4157
4258 /* Test deleting environment variable */
4359 let test_val = CStr16 :: from_str_with_buf ( "" , & mut test_val_buf) . unwrap ( ) ;
@@ -46,8 +62,15 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
4662 assert ! ( shell. get_env( test_var) . is_none( ) ) ;
4763
4864 let cur_env_vec = shell. get_envs ( ) ;
49- assert ! ( !cur_env_vec. contains( & test_var) ) ;
50- assert_eq ! ( cur_env_vec. len( ) , default_len) ;
65+ let mut found_var = false ;
66+ for env_var in cur_env_vec {
67+ if env_var == test_var {
68+ found_var = true ;
69+ }
70+ }
71+ assert ! ( !found_var) ;
72+ let cur_env_vec = shell. get_envs ( ) ;
73+ assert_eq ! ( cur_env_vec. count( ) , default_len) ;
5174}
5275
5376/// Test ``get_cur_dir()`` and ``set_cur_dir()``
0 commit comments