UPDATE: Dump of initial files
This commit is contained in:
73
base/src/expressions/lexer/test/test_tables.rs
Normal file
73
base/src/expressions/lexer/test/test_tables.rs
Normal file
@@ -0,0 +1,73 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::expressions::{
|
||||
lexer::{Lexer, LexerMode},
|
||||
token::{TableReference, TableSpecifier, TokenType::*},
|
||||
};
|
||||
use crate::language::get_language;
|
||||
use crate::locale::get_locale;
|
||||
|
||||
fn new_lexer(formula: &str) -> Lexer {
|
||||
let locale = get_locale("en").unwrap();
|
||||
let language = get_language("en").unwrap();
|
||||
Lexer::new(formula, LexerMode::A1, locale, language)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_this_row() {
|
||||
let mut lx = new_lexer("tbInfo[[#This Row], [Jan]:[Dec]]");
|
||||
assert_eq!(
|
||||
lx.next_token(),
|
||||
StructuredReference {
|
||||
table_name: "tbInfo".to_string(),
|
||||
specifier: Some(TableSpecifier::ThisRow),
|
||||
table_reference: Some(TableReference::RangeReference((
|
||||
"Jan".to_string(),
|
||||
"Dec".to_string()
|
||||
)))
|
||||
}
|
||||
);
|
||||
assert_eq!(lx.next_token(), EOF);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_no_specifier() {
|
||||
let mut lx = new_lexer("tbInfo[December]");
|
||||
assert_eq!(
|
||||
lx.next_token(),
|
||||
StructuredReference {
|
||||
table_name: "tbInfo".to_string(),
|
||||
specifier: None,
|
||||
table_reference: Some(TableReference::ColumnReference("December".to_string()))
|
||||
}
|
||||
);
|
||||
assert_eq!(lx.next_token(), EOF);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_no_specifier_white_spaces() {
|
||||
let mut lx = new_lexer("tbInfo[[First Month]]");
|
||||
assert_eq!(
|
||||
lx.next_token(),
|
||||
StructuredReference {
|
||||
table_name: "tbInfo".to_string(),
|
||||
specifier: None,
|
||||
table_reference: Some(TableReference::ColumnReference("First Month".to_string()))
|
||||
}
|
||||
);
|
||||
assert_eq!(lx.next_token(), EOF);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_totals_no_reference() {
|
||||
let mut lx = new_lexer("tbInfo[#Totals]");
|
||||
assert_eq!(
|
||||
lx.next_token(),
|
||||
StructuredReference {
|
||||
table_name: "tbInfo".to_string(),
|
||||
specifier: Some(TableSpecifier::Totals),
|
||||
table_reference: None
|
||||
}
|
||||
);
|
||||
assert_eq!(lx.next_token(), EOF);
|
||||
}
|
||||
Reference in New Issue
Block a user