<commit_before>#include "TestOpaqueToolkitTypes.hpp"
#include "TestOpaqueToolkit.hpp"
#include "opaque.h"

#ifdef WITH_CORBA
#include <omniORB4/CORBA.h>
#include <rtt/corba/CorbaLib.hpp>
#include "build/.orogen/toolkit/TestOpaqueToolkitC.h"
#endif

#include <rtt/os/main.h>
#include <rtt/Types.hpp>
#include <rtt/PropertyBag.hpp>
#include <rtt/DataSources.hpp>
#include <rtt/marsh/XMLMarshaller.hpp>
#include <rtt/marsh/PropertyMarshaller.hpp>
#include <rtt/marsh/PropertyDemarshaller.hpp>
#include <iostream>
#include <fstream>

using namespace RTT;
using std::cerr;
using std::endl;

bool test_plain_opaque()
{
    TypeInfoRepository::shared_ptr ti = TypeInfoRepository::Instance();
    TypeInfo* type = ti->type("/NotOrogenCompatible/Point2D");
    if (! type)
    {
	cerr << "cannot find /NotOrogenCompatible/Point2D in the type info repository" << endl;
	return 1;
    }

    // Create a structure of type Test::Simple, inject it into Orocos and check
    // that it is able to generate a XML representation of it
    NotOrogenCompatible::Point2D value(10, 20);
    ConstantDataSource<NotOrogenCompatible::Point2D>* source =
        new ConstantDataSource<NotOrogenCompatible::Point2D>(value);
    source->ref();

    PropertyBag bag;
    type->decomposeType(source, bag);

    // First, save it into XML. The Ruby test case will compare that to an
    // expected XML document
    std::ofstream xml_file("test_toolkit_opaque.xml");
    XMLMarshaller<std::ostream> xml_output(xml_file);
    xml_output.serialize(bag);

    // Now, marshal it to the standard Orocos format, reload it and compare
    // the result
    PropertyMarshaller cpf_output("test_toolkit_opaque.cpf");
    cpf_output.serialize(bag);
    cpf_output.flush();

    PropertyBag input_bag;
    PropertyDemarshaller cpf_input("test_toolkit_opaque.cpf");
    cpf_input.deserialize(input_bag);

    if (input_bag.size() != 3)
    {
        cerr << "error in property marshalling/demarshalling" << endl;
        cerr << "expected 3 elements, got " << input_bag.size() << endl;
        return false;
    }

    double input_a = Property<double>(input_bag.getItem(1)).value();
    double input_b = Property<double>(input_bag.getItem(2)).value();
    if (input_a != 10 || input_b != 20)
    {
        cerr << "error in property marshalling/demarshalling" << endl;
	cerr << "input.a == " << input_a << ", 10 expected" << endl;
	cerr << "input.b == " << input_b << ", 20 expected" << endl;
	return false;
    }

#ifdef WITH_CORBA
    std::cerr << "Testing the CORBA part ..." << std::endl;
    // And now the CORBA part. First marshalling ...
    { CORBA::Any_var result = reinterpret_cast<CORBA::Any*>(source->createBlob(ORO_CORBA_PROTOCOL_ID));

        result >>= input_a;
        result >>= input_b;
        if (input_a != 10 || input_b != 20)
        {
            cerr << "error in CORBA marshalling" << endl;
            cerr << "input.a == " << input_a << ", 10 expected" << endl;
            cerr << "input.b == " << input_b << ", 20 expected" << endl;
            return false;
        }
    }

    // And then unmarshalling
    { CORBA::Any* result = reinterpret_cast<CORBA::Any*>(source->createBlob(ORO_CORBA_PROTOCOL_ID));
        ValueDataSource<NotOrogenCompatible::Point2D>* reader =
            new ValueDataSource<NotOrogenCompatible::Point2D>();
        reader->ref();
        reader->updateBlob(ORO_CORBA_PROTOCOL_ID, result);
        NotOrogenCompatible::Point2D value = reader->get();

        if (value.x() != 10 || value.y() != 20)
        {
            cerr << "error in CORBA unmarshalling" << endl;
            cerr << "value.x() == " << value.x() << ", 10 expected" << endl;
            cerr << "value.y() == " << value.y() << ", 20 expected" << endl;
            return false;
        }
    }
#endif
    return true;
}

bool check_position_value(std::string const& place, double timestamp, double x, double y)
{
    if (timestamp != 10 || x != 20 || y != 30)
    {<commit_msg>test: fix the CORBA part of the plain opaque test in test_opaque<commit_after>#include "TestOpaqueToolkitTypes.hpp"
#include "TestOpaqueToolkit.hpp"
#include "opaque.h"

#ifdef WITH_CORBA
#include <omniORB4/CORBA.h>
#include <rtt/corba/CorbaLib.hpp>
#include "build/.orogen/toolkit/TestOpaqueToolkitC.h"
#endif

#include <rtt/os/main.h>
#include <rtt/Types.hpp>
#include <rtt/PropertyBag.hpp>
#include <rtt/DataSources.hpp>
#include <rtt/marsh/XMLMarshaller.hpp>
#include <rtt/marsh/PropertyMarshaller.hpp>
#include <rtt/marsh/PropertyDemarshaller.hpp>
#include <iostream>
#include <fstream>

using namespace RTT;
using std::cerr;
using std::endl;

bool test_plain_opaque()
{
    TypeInfoRepository::shared_ptr ti = TypeInfoRepository::Instance();
    TypeInfo* type = ti->type("/NotOrogenCompatible/Point2D");
    if (! type)
    {
	cerr << "cannot find /NotOrogenCompatible/Point2D in the type info repository" << endl;
	return 1;
    }

    // Create a structure of type Test::Simple, inject it into Orocos and check
    // that it is able to generate a XML representation of it
    NotOrogenCompatible::Point2D value(10, 20);
    ConstantDataSource<NotOrogenCompatible::Point2D>* source =
        new ConstantDataSource<NotOrogenCompatible::Point2D>(value);
    source->ref();

    PropertyBag bag;
    type->decomposeType(source, bag);

    // First, save it into XML. The Ruby test case will compare that to an
    // expected XML document
    std::ofstream xml_file("test_toolkit_opaque.xml");
    XMLMarshaller<std::ostream> xml_output(xml_file);
    xml_output.serialize(bag);

    // Now, marshal it to the standard Orocos format, reload it and compare
    // the result
    PropertyMarshaller cpf_output("test_toolkit_opaque.cpf");
    cpf_output.serialize(bag);
    cpf_output.flush();

    PropertyBag input_bag;
    PropertyDemarshaller cpf_input("test_toolkit_opaque.cpf");
    cpf_input.deserialize(input_bag);

    if (input_bag.size() != 3)
    {
        cerr << "error in property marshalling/demarshalling" << endl;
        cerr << "expected 3 elements, got " << input_bag.size() << endl;
        return false;
    }

    double input_a = Property<double>(input_bag.getItem(1)).value();
    double input_b = Property<double>(input_bag.getItem(2)).value();
    if (input_a != 10 || input_b != 20)
    {
        cerr << "error in property marshalling/demarshalling" << endl;
	cerr << "input.a == " << input_a << ", 10 expected" << endl;
	cerr << "input.b == " << input_b << ", 20 expected" << endl;
	return false;
    }

#ifdef WITH_CORBA
    std::cerr << "Testing the CORBA part ..." << std::endl;
    // And now the CORBA part. First marshalling ...
    { CORBA::Any* result = reinterpret_cast<CORBA::Any*>(source->createBlob(ORO_CORBA_PROTOCOL_ID));

        TestOpaque::Corba::Point2D*  p;
        (*result) >>= p;

        if (p->padding != 100 || p->x != 10 || p->y != 20)
        {
            cerr << "error in CORBA marshalling" << endl;
            cerr << "input.padding == " << p->padding << ", 100 expected" << endl;
            cerr << "input.a == " << p->x << ", 10 expected" << endl;
            cerr << "input.b == " << p->y << ", 20 expected" << endl;
            return false;
        }
    }

    // And then unmarshalling
    { CORBA::Any* result = reinterpret_cast<CORBA::Any*>(source->createBlob(ORO_CORBA_PROTOCOL_ID));
        ValueDataSource<NotOrogenCompatible::Point2D>* reader =
            new ValueDataSource<NotOrogenCompatible::Point2D>();
        reader->ref();
        reader->updateBlob(ORO_CORBA_PROTOCOL_ID, result);
        NotOrogenCompatible::Point2D value = reader->get();

        if (value.x() != 10 || value.y() != 20)
        {
            cerr << "error in CORBA unmarshalling" << endl;
            cerr << "value.x() == " << value.x() << ", 10 expected" << endl;
            cerr << "value.y() == " << value.y() << ", 20 expected" << endl;
            return false;
        }
    }
#endif
    return true;
}

bool check_position_value(std::string const& place, double timestamp, double x, double y)
{
    if (timestamp != 10 || x != 20 || y != 30)
    {
{'fraction_non_alphanumeric': 0.14589515331355093, 'fraction_numerical': 0.012734915924826904, 'mean_word_length': 3.1933644375324004, 'pattern_counts': {'":': 0, '<': 207, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7228661', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2652, 'n_words': 619}