Skip to content

Commit bfdd063

Browse files
authored
Merge pull request #59 from mgeisler/rust-2018-paths
doc: update example to use macros directly
2 parents 5c01401 + 9fd877a commit bfdd063

File tree

3 files changed

+13
-28
lines changed

3 files changed

+13
-28
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@ version-sync = "0.7"
2121

2222
Then create a `tests/version-numbers.rs` file with:
2323
```rust
24-
#[macro_use]
25-
extern crate version_sync;
26-
2724
#[test]
2825
fn test_readme_deps() {
29-
assert_markdown_deps_updated!("README.md");
26+
version_sync::assert_markdown_deps_updated!("README.md");
3027
}
3128

3229
#[test]
3330
fn test_html_root_url() {
34-
assert_html_root_url_updated!("src/lib.rs");
31+
version_sync::assert_html_root_url_updated!("src/lib.rs");
3532
}
3633
```
3734

src/lib.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020
//! `tests/version-numbers.rs` file with:
2121
//!
2222
//! ```rust
23-
//! #[macro_use]
24-
//! extern crate version_sync;
25-
//!
2623
//! #[test]
2724
//! # fn fake_hidden_test_case_1() {}
2825
//! fn test_readme_deps() {
29-
//! assert_markdown_deps_updated!("README.md");
26+
//! version_sync::assert_markdown_deps_updated!("README.md");
3027
//! }
3128
//!
3229
//! #[test]
3330
//! # fn fake_hidden_test_case_2() {}
3431
//! fn test_html_root_url() {
35-
//! assert_html_root_url_updated!("src/lib.rs");
32+
//! version_sync::assert_html_root_url_updated!("src/lib.rs");
3633
//! }
3734
//!
3835
//! # fn main() {
@@ -76,14 +73,11 @@ pub use crate::markdown_deps::check_markdown_deps;
7673
/// The typical way to use this macro is from an integration test:
7774
///
7875
/// ```rust
79-
/// #[macro_use]
80-
/// extern crate version_sync;
81-
///
8276
/// #[test]
8377
/// # fn fake_hidden_test_case() {}
8478
/// # // The above function ensures test_readme_deps is compiled.
8579
/// fn test_readme_deps() {
86-
/// assert_markdown_deps_updated!("README.md");
80+
/// version_sync::assert_markdown_deps_updated!("README.md");
8781
/// }
8882
///
8983
/// # fn main() {
@@ -130,14 +124,11 @@ macro_rules! assert_markdown_deps_updated {
130124
/// The typical way to use this macro is from an integration test:
131125
///
132126
/// ```rust
133-
/// #[macro_use]
134-
/// extern crate version_sync;
135-
///
136127
/// #[test]
137128
/// # fn fake_hidden_test_case() {}
138129
/// # // The above function ensures test_html_root_url is compiled.
139130
/// fn test_html_root_url() {
140-
/// assert_html_root_url_updated!("src/lib.rs");
131+
/// version_sync::assert_html_root_url_updated!("src/lib.rs");
141132
/// }
142133
///
143134
/// # fn main() {
@@ -184,15 +175,12 @@ macro_rules! assert_html_root_url_updated {
184175
/// The typical way to use this macro is from an integration test:
185176
///
186177
/// ```rust
187-
/// #[macro_use]
188-
/// extern crate version_sync;
189-
///
190178
/// #[test]
191179
/// # fn fake_hidden_test_case() {}
192180
/// # // The above function ensures test_readme_mentions_version is
193181
/// # // compiled.
194182
/// fn test_readme_mentions_version() {
195-
/// assert_contains_regex!("README.md", "^### Version {version}");
183+
/// version_sync::assert_contains_regex!("README.md", "^### Version {version}");
196184
/// }
197185
///
198186
/// # fn main() {

tests/version-numbers.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
#[macro_use]
2-
extern crate version_sync;
3-
41
#[test]
52
fn test_readme_deps() {
6-
assert_markdown_deps_updated!("README.md");
3+
version_sync::assert_markdown_deps_updated!("README.md");
74
}
85

96
#[test]
107
fn test_readme_changelog() {
11-
assert_contains_regex!("README.md", r"^### Version {version} — .* \d\d?.., 20\d\d$");
8+
version_sync::assert_contains_regex!(
9+
"README.md",
10+
r"^### Version {version} — .* \d\d?.., 20\d\d$"
11+
);
1212
}
1313

1414
#[test]
1515
fn test_html_root_url() {
16-
assert_html_root_url_updated!("src/lib.rs");
16+
version_sync::assert_html_root_url_updated!("src/lib.rs");
1717
}

0 commit comments

Comments
 (0)