add some tests for test_func
This commit is contained in:
parent
be4028e697
commit
aef2b9c24c
@ -30,7 +30,7 @@ impl BackingFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref VALID_VARIABLES: Vec<char> = "xeπ".chars().collect();
|
static ref VALID_VARIABLES: Vec<char> = "xXEπ".chars().collect();
|
||||||
static ref LETTERS: Vec<char> = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
static ref LETTERS: Vec<char> = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
.chars()
|
.chars()
|
||||||
.collect();
|
.collect();
|
||||||
@ -130,6 +130,29 @@ pub fn test_func(function_string: &str) -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used for testing: passes function to `add_asterisks` before running `test_func`
|
||||||
|
#[cfg(test)]
|
||||||
|
fn test_func_helper(function_string: &str) -> Option<String> {
|
||||||
|
test_func(&add_asterisks(function_string.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_func_test() {
|
||||||
|
// These shouldn't fail
|
||||||
|
assert!(test_func_helper("x^2").is_none());
|
||||||
|
assert!(test_func_helper("2x").is_none());
|
||||||
|
// assert!(test_func_helper("e^x").is_none()); // need to fix!!! PR to exmex
|
||||||
|
assert!(test_func_helper("E^x").is_none());
|
||||||
|
assert!(test_func_helper("log10(x)").is_none());
|
||||||
|
assert!(test_func_helper("xxxxx").is_none());
|
||||||
|
|
||||||
|
// Expect these to fail
|
||||||
|
assert!(test_func_helper("a").is_some());
|
||||||
|
assert!(test_func_helper("l^2").is_some());
|
||||||
|
assert!(test_func_helper("log222(x)").is_some());
|
||||||
|
assert!(test_func_helper("abcdef").is_some());
|
||||||
|
}
|
||||||
|
|
||||||
// Tests to make sure my cursed function works as intended
|
// Tests to make sure my cursed function works as intended
|
||||||
#[test]
|
#[test]
|
||||||
fn asterisk_test() {
|
fn asterisk_test() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user