Refactored tests/ and added test for VideoSubsys

This commit is contained in:
Cobrand
2017-05-02 08:09:57 +02:00
parent f1eea15e00
commit 40a373c5ea
6 changed files with 14 additions and 8 deletions

View File

@@ -15,11 +15,6 @@ categories = ["rendering","games","game-engine","multimedia"]
name = "sdl2"
path = "src/sdl2/lib.rs"
[[test]]
name="events"
harness=false
[dependencies]
bitflags = "0.7"
libc = "0.2"

View File

@@ -27,7 +27,7 @@ impl AudioCallback for Sound {
fn main() {
let wav_file : Cow<'static, Path> = match std::env::args().nth(1) {
None => Cow::from(Path::new("./tests/sine.wav")),
None => Cow::from(Path::new("./assets/sine.wav")),
Some(s) => Cow::from(PathBuf::from(s))
};
let sdl_context = sdl2::init().unwrap();

View File

@@ -2,7 +2,7 @@ extern crate sdl2;
#[test]
fn audio_spec_wav() {
let wav = sdl2::audio::AudioSpecWAV::load_wav("./tests/sine.wav").unwrap();
let wav = sdl2::audio::AudioSpecWAV::load_wav("./assets/sine.wav").unwrap();
assert_eq!(wav.freq, 22050);
assert_eq!(wav.format, sdl2::audio::AudioFormat::S16LSB);

View File

@@ -1,7 +1,8 @@
extern crate sdl2;
use sdl2::event;
fn main() {
#[test]
fn test_events() {
let sdl = sdl2::init().unwrap();
let ev = sdl.event().unwrap();
let mut ep = sdl.event_pump().unwrap();

10
tests/video.rs Normal file
View File

@@ -0,0 +1,10 @@
extern crate sdl2;
#[test]
fn display_name_no_segfault() {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
// hopefully no one has a 100 screen to see this test pass
let r = video_subsystem.display_name(99);
assert!(r.is_err());
}