[ismrmrd] 232/281: Fixes broken test for t_ndarraycontainer

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit d20f85d1337edc1c3b60c8d526495f403beb7b01
Author: Ghislain Vaillant <ghisvail at gmail.com>
Date:   Wed May 28 17:15:07 2014 +0100

    Fixes broken test for t_ndarraycontainer
    
    MATLAB/FORTRAN indexing convention was used instead of C-style indexing,
    provoking an out-of-bounds access to memory. This patch fixes the indexing.
    
    Signed-off-by: Ghislain Antony Vaillant <ghisvail at gmail.com>
---
 tests/c++/t_ndarraycontainer.cpp | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/tests/c++/t_ndarraycontainer.cpp b/tests/c++/t_ndarraycontainer.cpp
index 0b30314..5feed2b 100644
--- a/tests/c++/t_ndarraycontainer.cpp
+++ b/tests/c++/t_ndarraycontainer.cpp
@@ -17,9 +17,8 @@ template<> struct populate <float> {
     static void random (NDArrayContainer<type>& ndac) {
         type mi = (type) std::numeric_limits<int>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = 1.0 - 2.0 * (type)rand() / mi;
     }
 
@@ -32,9 +31,8 @@ template<> struct populate <double> {
     static void random (NDArrayContainer<type>& ndac) {
         type mi = (type) std::numeric_limits<int>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = 1.0 - 2.0 * (type)rand() / mi;
     }
 
@@ -48,9 +46,8 @@ template<> struct populate <std::complex<float> > {
     static void random (NDArrayContainer<type>& ndac) {
         rtype mi = std::numeric_limits<int>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = type(1.0, 1.0) - type(2.0 * (rtype)rand() / mi, 2.0 * (rtype)rand() / mi);
     }
     
@@ -64,9 +61,8 @@ template<> struct populate <std::complex<double> > {
     static void random (NDArrayContainer<type>& ndac) {
         rtype mi = std::numeric_limits<int>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = type(1.0, 1.0) - type(2.0 * (rtype)rand() / mi, 2.0 * (rtype)rand() / mi);
     }
     
@@ -79,9 +75,8 @@ template<> struct populate <int> {
     static void random (NDArrayContainer<type>& ndac) {
         type mi = (type) std::numeric_limits<type>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = rand();
     }
     
@@ -94,9 +89,8 @@ template<> struct populate <short> {
     static void random (NDArrayContainer<type>& ndac) {
         type mi = (type) std::numeric_limits<type>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = rand();
     }
     
@@ -109,9 +103,8 @@ template<> struct populate <long> {
     static void random (NDArrayContainer<type>& ndac) {
         type mi = (type) std::numeric_limits<type>::max();
         assert (ndac.is_consistent());
-        size_t i = ndac.elements();
-        size_t j = ndac.data_.size();
-        for (; i>=1; i--)
+        size_t j = ndac.elements();
+        for (size_t i=0; i<j; i++)
             ndac[i] = rand();
     }
     

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list