summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Chambers <chris.chambers@peanutcode.com>2014-12-18 08:51:22 -0600
committerChristopher Chambers <chris.chambers@peanutcode.com>2014-12-18 12:47:13 -0600
commitce879aacbc77de5523042ddead8aee1d6a47c15c (patch)
treedd5d9b1b4675ca3c5bbd32160e5f9c8034a64386
parent0fa1990fbde3d36a757954ef2efa07aa734c40e9 (diff)
Updates tests in macro.rs and cmath.rs.
macro.rs - Removes make_string_vec in favor of the vec! macro. - Updates test_parse_process_args with vec!. cmath.rs - Adds needed 'extern crate libc;' declaration. - bindgen! invocation now references math.h as "/usr/include/math.h", which should be pretty universal. Clang was not able to find the file using just "math.h". - Moves contents of main method into a #[test] method.
-rw-r--r--src/macro.rs19
-rw-r--r--tests/cmath.rs7
2 files changed, 12 insertions, 14 deletions
diff --git a/src/macro.rs b/src/macro.rs
index f4a1839c..6f16955a 100644
--- a/src/macro.rs
+++ b/src/macro.rs
@@ -311,18 +311,13 @@ impl base::MacResult for BindgenResult {
}
}
-#[cfg(test)]
-fn make_string_vec(parts: &[&str]) -> Vec<String> {
- parts.iter().map(|p| p.to_string()).collect()
-}
-
#[test]
fn test_parse_process_args() {
- assert_eq!(parse_process_args("a b c"), make_string_vec(["a", "b", "c"]));
- assert_eq!(parse_process_args("a \"b\" c"), make_string_vec(["a", "b", "c"]));
- assert_eq!(parse_process_args("a \'b\' c"), make_string_vec(["a", "b", "c"]));
- assert_eq!(parse_process_args("a \"b c\""), make_string_vec(["a", "b c"]));
- assert_eq!(parse_process_args("a \'\"b\"\' c"), make_string_vec(["a", "\"b\"", "c"]));
- assert_eq!(parse_process_args("a b\\ c"), make_string_vec(["a", "b c"]));
- assert_eq!(parse_process_args("a b c\\"), make_string_vec(["a", "b", "c\\"]));
+ assert_eq!(parse_process_args("a b c"), vec!("a", "b", "c"));
+ assert_eq!(parse_process_args("a \"b\" c"), vec!("a", "b", "c"));
+ assert_eq!(parse_process_args("a \'b\' c"), vec!("a", "b", "c"));
+ assert_eq!(parse_process_args("a \"b c\""), vec!("a", "b c"));
+ assert_eq!(parse_process_args("a \'\"b\"\' c"), vec!("a", "\"b\"", "c"));
+ assert_eq!(parse_process_args("a b\\ c"), vec!("a", "b c"));
+ assert_eq!(parse_process_args("a b c\\"), vec!("a", "b", "c\\"));
}
diff --git a/tests/cmath.rs b/tests/cmath.rs
index 477184b7..97217c53 100644
--- a/tests/cmath.rs
+++ b/tests/cmath.rs
@@ -3,15 +3,18 @@
#[phase(plugin)]
extern crate bindgen;
+extern crate libc;
+
#[allow(dead_code)]
#[allow(non_snake_case)]
#[allow(non_camel_case_types)]
#[allow(non_upper_case_globals)]
pub mod ffi {
- bindgen!("math.h", link = "m")
+ bindgen!("/usr/include/math.h", link = "m")
}
-fn main() {
+#[test]
+fn test_floor_is_bound_and_callable() {
unsafe {
assert_eq!(ffi::floor( 2.7), 2.0);
assert_eq!(ffi::floor(-2.7), -3.0);