/** \file
 *
 *  Contains unit tests for the Mtx class
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef _MTX_TEST_H_
#define _MTX_TEST_H_


#include "Mtx.h"
#include "io/StrIOStream.h"

#include <cxxtest/TestSuite.h>

/**
 *  Unit tests for Mtx class
 *
 *  \ingroup data
 */
class Mtx_Test : public CxxTest::TestSuite
{
public:

    /// Test Mtx::shellSort
    void testShellSort( void )
    {
        Logger logger( "Mtx_Test" );
        Mtx mtx( logger, 3, 4 );
        mtx[ 0 ][ 0 ] = 5.0f;
        mtx[ 1 ][ 0 ] = 4.0f;
        mtx[ 2 ][ 0 ] = 1.0f;
        mtx[ 0 ][ 1 ] = 2.0f;
        mtx[ 1 ][ 1 ] = 5.0f;
        mtx[ 2 ][ 1 ] = 5.0f;
        mtx[ 0 ][ 2 ] = 1.0f;
        mtx[ 1 ][ 2 ] = 2.0f;
        mtx[ 2 ][ 2 ] = 5.0f;
        mtx[ 0 ][ 3 ] = 1.0f;
        mtx[ 1 ][ 3 ] = 3.0f;
        mtx[ 2 ][ 3 ] = 3.0f;

        mtx.shellSort( Mtx::Comp1 );

        TS_ASSERT_EQUALS( mtx( 0, 0 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 0, 1 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 0, 2 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 0, 3 ), 2.0f );
        TS_ASSERT_EQUALS( mtx( 1, 0 ), 2.0f );
        TS_ASSERT_EQUALS( mtx( 1, 1 ), 3.0f );
        TS_ASSERT_EQUALS( mtx( 1, 2 ), 4.0f );
        TS_ASSERT_EQUALS( mtx( 1, 3 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 2, 0 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 2, 1 ), 3.0f );
        TS_ASSERT_EQUALS( mtx( 2, 2 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 2, 3 ), 5.0f );

        mtx.shellSort( Mtx::Comp01 );

        TS_ASSERT_EQUALS( mtx( 0, 0 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 0, 1 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 0, 2 ), 2.0f );
        TS_ASSERT_EQUALS( mtx( 0, 3 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 1, 0 ), 2.0f );
        TS_ASSERT_EQUALS( mtx( 1, 1 ), 3.0f );
        TS_ASSERT_EQUALS( mtx( 1, 2 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 1, 3 ), 4.0f );
        TS_ASSERT_EQUALS( mtx( 2, 0 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 2, 1 ), 3.0f );
        TS_ASSERT_EQUALS( mtx( 2, 2 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 2, 3 ), 1.0f );

        mtx.shellSort( Mtx::Comp02 );

        TS_ASSERT_EQUALS( mtx( 0, 0 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 0, 1 ), 1.0f );
        TS_ASSERT_EQUALS( mtx( 0, 2 ), 2.0f );
        TS_ASSERT_EQUALS( mtx( 0, 3 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 1, 0 ), 3.0f );
        TS_ASSERT_EQUALS( mtx( 1, 1 ), 2.0f );
        TS_ASSERT_EQUALS( mtx( 1, 2 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 1, 3 ), 4.0f );
        TS_ASSERT_EQUALS( mtx( 2, 0 ), 3.0f );
        TS_ASSERT_EQUALS( mtx( 2, 1 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 2, 2 ), 5.0f );
        TS_ASSERT_EQUALS( mtx( 2, 3 ), 1.0f );
    }

};

#endif // _MTX_TEST_H
