Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a test case for hover docs #1311

Merged
merged 2 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading