Consistent formatting for args and attrs
This commit is contained in:
parent
f3f2e697d8
commit
e0ea31f56c
1 changed files with 9 additions and 9 deletions
|
@ -33,7 +33,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|||
# Unit testing in Rust
|
||||
|
||||
Rust has built in support for simple unit testing. Functions can be
|
||||
marked as unit tests using the 'test' attribute.
|
||||
marked as unit tests using the `test` attribute.
|
||||
|
||||
~~~
|
||||
#[test]
|
||||
|
@ -44,13 +44,13 @@ fn return_none_if_empty() {
|
|||
|
||||
A test function's signature must have no arguments and no return
|
||||
value. To run the tests in a crate, it must be compiled with the
|
||||
'--test' flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
|
||||
`--test` flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
|
||||
the resulting executable will run all the tests in the crate. A test
|
||||
is considered successful if its function returns; if the task running
|
||||
the test fails, through a call to `fail!`, a failed `check` or
|
||||
`assert`, or some other (`assert_eq`, ...) means, then the test fails.
|
||||
|
||||
When compiling a crate with the '--test' flag '--cfg test' is also
|
||||
When compiling a crate with the `--test` flag `--cfg test` is also
|
||||
implied, so that tests can be conditionally compiled.
|
||||
|
||||
~~~
|
||||
|
@ -64,17 +64,17 @@ mod tests {
|
|||
~~~
|
||||
|
||||
Additionally `#[test]` items behave as if they also have the
|
||||
`#[cfg(test)]` attribute, and will not be compiled when the --test flag
|
||||
`#[cfg(test)]` attribute, and will not be compiled when the `--test` flag
|
||||
is not used.
|
||||
|
||||
Tests that should not be run can be annotated with the 'ignore'
|
||||
Tests that should not be run can be annotated with the `ignore`
|
||||
attribute. The existence of these tests will be noted in the test
|
||||
runner output, but the test will not be run. Tests can also be ignored
|
||||
by configuration so, for example, to ignore a test on windows you can
|
||||
write `#[ignore(cfg(target_os = "win32"))]`.
|
||||
|
||||
Tests that are intended to fail can be annotated with the
|
||||
'should_fail' attribute. The test will be run, and if it causes its
|
||||
`should_fail` attribute. The test will be run, and if it causes its
|
||||
task to fail then the test will be counted as successful; otherwise it
|
||||
will be counted as a failure. For example:
|
||||
|
||||
|
@ -87,11 +87,11 @@ fn test_out_of_bounds_failure() {
|
|||
}
|
||||
~~~
|
||||
|
||||
A test runner built with the '--test' flag supports a limited set of
|
||||
A test runner built with the `--test` flag supports a limited set of
|
||||
arguments to control which tests are run: the first free argument
|
||||
passed to a test runner specifies a filter used to narrow down the set
|
||||
of tests being run; the '--ignored' flag tells the test runner to run
|
||||
only tests with the 'ignore' attribute.
|
||||
of tests being run; the `--ignored` flag tells the test runner to run
|
||||
only tests with the `ignore` attribute.
|
||||
|
||||
## Parallelism
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue