MCPcopy Create free account
hub / github.com/cosdata/cosdata / test_condition_parser

Function test_condition_parser

src/cosql/condition.rs:197–262  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195
196 #[test]
197 fn test_condition_parser() {
198 let values = [
199 (
200 "$age < 18",
201 Condition::Binary(BinaryCondition {
202 left: "age".to_string(),
203 operator: BinaryConditionOperator::LessThan,
204 right: Value::Int(18),
205 }),
206 ),
207 (
208 r#"(((($programming_language == "Rust"))))"#,
209 Condition::Binary(BinaryCondition {
210 left: "programming_language".to_string(),
211 operator: BinaryConditionOperator::Equality,
212 right: Value::String("Rust".to_string()),
213 }),
214 ),
215 (
216 r#"$programming_language == "Rust" and $salary >= 1000000"#,
217 Condition::Logical(Box::new(LogicalCondition {
218 left: Condition::Binary(BinaryCondition {
219 left: "programming_language".to_string(),
220 operator: BinaryConditionOperator::Equality,
221 right: Value::String("Rust".to_string()),
222 }),
223 operator: LogicalOperator::And,
224 right: Condition::Binary(BinaryCondition {
225 left: "salary".to_string(),
226 operator: BinaryConditionOperator::GreaterEqualThan,
227 right: Value::Int(1000000),
228 }),
229 })),
230 ),
231 (
232 r#"($programming_language == "Rust" and $salary >= 1000000) or $age < 18"#,
233 Condition::Logical(Box::new(LogicalCondition {
234 left: Condition::Logical(Box::new(LogicalCondition {
235 left: Condition::Binary(BinaryCondition {
236 left: "programming_language".to_string(),
237 operator: BinaryConditionOperator::Equality,
238 right: Value::String("Rust".to_string()),
239 }),
240 operator: LogicalOperator::And,
241 right: Condition::Binary(BinaryCondition {
242 left: "salary".to_string(),
243 operator: BinaryConditionOperator::GreaterEqualThan,
244 right: Value::Int(1000000),
245 }),
246 })),
247 operator: LogicalOperator::Or,
248 right: Condition::Binary(BinaryCondition {
249 left: "age".to_string(),
250 operator: BinaryConditionOperator::LessThan,
251 right: Value::Int(18),
252 }),
253 })),
254 ),

Callers

nothing calls this directly

Calls 1

parse_conditionFunction · 0.85

Tested by

no test coverage detected