TEST_F( OpenDDLExportTest, writeValueArrayTest ) {
    OpenDDLExportMock myExporter;
    bool ok( true );
    std::string statement;
    ok = myExporter.writeValueArrayTester( ddl_nullptr, statement );
    EXPECT_FALSE( ok );
    EXPECT_TRUE( statement.empty() );

    char token [] =
        "float[ 3 ]\n"
        "{\n"
        "    {1, 2, 3}\n"
        "}\n";

    size_t len( 0 );
    char *end = findEnd( token, len );
    DataArrayList *dataArrayList( ddl_nullptr );
    Value::ValueType type;

    char *in = OpenDDLParser::parsePrimitiveDataType( token, end, type, len );
    ASSERT_EQ( Value::ddl_float, type );
    ASSERT_EQ( 3U, len );
    in = OpenDDLParser::parseDataArrayList( in, end, type, &dataArrayList );
    ASSERT_FALSE( ddl_nullptr == dataArrayList );

    ok = myExporter.writeValueArrayTester( dataArrayList, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "{ 1, 2, 3 }", statement );
    delete dataArrayList;
}
TEST_F( OpenDDLExportTest, writeIntegerTest ) {
    OpenDDLExportMock myExport;
    Value *v = ValueAllocator::allocPrimData( Value::ddl_int8 );
    v->setInt8( 10 );
    bool ok( true );
    std::string statement;
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "10", statement );
    ValueAllocator::releasePrimData( &v );

    statement.clear();
    v = ValueAllocator::allocPrimData( Value::ddl_int16 );
    v->setInt16( 655 );
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "655", statement );
    ValueAllocator::releasePrimData( &v );

    statement.clear();
    v = ValueAllocator::allocPrimData( Value::ddl_int32 );
    v->setInt32( 65501 );
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "65501", statement );
    ValueAllocator::releasePrimData( &v );

    statement.clear();
    v = ValueAllocator::allocPrimData( Value::ddl_int64 );
    v->setInt64( 65502 );
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "65502", statement );
    ValueAllocator::releasePrimData( &v );
}
TEST_F( OpenDDLExportTest, writeFloatTest ) {
    OpenDDLExportMock myExport;
    Value *v = ValueAllocator::allocPrimData( Value::ddl_float );
    v->setFloat( 1.1f );
    bool ok( true );
    std::string statement;
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "1.1", statement );
    ValueAllocator::releasePrimData( &v );
}
TEST_F( OpenDDLExportTest, writeStringTest ) {
    OpenDDLExportMock myExport;
    Value *v = ValueAllocator::allocPrimData( Value::ddl_string );
    v->setString( "huhu" );
    bool ok( true );
    std::string statement;
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "\"huhu\"", statement );
    ValueAllocator::releasePrimData( &v );
}
TEST_F( OpenDDLExportTest, writeBoolTest ) {
    OpenDDLExportMock myExport;
    Value *v = ValueAllocator::allocPrimData( Value::ddl_bool );
    v->setBool( true );

    std::string statement;
    bool ok( true );
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "true", statement );

    v->setBool( false );
    statement.clear();
    ok = myExport.writeValueTester( v, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "false", statement );

    ValueAllocator::releasePrimData( &v );
}
TEST_F( OpenDDLExportTest, writeNodeHeaderTest ) {
    OpenDDLExportMock myExport;

    bool ok( true );
    std::string statement;
    ok = myExport.writeNodeHeaderTester( ddl_nullptr, statement );
    EXPECT_FALSE( ok );

    DDLNode *node( DDLNode::create( "test", "" ) );
    node->attachParent( m_root );
    ok = myExport.writeNodeHeaderTester( node, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "test", statement );
    statement.clear();

    ok = myExport.writeNodeHeaderTester( m_root, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "test $root", statement );
}
TEST_F( OpenDDLExportTest, writeValueTypeTest ) {
    OpenDDLExportMock myExporter;
    bool ok( true );
    std::string statement;
    ok = myExporter.writeValueTypeTester( Value::ddl_types_max, 1, statement );
    EXPECT_FALSE( ok );
    EXPECT_TRUE( statement.empty() );

    Value *v_int32 = ValueAllocator::allocPrimData( Value::ddl_int32 );
    ok = myExporter.writeValueTypeTester( v_int32->m_type, 1, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "int32", statement );
    statement.clear();

    Value *v_int32_array = ValueAllocator::allocPrimData( Value::ddl_int32 );
    ok = myExporter.writeValueTypeTester( v_int32_array->m_type, 10, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "int32[10]", statement );
}
TEST_F( OpenDDLExportTest, writePropertiesTest ) {
    OpenDDLExportMock myExporter;
    bool ok( true );
    std::string statement;
    ok = myExporter.writePropertiesTester( ddl_nullptr, statement );
    EXPECT_FALSE( ok );

    Property *prop( createProperties( 1 ) );
    m_root->setProperties( prop );

    ok = myExporter.writePropertiesTester( m_root, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "(id.0 = 0)", statement );

    statement.clear();
    Property *prop2( createProperties( 2 ) );
    m_root->setProperties( prop2 );
    ok = myExporter.writePropertiesTester( m_root, statement );
    EXPECT_TRUE( ok );
    EXPECT_EQ( "(id.0 = 0, id.1 = 1)", statement );
}