summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--talpid_openvpn_plugin/Cargo.lock7
-rw-r--r--talpid_openvpn_plugin/Cargo.toml1
-rw-r--r--talpid_openvpn_plugin/src/ffi/parse.rs16
-rw-r--r--talpid_openvpn_plugin/src/lib.rs3
4 files changed, 13 insertions, 14 deletions
diff --git a/talpid_openvpn_plugin/Cargo.lock b/talpid_openvpn_plugin/Cargo.lock
index 78d4f1057a..2aa2632afa 100644
--- a/talpid_openvpn_plugin/Cargo.lock
+++ b/talpid_openvpn_plugin/Cargo.lock
@@ -2,11 +2,17 @@
name = "talpid_openvpn_plugin"
version = "0.1.0"
dependencies = [
+ "assert_matches 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "assert_matches"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "backtrace"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -91,6 +97,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
+"checksum assert_matches 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9aa85694f8820620d0df15526544e1c3fbbac7ba3874781d874d7d6499a53724"
"checksum backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f551bc2ddd53aea015d453ef0b635af89444afa5ed2405dd0b2062ad5d600d80"
"checksum backtrace-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3602e8d8c43336088a8505fa55cae2b3884a9be29440863a11528a42f46f6bb7"
"checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c"
diff --git a/talpid_openvpn_plugin/Cargo.toml b/talpid_openvpn_plugin/Cargo.toml
index 8eff4c9c27..03243c603a 100644
--- a/talpid_openvpn_plugin/Cargo.toml
+++ b/talpid_openvpn_plugin/Cargo.toml
@@ -9,3 +9,4 @@ crate-type = ["dylib"]
[dependencies]
lazy_static = "0.2"
error-chain = "0.8"
+assert_matches = "1.0"
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