on master help sign in
Fix tests failing on cargo test --release
4f108abBlaž Hrastnik
helix-tui/src/buffer.rs+2−19
@@ -203,16 +203,6 @@ impl Buffer {
203 /// # Panics
203 /// # Panics
204 ///
204 ///
205 /// Panics when given an coordinate that is outside of this Buffer's area.
205 /// Panics when given an coordinate that is outside of this Buffer's area.
206− ///
207− /// ```should_panic
208− /// # use helix_tui::buffer::Buffer;
209− /// # use helix_tui::layout::Rect;
210− /// let rect = Rect::new(200, 100, 10, 10);
211− /// let buffer = Buffer::empty(rect);
212− /// // Top coordinate is outside of the buffer in global coordinate space, as the Buffer's area
213− /// // starts at (200, 100).
214− /// buffer.index_of(0, 0); // Panics
215− /// ```
216 pub fn index_of(&self, x: u16, y: u16) -> usize {
206 pub fn index_of(&self, x: u16, y: u16) -> usize {
217 debug_assert!(
207 debug_assert!(
218 x >= self.area.left()
208 x >= self.area.left()
@@ -245,15 +235,6 @@ impl Buffer {
245 /// # Panics
235 /// # Panics
246 ///
236 ///
247 /// Panics when given an index that is outside the Buffer's content.
237 /// Panics when given an index that is outside the Buffer's content.
248− ///
249− /// ```should_panic
250− /// # use helix_tui::buffer::Buffer;
251− /// # use helix_tui::layout::Rect;
252− /// let rect = Rect::new(0, 0, 10, 10); // 100 cells in total
253− /// let buffer = Buffer::empty(rect);
254− /// // Index 100 is the 101th cell, which lies outside of the area of this Buffer.
255− /// buffer.pos_of(100); // Panics
256− /// ```
257 pub fn pos_of(&self, i: usize) -> (u16, u16) {
238 pub fn pos_of(&self, i: usize) -> (u16, u16) {
258 debug_assert!(
239 debug_assert!(
259 i < self.content.len(),
240 i < self.content.len(),
@@ -510,6 +491,7 @@ mod tests {
510
491
511 #[test]
492 #[test]
512 #[should_panic(expected = "outside the buffer")]
493 #[should_panic(expected = "outside the buffer")]
494+ #[cfg(debug_assertions)]
513 fn pos_of_panics_on_out_of_bounds() {
495 fn pos_of_panics_on_out_of_bounds() {
514 let rect = Rect::new(0, 0, 10, 10);
496 let rect = Rect::new(0, 0, 10, 10);
515 let buf = Buffer::empty(rect);
497 let buf = Buffer::empty(rect);
@@ -520,6 +502,7 @@ mod tests {
520
502
521 #[test]
503 #[test]
522 #[should_panic(expected = "outside the buffer")]
504 #[should_panic(expected = "outside the buffer")]
505+ #[cfg(debug_assertions)]
523 fn index_of_panics_on_out_of_bounds() {
506 fn index_of_panics_on_out_of_bounds() {
524 let rect = Rect::new(0, 0, 10, 10);
507 let rect = Rect::new(0, 0, 10, 10);
525 let buf = Buffer::empty(rect);
508 let buf = Buffer::empty(rect);