diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-01-30 13:43:54 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-01-31 13:47:23 +0100 |
| commit | 7d56bd02a8e057ca2b8bcb87c4b3ec73313cec35 (patch) | |
| tree | 75927cd2d5d394cfdfa3bb03cd0d853ab1bb3d6a /talpid_openvpn_plugin/src | |
| parent | c7cdc75ee6e4232967256973f0192b6105f2ffc8 (diff) | |
| download | mullvadvpn-7d56bd02a8e057ca2b8bcb87c4b3ec73313cec35.tar.xz mullvadvpn-7d56bd02a8e057ca2b8bcb87c4b3ec73313cec35.zip | |
Add extra parse tests
Diffstat (limited to 'talpid_openvpn_plugin/src')
| -rw-r--r-- | talpid_openvpn_plugin/src/ffi/parse.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/talpid_openvpn_plugin/src/ffi/parse.rs b/talpid_openvpn_plugin/src/ffi/parse.rs index 72b46316f0..bcef72570c 100644 --- a/talpid_openvpn_plugin/src/ffi/parse.rs +++ b/talpid_openvpn_plugin/src/ffi/parse.rs @@ -103,6 +103,17 @@ mod tests { } #[test] + fn string_array_two_strings() { + let test_str1 = "foobar\0"; + let test_str2 = "barbaz\0"; + let ptr_arr = [test_str1 as *const _ as *const c_char, + test_str2 as *const _ as *const c_char, + ptr::null()]; + let result = unsafe { string_array(&ptr_arr as *const *const c_char).unwrap() }; + assert_eq!(["foobar", "barbaz"], &result[..]); + } + + #[test] fn env_one_value() { let test_str = "var_a=value_b\0"; let ptr_arr = [test_str as *const _ as *const c_char, ptr::null()]; @@ -127,4 +138,16 @@ mod tests { assert_eq!(1, env.len()); assert_eq!(Some("bar=baz "), env.get("foo").map(|s| &s[..])); } + + #[test] + fn env_two_same_key() { + let test_str1 = "foo=123\0"; + let test_str2 = "foo=abc\0"; + let ptr_arr = [test_str1 as *const _ as *const c_char, + test_str2 as *const _ as *const c_char, + ptr::null()]; + let env = unsafe { env(&ptr_arr as *const *const c_char).unwrap() }; + assert_eq!(1, env.len()); + assert_eq!(Some("abc"), env.get("foo").map(|s| &s[..])); + } } |
