Update some more code and text for new cargo new test content

This commit is contained in:
Carol (Nichols || Goulding)
2017-11-13 14:47:17 -05:00
parent 282097542a
commit 92cf1f2445
4 changed files with 10 additions and 6 deletions

View File

@@ -29,15 +29,16 @@ Notice that Cargo generated *src/lib.rs* instead of *src/main.rs*. Inside
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
```
Cargo creates an empty test to help us get our library started, rather than the
“Hello, world!” binary that we get when we use the `--bin` option. Well look
at the `#[]` and `mod tests` syntax in the “Using `super` to Access a Parent
Module” section later in this chapter, but for now, leave this code at the
bottom of *src/lib.rs*.
Cargo creates an example test to help us get our library started, rather than
the “Hello, world!” binary that we get when we use the `--bin` option. Well
look at the `#[]` and `mod tests` syntax in the “Using `super` to Access a
Parent Module” section later in this chapter, but for now, leave this code at
the bottom of *src/lib.rs*.
Because we dont have a *src/main.rs* file, theres nothing for Cargo to
execute with the `cargo run` command. Therefore, well use the `cargo build`

View File

@@ -146,6 +146,7 @@ pub mod network;
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
```

View File

@@ -120,6 +120,7 @@ Give the `it_works` function a different name, such as `exploration`, like so:
mod tests {
#[test]
fn exploration() {
assert_eq!(2 + 2, 4);
}
}
```
@@ -148,6 +149,7 @@ like Listing 11-3:
mod tests {
#[test]
fn exploration() {
assert_eq!(2 + 2, 4);
}
#[test]

View File

@@ -253,7 +253,7 @@ time consuming tests with the `ignore` attribute to exclude them:
```rust
#[test]
fn it_works() {
assert!(true);
assert_eq!(2 + 2, 4);
}
#[test]