summaryrefslogtreecommitdiffhomepage
path: root/talpid_openvpn_plugin/src
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-02-04 00:15:56 +0100
committerLinus Färnstrand <linus@mullvad.net>2017-02-04 00:28:52 +0100
commit16b1603abb78563bfde5964b0d19347bd0cc7533 (patch)
treeefed3d859cbd74a41a49537e9a9b81b3339e4b48 /talpid_openvpn_plugin/src
parent1c15ddfd97afeba755ab591c205785f9be7608e1 (diff)
downloadmullvadvpn-16b1603abb78563bfde5964b0d19347bd0cc7533.tar.xz
mullvadvpn-16b1603abb78563bfde5964b0d19347bd0cc7533.zip
Replace homegrown assert_pat! with assert_matches
Diffstat (limited to 'talpid_openvpn_plugin/src')
-rw-r--r--talpid_openvpn_plugin/src/ffi/parse.rs16
-rw-r--r--talpid_openvpn_plugin/src/lib.rs3
2 files changed, 5 insertions, 14 deletions
diff --git a/talpid_openvpn_plugin/src/ffi/parse.rs b/talpid_openvpn_plugin/src/ffi/parse.rs
index de8e7a16a7..db26335d27 100644
--- a/talpid_openvpn_plugin/src/ffi/parse.rs
+++ b/talpid_openvpn_plugin/src/ffi/parse.rs
@@ -70,22 +70,10 @@ mod tests {
use std::os::raw::c_char;
use std::ptr;
- /// Assert macro that fails if the given pattern does not match the given expression
- /// TODO(Linus): Very useful macro for asserting on patterns where the type does not implement
- /// Eq. Thus it should probably be moved to a general place/crate when needed in more places.
- macro_rules! assert_pat {
- ($expected:pat, $actual:expr) => {{
- if let $expected = $actual {} else {
- let msg = stringify!($expected);
- panic!("Expected {}. Got {:?}", msg, $actual);
- }
- }}
- }
-
#[test]
fn string_array_null() {
let result = unsafe { string_array(ptr::null()) };
- assert_pat!(Err(Error(ErrorKind::Null, _)), result);
+ assert_matches!(result, Err(Error(ErrorKind::Null, _)));
}
#[test]
@@ -128,7 +116,7 @@ mod tests {
let test_str = "foobar\0";
let ptr_arr = [test_str as *const _ as *const c_char, ptr::null()];
let result = unsafe { env(&ptr_arr as *const *const c_char) };
- assert_pat!(Err(Error(ErrorKind::NoEqual(_), _)), result);
+ assert_matches!(result, Err(Error(ErrorKind::NoEqual(_), _)));
}
#[test]
diff --git a/talpid_openvpn_plugin/src/lib.rs b/talpid_openvpn_plugin/src/lib.rs
index 91fcd34396..ea7a5d17ed 100644
--- a/talpid_openvpn_plugin/src/lib.rs
+++ b/talpid_openvpn_plugin/src/lib.rs
@@ -4,6 +4,9 @@ extern crate lazy_static;
#[macro_use]
extern crate error_chain;
+#[macro_use]
+extern crate assert_matches;
+
mod ffi;
/// Publicly export the functions making up the public interface of the plugin. These are the C FFI