samedi 1 août 2015

How to make a test dir in Rust?

I'd like to set up a basic hello world project. The unit tests should be in the test/ directory as described in the book. My code so far is as follows.

src/main.rs

pub mod player;

fn main() {
    println!("Hello, world!");
}

src/player.rs

pub fn rep(arg: i32) -> i32 {
    arg
}

tests/player.rs

extern crate player;

#[test]
fn it_works() {
    assert_eq!(4, player::rep(2+2));
}

I believe the code is very similar to the book. However, cargo test fails:

tests/player.rs:1:1: 1:21 error: can't find crate for `player`
tests/player.rs:1 extern crate player;
              ^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

What is the problem? I'm completely lost.

Aucun commentaire:

Enregistrer un commentaire