2026-03-09 10:58:55 +00:00

17 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Assorted testing utilities."><title>test_utils - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-77263533.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="test_utils" data-themes="" data-resource-suffix="" data-rustdoc-version="1.94.0 (4a4ef493e 2026-03-02)" data-channel="1.94.0" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-b897f86f.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-7bab91a1.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-ffcac47a.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Crate test_utils</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../test_utils/index.html">test_<wbr>utils</a><span class="version">0.0.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#constants" title="Constants">Constants</a></li><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>test_<wbr>utils</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/test_utils/lib.rs.html#1-508">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Assorted testing utilities.</p>
<p>Most notable things are:</p>
<ul>
<li>Rich text comparison, which outputs a diff.</li>
<li>Extracting markup (mainly, <code>$0</code> markers) out of fixture strings.</li>
<li>marks (see the eponymous module).</li>
</ul>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="assert_linear/index.html" title="mod test_utils::assert_linear">assert_<wbr>linear</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dd>Checks that a set of measurements looks like a linear function rather than
like a quadratic function. Algorithm:</dd><dt><a class="mod" href="bench_fixture/index.html" title="mod test_utils::bench_fixture">bench_<wbr>fixture</a></dt><dd>Generates large snippets of Rust code for usage in the benchmarks.</dd><dt><a class="mod" href="fixture/index.html" title="mod test_utils::fixture">fixture</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dd>Defines <code>Fixture</code> a convenient way to describe the initial state of
rust-analyzer database from a single string.</dd></dl><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro.assert_eq_text.html" title="macro test_utils::assert_eq_text">assert_<wbr>eq_<wbr>text</a></dt><dd>Asserts that two strings are equal, otherwise displays a rich diff between them.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.AssertLinear.html" title="struct test_utils::AssertLinear">Assert<wbr>Linear</a></dt><dt><a class="struct" href="struct.Fixture.html" title="struct test_utils::Fixture">Fixture</a></dt><dt><a class="struct" href="struct.FixtureWithProjectMeta.html" title="struct test_utils::FixtureWithProjectMeta">Fixture<wbr>With<wbr>Project<wbr>Meta</a></dt><dt><a class="struct" href="struct.MiniCore.html" title="struct test_utils::MiniCore">Mini<wbr>Core</a></dt></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.LineAnnotation.html" title="enum test_utils::LineAnnotation">Line<wbr>Annotation</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dt><a class="enum" href="enum.RangeOrOffset.html" title="enum test_utils::RangeOrOffset">Range<wbr>OrOffset</a></dt></dl><h2 id="constants" class="section-header">Constants<a href="#constants" class="anchor">§</a></h2><dl class="item-table"><dt><a class="constant" href="constant.CURSOR_MARKER.html" title="constant test_utils::CURSOR_MARKER">CURSOR_<wbr>MARKER</a></dt><dt><a class="constant" href="constant.ESCAPED_CURSOR_MARKER.html" title="constant test_utils::ESCAPED_CURSOR_MARKER">ESCAPED_<wbr>CURSOR_<wbr>MARKER</a></dt></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.__diff.html" title="fn test_utils::__diff">__diff</a></dt><dt><a class="fn" href="fn.add_cursor.html" title="fn test_utils::add_cursor">add_<wbr>cursor</a></dt><dd>Inserts <code>$0</code> marker into the <code>text</code> at <code>offset</code>.</dd><dt><a class="fn" href="fn.bench.html" title="fn test_utils::bench">bench</a></dt><dd>Utility for writing benchmark tests.</dd><dt><a class="fn" href="fn.ensure_file_contents.html" title="fn test_utils::ensure_file_contents">ensure_<wbr>file_<wbr>contents</a></dt><dd>Checks that the <code>file</code> has the specified <code>contents</code>. If that is not the
case, updates the file and then fails the test.</dd><dt><a class="fn" href="fn.extract_annotations.html" title="fn test_utils::extract_annotations">extract_<wbr>annotations</a></dt><dd>Extracts <code>//^^^ some text</code> annotations.</dd><dt><a class="fn" href="fn.extract_line_annotations.html" title="fn test_utils::extract_line_annotations">extract_<wbr>line_<wbr>annotations</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dt><a class="fn" href="fn.extract_offset.html" title="fn test_utils::extract_offset">extract_<wbr>offset</a></dt><dd>Infallible version of <code>try_extract_offset()</code>.</dd><dt><a class="fn" href="fn.extract_range.html" title="fn test_utils::extract_range">extract_<wbr>range</a></dt><dd>Infallible version of <code>try_extract_range()</code>.</dd><dt><a class="fn" href="fn.extract_range_or_offset.html" title="fn test_utils::extract_range_or_offset">extract_<wbr>range_<wbr>or_<wbr>offset</a></dt><dd>Extracts <code>TextRange</code> or <code>TextSize</code> depending on the amount of <code>$0</code> markers
found in <code>text</code>.</dd><dt><a class="fn" href="fn.extract_tags.html" title="fn test_utils::extract_tags">extract_<wbr>tags</a></dt><dd>Extracts ranges, marked with <code>&lt;tag&gt; &lt;/tag&gt;</code> pairs from the <code>text</code></dd><dt><a class="fn" href="fn.format_diff.html" title="fn test_utils::format_diff">format_<wbr>diff</a></dt><dt><a class="fn" href="fn.normalize_newlines.html" title="fn test_utils::normalize_newlines">normalize_<wbr>newlines</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dt><a class="fn" href="fn.project_root.html" title="fn test_utils::project_root">project_<wbr>root</a></dt><dd>Returns the path to the root directory of <code>rust-analyzer</code> project.</dd><dt><a class="fn" href="fn.skip_slow_tests.html" title="fn test_utils::skip_slow_tests">skip_<wbr>slow_<wbr>tests</a></dt><dd>Returns <code>false</code> if slow tests should not run, otherwise returns <code>true</code> and
also creates a file at <code>./target/.slow_tests_cookie</code> which serves as a flag
that slow tests did run.</dd><dt><a class="fn" href="fn.target_dir.html" title="fn test_utils::target_dir">target_<wbr>dir</a></dt><dt><a class="fn" href="fn.try_ensure_file_contents.html" title="fn test_utils::try_ensure_file_contents">try_<wbr>ensure_<wbr>file_<wbr>contents</a></dt><dd>Checks that the <code>file</code> has the specified <code>contents</code>. If that is not the
case, updates the file and return an Error.</dd><dt><a class="fn" href="fn.try_extract_offset.html" title="fn test_utils::try_extract_offset">try_<wbr>extract_<wbr>offset</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dd>Returns the offset of the first occurrence of <code>$0</code> marker and the copy of <code>text</code>
without the marker.</dd><dt><a class="fn" href="fn.try_extract_range.html" title="fn test_utils::try_extract_range">try_<wbr>extract_<wbr>range</a><span title="Restricted Visibility">&nbsp;🔒</span> </dt><dd>Returns <code>TextRange</code> between the first two markers <code>$0...$0</code> and the copy
of <code>text</code> without both of these markers.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.FxHashMap.html" title="type test_utils::FxHashMap">FxHash<wbr>Map</a></dt><dd>Type alias for a hash map that uses the Fx hashing algorithm.</dd></dl></section></div></main></body></html>