/*
 * I2D.h
 *
 * Unit tests of methods for creating and deleting 2D pointer-based matrices.
 *
 *  Created on: Feb 7, 2014
 *      Author: godin
 */

#ifndef I2D_TEST_H_
#define I2D_TEST_H_

#include "I2D.h"

#include <cxxtest/TestSuite.h>

class I2D_Test : public CxxTest::TestSuite
{
public:

    // Test basic allocation and access
    void testNew( void )
    {
        int m = 7, n = 4;
        float** values = I2D<float>::New2D( m, n );
        float inc = 1;
        for( int i = 0; i < m; ++i )
        {
            for( int j = 0; j < n; ++j )
            {
                values[i][j] = inc;
                inc = inc + 1.0f;
            }
        }
        int sum = 0;
        for( int i = 0; i < m; ++i )
        {
            for( int j = 0; j < n; ++j )
            {
                sum = sum + values[i][j];
            }
        }
        TS_ASSERT_DELTA( sum, ( m * n ) * ( m * n + 1 ) / 2.0f, 0.01 );
        I2D<float>::Delete2D( values );
    }
};

#endif /* I2D_TEST_H_ */
