This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
concat.rs
74 lines (63 loc) · 1.54 KB
/
concat.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
mod utils;
use utils::*;
#[test]
fn concat() {
given(r#"
# Getting started
First of all, create a simple `Cargo.toml` file:
```toml,file=Cargo.toml
[package]
authors = ["Pascal Hertleif <killercup@gmail.com>"]
name = "foo"
version = "0.1.0"
```
Now, let us define our first data structure by putting this into our
`src/lib.rs`:
```rust,file=src/lib.rs
struct Foo {
x: i32,
}
```
Very good. Let us implement a `new` function:
```rust,file=src/lib.rs
impl Foo {
fn new(x: i32) -> Foo {
Foo { x: x }
}
}
```
Great. How about a good default as well?
```rust,file=src/lib.rs
use std::default::Default;
impl Default for Foo {
fn default() -> Foo {
Foo { x: 42 }
}
}
```
"#)
.running(waltz)
.creates(file("Cargo.toml").containing(r#"
[package]
authors = ["Pascal Hertleif <killercup@gmail.com>"]
name = "foo"
version = "0.1.0"
"#))
.creates(file("src/lib.rs").containing(r#"
struct Foo {
x: i32,
}
impl Foo {
fn new(x: i32) -> Foo {
Foo { x: x }
}
}
use std::default::Default;
impl Default for Foo {
fn default() -> Foo {
Foo { x: 42 }
}
}
"#))
.running(cargo_check);
}