Skip to content

Commit

Permalink
chore: some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanbohan committed Jul 19, 2023
1 parent 27d3187 commit 7824288
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ pub struct AggregateExpr {
impl fmt::Display for AggregateExpr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", token_display(self.op.id()))?;
// let mut v: Vec<String> = vec![token_display(self.op.id()).into()];

// modifier
{
Expand Down
23 changes: 21 additions & 2 deletions src/parser/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,26 @@ mod tests {

#[test]
fn test_args_display() {
let args = FunctionArgs::new_args(Expr::from(VectorSelector::from("up")));
assert_eq!("up", args.to_string())
let cases = vec![
(
FunctionArgs::new_args(Expr::from(VectorSelector::from("up"))),
"up",
),
(
FunctionArgs::empty_args()
.append_args(Expr::from("src1"))
.append_args(Expr::from("src2"))
.append_args(Expr::from("src3")),
r#""src1", "src2", "src3""#,
),
];

for (args, expect) in cases {
assert_eq!(
expect,
args.to_string(),
"{args:?} and {expect} does not match"
)
}
}
}
1 change: 1 addition & 0 deletions src/util/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ mod tests {
#[test]
fn test_display_duration() {
let ds = vec![
(Duration::ZERO, "0s"),
(Duration::from_millis(324), "324ms"),
(Duration::from_secs(3), "3s"),
(MINUTE_DURATION * 5, "5m"),
Expand Down

0 comments on commit 7824288

Please sign in to comment.