gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.31k stars 247 forks source link

Add unit tests for layout/get_min_size/draw methods #41

Open gyscos opened 8 years ago

gyscos commented 8 years ago

Some views need some minimal space to display properly. It's usually just a few cells, but as views include other views, it adds up. And while it's rarely an issue in regular use, when resizing a view, it can happen, if only temporarily.

Currently, it often results in a panic from usize overflows.

Rather than crashing, displaying an empty view would be a minimal thing to do. Showing an error message (like "Screen size too small" or something) would be even better.

gyscos commented 8 years ago

Now at least it doesn't crash anymore - so resizing the terminal window by mistake won't kill your application.

Ideally, we'd still have a more gracious fallback: I guess cropping the view may be the best solution.

gyscos commented 8 years ago

Actually, since this doesn't need a running Cursive instance, there should probably be unit tests for that.

gyscos commented 8 years ago

Testing the draw methods may require a Dummy printer (or a printer in dummy mode).

gyscos commented 4 years ago

Testing the draw methods may require a Dummy printer (or a printer in dummy mode).

Well, now that backends are dynamics, we could either use backends::Dummy or some puppet backend.