Skip to content

Commit

Permalink
added a test case for hover docs (#1311)
Browse files Browse the repository at this point in the history
added test-case for hover docs

Signed-off-by: d4v1d03 <a_pandey1@ce.iitr.ac.in>
  • Loading branch information
d4v1d03 committed May 14, 2024
1 parent e2c778f commit 3ac7a66
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions kclvm/tools/src/LSP/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ fn build_func_hover_content(func_ty: &FunctionType, name: String) -> Vec<String>

#[cfg(test)]
mod tests {
use crate::hover::docs_to_hover;
use std::path::PathBuf;

use kclvm_error::Position as KCLPos;
Expand Down Expand Up @@ -227,6 +228,42 @@ mod tests {
}
}

#[test]
#[bench_test]
fn test_docs_to_hover_multiple_docs() {
// Given multiple documentation strings
let docs = vec![
"Documentation string 1".to_string(),
"Documentation string 2".to_string(),
"Documentation string 3".to_string(),
];

// When converting to hover content
let hover = docs_to_hover(docs.clone());

// Then the result should be a Hover object with an Array of MarkedString::String
assert!(hover.is_some());
let hover = hover.unwrap();
match hover.contents {
lsp_types::HoverContents::Array(vec) => {
assert_eq!(vec.len(), 3);
assert_eq!(
vec[0],
MarkedString::String("Documentation string 1".to_string())
);
assert_eq!(
vec[1],
MarkedString::String("Documentation string 2".to_string())
);
assert_eq!(
vec[2],
MarkedString::String("Documentation string 3".to_string())
);
}
_ => panic!("Unexpected hover contents"),
}
}

#[test]
#[bench_test]
fn schema_doc_hover_test1() {
Expand Down

0 comments on commit 3ac7a66

Please sign in to comment.