use super::*;
#[derive(Debug, PartialEq)]
pub struct Expression {
keyword: grammar::Keyword,
keyword_data: Vec<String>,
}
impl Expression {
pub fn new(keyword: String, data: Vec<String>) -> Expression {
Expression {
keyword: grammar::unwrap_string(keyword),
keyword_data: data,
}
}
pub fn get_keyword_value_for_expression(&self) -> i32 {
self.keyword.value_for_command()
}
pub fn get_size_of_keyword_data(&self) -> i32 {
self.keyword_data.len() as i32
}
pub fn parse_expression(&self) {}
pub fn merge_expressions(&self, _expression_merge: Expression) -> Expression {
Expression::new(String::from("test"), vec![])
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn correct_data_length() {
let data: Vec<String> = vec![
String::from("testing"),
String::from("Testing"),
String::from("Tetign"),
];
let exp = expression::Expression::new(String::from("SELECT"), data.clone());
assert_eq!(data.len() as i32, exp.get_size_of_keyword_data());
}
}