[librsvg/wip/aruiz/rust-pixbuf-loader: 174/188] itest: test last pixel




commit 3a83f5579791d9d1ade0b35b77fb0bd99c63a74a
Author: Alberto Ruiz <aruiz redhat com>
Date:   Fri Jul 29 18:35:34 2022 +0100

    itest: test last pixel

 gdk-pixbuf-loader/src/lib.rs | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gdk-pixbuf-loader/src/lib.rs b/gdk-pixbuf-loader/src/lib.rs
index ac6770c90..6c5ffffc2 100644
--- a/gdk-pixbuf-loader/src/lib.rs
+++ b/gdk-pixbuf-loader/src/lib.rs
@@ -372,10 +372,28 @@ mod tests {
             assert_eq!(*pixels.offset(3), 0xff);
 
             // Bottom left pixel
-            assert_eq!(*pixels.offset((stride * 99) as isize), 0xaa);
-            assert_eq!(*pixels.offset((stride * 99) as isize + 1), 0x11);
-            assert_eq!(*pixels.offset((stride * 99) as isize + 2), 0x44);
-            assert_eq!(*pixels.offset((stride * 99) as isize + 3), 0xff);
+            assert_eq!(*pixels.offset((stride * (h - 1)) as isize), 0xaa);
+            assert_eq!(*pixels.offset((stride * (h - 1)) as isize + 1), 0x11);
+            assert_eq!(*pixels.offset((stride * (h - 1)) as isize + 2), 0x44);
+            assert_eq!(*pixels.offset((stride * (h - 1)) as isize + 3), 0xff);
+
+            // Bottom right pixel
+            assert_eq!(
+                *pixels.offset((stride * (h - 1)) as isize + (w as isize - 1) * 4),
+                0xaa
+            );
+            assert_eq!(
+                *pixels.offset((stride * (h - 1)) as isize + (w as isize - 1) * 4 + 1),
+                0x11
+            );
+            assert_eq!(
+                *pixels.offset((stride * (h - 1)) as isize + (w as isize - 1) * 4 + 2),
+                0x44
+            );
+            assert_eq!(
+                *pixels.offset((stride * (h - 1)) as isize + (w as isize - 1) * 4 + 3),
+                0xff
+            );
         }
 
         let ctx = unsafe { crate::begin_load(None, Some(prep_cb), None, null_mut(), null_mut()) };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]