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

#ifndef _STRVALUE_TEST_H_


#include "StrValue.h"

#include "UChar.h"
#include "Int.h"
#include "Float2.h"
#include "Float3.h"
#include "Float.h"
#include "Double4.h"
#include "Double6.h"
#include "Double.h"

#include "units/Units.h"

#include <cxxtest/TestSuite.h>

/**
 *  Unit tests for StrValue class
 *
 *  \ingroup data
 */
class StrValue_Test : public CxxTest::TestSuite
{
public:

    /// tests the setFrom Method
    void testSetFrom( void )
    {
        StrValue strValue;

        StrValue testStr( "Hello!" );
        TS_ASSERT( strValue.setFrom( testStr ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "Hello!", 6 );

        UChar testUChar( Units::ENUM, 1 );
        TS_ASSERT( strValue.setFrom( testUChar ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "1 enum", 6 );

        Int testInt( Units::ENUM, 2 );
        TS_ASSERT( strValue.setFrom( testInt ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "2 enum", 6 );

        Float2 testFloat2( Units::METER, 3.4375 );
        TS_ASSERT( strValue.setFrom( testFloat2 ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "3.4375", 6 );

        Float3 testFloat3( Units::METER, 4.5 );
        TS_ASSERT( strValue.setFrom( testFloat3 ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "4.5", 3 );

        Float testFloat( Units::METER, 5.625 );
        TS_ASSERT( strValue.setFrom( testFloat ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "5.625", 5 );

        Double4 testDouble4( Units::METER, 6.75 );
        TS_ASSERT( strValue.setFrom( testDouble4 ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "6.75", 4 );

        Double6 testDouble6( Units::METER, 7.875 );
        TS_ASSERT( strValue.setFrom( testDouble6 ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "7.875", 5 );

        Double testDouble( Units::METER, 8.9375 );
        TS_ASSERT( strValue.setFrom( testDouble ) );
        TS_ASSERT_SAME_DATA( strValue.asString().cStr(), "8.9375", 6 );

    }

};

#endif // _STRVALUE_TEST_H
