@@ -10,18 +10,20 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
10
10
let mut test_buf = [ 0u16 ; 128 ] ;
11
11
12
12
/* Test retrieving list of environment variable names */
13
- let cur_env_vec = shell. get_envs ( ) ;
13
+ let mut cur_env_vec = shell. get_envs ( ) ;
14
14
assert_eq ! (
15
- * cur_env_vec. first ( ) . unwrap( ) ,
15
+ cur_env_vec. next ( ) . unwrap( ) ,
16
16
CStr16 :: from_str_with_buf( "path" , & mut test_buf) . unwrap( )
17
17
) ;
18
18
assert_eq ! (
19
- * cur_env_vec. get ( 1 ) . unwrap( ) ,
19
+ cur_env_vec. next ( ) . unwrap( ) ,
20
20
CStr16 :: from_str_with_buf( "nonesting" , & mut test_buf) . unwrap( )
21
21
) ;
22
- let default_len = cur_env_vec. len ( ) ;
22
+ let cur_env_vec = shell. get_envs ( ) ;
23
+ let default_len = cur_env_vec. count ( ) ;
23
24
24
25
/* Test setting and getting a specific environment variable */
26
+ let cur_env_vec = shell. get_envs ( ) ;
25
27
let mut test_env_buf = [ 0u16 ; 32 ] ;
26
28
let test_var = CStr16 :: from_str_with_buf ( "test_var" , & mut test_env_buf) . unwrap ( ) ;
27
29
let mut test_val_buf = [ 0u16 ; 32 ] ;
@@ -34,10 +36,24 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
34
36
. expect ( "Could not get environment variable" ) ;
35
37
assert_eq ! ( cur_env_str, test_val) ;
36
38
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) ;
38
46
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 ) ;
41
57
42
58
/* Test deleting environment variable */
43
59
let test_val = CStr16 :: from_str_with_buf ( "" , & mut test_val_buf) . unwrap ( ) ;
@@ -46,8 +62,15 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
46
62
assert ! ( shell. get_env( test_var) . is_none( ) ) ;
47
63
48
64
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) ;
51
74
}
52
75
53
76
/// Test ``get_cur_dir()`` and ``set_cur_dir()``
0 commit comments