Skip to content

Commit fea61d3

Browse files
committed
Fix tests
1 parent 886c6c7 commit fea61d3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! use dataplotlib::util::{linspace, zip2};
88
//! use dataplotlib::plotbuilder::PlotBuilder2D;
99
//! use dataplotlib::plotter::Plotter;
10+
//! use dataplotlib::draw_sdl::DrawSDL;
1011
//!
1112
//! fn main() {
1213
//! let x = linspace(0, 10, 100);
@@ -21,11 +22,14 @@
2122
//!
2223
//! // Adds the sin plot and the linear plot with custom colors
2324
//! pb.add_color_xy(xy_sin, [1.0, 0.0, 0.0, 1.0]);
24-
//! pb.add_color_xy(xy_lin, [0.0, 0.0, 1.0, 1.0]);
25+
//! pb.add_color_xy(xy_lin, [0.0, 0.75, 0.0, 1.0]);
26+
//!
27+
//! let sdlh = dataplotlib::sdl2_init();
28+
//! let sdl2_window = DrawSDL::new(sdlh);
2529
//!
2630
//! let mut plt = Plotter::new();
27-
//! plt.plot2d(pb);
28-
//! plt.join();
31+
//! plt.plot2d(pb, sdl2_window);
32+
//! # plt.disown(); // make sure the doc test doesn't last forever
2933
//! }
3034
//! ```
3135

src/plotter.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ mod test {
5959
use super::*;
6060
use plotbuilder::*;
6161
use util::*;
62+
use draw_sdl::DrawSDL;
63+
use sdl2_mt;
6264

6365
#[test]
6466
fn plot2d_test() {
@@ -67,10 +69,13 @@ mod test {
6769
let y = (&x).iter().map(|x| x.sin()).collect();
6870
let xy = zip2(&x, &y);
6971

72+
let sdlh = sdl2_mt::init();
73+
let sdl2_window = DrawSDL::new(sdlh);
74+
7075
let mut pb1 = PlotBuilder2D::new();
7176
pb1.add_simple_xy(xy);
7277
let mut plt = Plotter::new();
73-
plt.plot2d(pb1);
74-
plt.join();
78+
plt.plot2d(pb1, sdl2_window);
79+
plt.disown();
7580
}
7681
}

0 commit comments

Comments
 (0)