SHARE
TWEET

Untitled

a guest May 23rd, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(dead_code)]
  2. #![feature(custom_test_frameworks)]
  3. #![test_runner(crate::schema_runner)]
  4.  
  5. type Test = (&'static str, bool);
  6.  
  7. #[test_case]
  8. fn foo(x: usize) -> Test {
  9.     let name = "foo";
  10.     let result = x < 1;
  11.     (name, result)
  12. }
  13.  
  14. #[test_case]
  15. fn bar(x: usize) -> Test {
  16.     let name = "bar";
  17.     let result = x < 1;
  18.     (name, result)
  19. }
  20.  
  21. #[test_case]
  22. fn set()
  23.  
  24. #[cfg(test)]
  25. fn schema_runner(tests: &[&dyn Fn(usize) -> Test]) {
  26.     println!("running {} schema tests\n", tests.len());
  27.  
  28.     let mut pass = 0;
  29.     let mut fail = vec![];
  30.  
  31.     for (i, t) in tests.iter().enumerate() {
  32.         let (name, result) = t(i);
  33.         if result {
  34.             println!("test {} ... ok", name);
  35.             pass += 1;
  36.         } else {
  37.             println!("test {} ... FAILED", name);
  38.             fail.push(name);
  39.         }
  40.     }
  41.    
  42.     if fail.len() > 0 {
  43.         println!("\nfailures:");
  44.         for f in &fail {
  45.             println!("    {}", f);
  46.         }
  47.     }
  48.    
  49.     println!(
  50.         "\nschema test result: ok. {} passed; {} failed;",
  51.         pass, fail.len()
  52.     );
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top