diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-11-30 21:44:52 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-11-30 21:44:52 -0800 |
commit | 53f703416730ed277cd1b76d886d4256a0063bcb (patch) | |
tree | 09ed38b10c5f61016a2e68a21350c9d9c9f6cd4a /src/lib.rs | |
parent | a2d795d2ce787841a4f149ccf3ff25b39f73c5b5 (diff) | |
download | modelthing-53f703416730ed277cd1b76d886d4256a0063bcb.tar.gz modelthing-53f703416730ed277cd1b76d886d4256a0063bcb.zip |
move tests from in-file to separate dir
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 64 |
1 files changed, 0 insertions, 64 deletions
@@ -182,67 +182,3 @@ pub fn pp_parseerror(raw: &str, pe: ParseError<usize, (usize, &str), ()>) -> Str format!("{} {:?}", "parse error:".red().bold(), pe) }, } } - -/* ******************************** Tests ******************************* */ - -#[test] -fn test_parse_metadata() { - let raw = -r#" -[model] -name-en = "Bogus Dummy Model" -[variables] -"#.to_string(); - assert_eq!(parse_metadata(raw).unwrap(), - ModelMetadata { - name_en: "Bogus Dummy Model".to_string(), - description_en: None, - vars: vec![], - }); -} - -#[test] -fn test_load_model_entry() { - load_model_entry(Path::new("./examples/classic_gravitation/")).unwrap(); -} - -#[test] -fn test_search_models() { - assert_eq!(search_models(Path::new("./examples/")).len() > 1, true); -} - -#[test] -fn test_lexical() { - assert_eq!(&format!("{:?}", modelica_parser::parse_integer("+123").unwrap()), - "123"); - assert_eq!(&format!("{:?}", modelica_parser::parse_integer("-9").unwrap()), - "-9"); - assert_eq!(&format!("{:?}", modelica_parser::parse_float("-1.0e0").unwrap()), - "-1"); - assert_eq!(&format!("{:?}", modelica_parser::parse_float("123.456").unwrap()), - "123.456"); -} - -#[test] -fn test_parse() { - let example1 = -r#"model MinimalModel - Real x; -equation - x = 1; -end MinimalModel; -"#; - assert_eq!(&format!("{:?}", modelica_parser::parse_model(example1).unwrap()), example1); - - let example2 = -r#"model MinimalModel - parameter Real a; - Real b; -equation - connect(a, b); - a = 1; - b = ((abs(a) + 2) / 4); -end MinimalModel; -"#; - assert_eq!(&format!("{:?}", modelica_parser::parse_model(example2).unwrap()), example2); -} |