use std::borrow::Cow;
-use syntax::{ast, AstToken, TextRange, TextSize};
-use test_utils::mark;
+use syntax::{ast, ast::IsString, AstToken, TextRange, TextSize};
use crate::{AssistContext, AssistId, AssistKind, Assists};
if matches!(value, Cow::Borrowed(_)) {
// Avoid replacing the whole string to better position the cursor.
edit.insert(token.syntax().text_range().start(), format!("r{}", hashes));
- edit.insert(token.syntax().text_range().end(), format!("{}", hashes));
+ edit.insert(token.syntax().text_range().end(), hashes);
} else {
edit.replace(
token.syntax().text_range(),
let internal_text = &text[token.text_range_between_quotes()? - text_range.start()];
if existing_hashes == required_hashes(internal_text) {
- mark::hit!(cant_remove_required_hash);
+ cov_mark::hit!(cant_remove_required_hash);
return None;
}
res
}
-#[test]
-fn test_required_hashes() {
- assert_eq!(0, required_hashes("abc"));
- assert_eq!(0, required_hashes("###"));
- assert_eq!(1, required_hashes("\""));
- assert_eq!(2, required_hashes("\"#abc"));
- assert_eq!(0, required_hashes("#abc"));
- assert_eq!(3, required_hashes("#ab\"##c"));
- assert_eq!(5, required_hashes("#ab\"##\"####c"));
-}
-
#[cfg(test)]
mod tests {
- use test_utils::mark;
-
use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
use super::*;
+ #[test]
+ fn test_required_hashes() {
+ assert_eq!(0, required_hashes("abc"));
+ assert_eq!(0, required_hashes("###"));
+ assert_eq!(1, required_hashes("\""));
+ assert_eq!(2, required_hashes("\"#abc"));
+ assert_eq!(0, required_hashes("#abc"));
+ assert_eq!(3, required_hashes("#ab\"##c"));
+ assert_eq!(5, required_hashes("#ab\"##\"####c"));
+ }
+
#[test]
fn make_raw_string_target() {
check_assist_target(
#[test]
fn cant_remove_required_hash() {
- mark::check!(cant_remove_required_hash);
+ cov_mark::check!(cant_remove_required_hash);
check_assist_not_applicable(
remove_hash,
r##"