<commit_before>#include "gtest/gtest.h"
#include "dsb/execution.hpp"

using namespace dsb::execution;

TEST(dsb_execution, Controller)
{
    auto context = std::make_shared<zmq::context_t>();
    auto exec = SpawnExecution(context, "inproc://dsb_execution_test_Controller");

    // Unfortunately, at the current time, we can only check whether the
    // functions correctly handle the most trivial errors, and not whether they
    // actually do what they're supposed to do.  The latter requires us to have
    // actual slaves present, which is hard to achieve in simple unittests.

    EXPECT_NO_THROW(exec.SetSimulationTime(1.0));
    EXPECT_NO_THROW(exec.SetSimulationTime(1.0, 2.0));
    EXPECT_THROW(exec.SetSimulationTime(2.0, 1.0), std::runtime_error);
    EXPECT_NO_THROW(exec.SetSimulationTime(1.0, 2.0));

    EXPECT_NO_THROW(exec.AddSlave(1));
    EXPECT_NO_THROW(exec.AddSlave(2));
    EXPECT_THROW(exec.AddSlave(1), std::runtime_error);
    EXPECT_NO_THROW(exec.AddSlave(3));
    EXPECT_THROW(exec.SetSimulationTime(1.0, 2.0), std::runtime_error);

    EXPECT_NO_THROW(exec.SetVariables(1, dsb::sequence::EmptySequence<Variable&>()));
    Variable v[2] = { { 1, 3.14 }, { 2, -10.0 } };
    EXPECT_NO_THROW(exec.SetVariables(2, dsb::sequence::ArraySequence(v, 2)));
    EXPECT_THROW(exec.SetVariables(4, dsb::sequence::EmptySequence<Variable&>()), std::runtime_error);
    EXPECT_THROW(exec.SetVariables(5, dsb::sequence::ArraySequence(v, 2)), std::runtime_error);

    EXPECT_NO_THROW(exec.ConnectVariables(1, dsb::sequence::EmptySequence<VariableConnection&>()));
    VariableConnection c[3] = { { 0, 2, 0 }, { 0, 3, 0 }, { 0, 4, 0 } };
    EXPECT_NO_THROW(exec.ConnectVariables(2, dsb::sequence::ArraySequence(c, 2)));
    EXPECT_THROW(exec.ConnectVariables(4, dsb::sequence::EmptySequence<VariableConnection&>()), std::runtime_error);
    EXPECT_THROW(exec.ConnectVariables(5, dsb::sequence::ArraySequence(c, 2)), std::runtime_error);
    // The third connection has an invalid slave ID (4).
    EXPECT_THROW(exec.ConnectVariables(1, dsb::sequence::ArraySequence(c, 3)), std::runtime_error);
    
    EXPECT_NO_THROW(exec.Terminate());
}<commit_msg>Updated sequence function names in dsb_test<commit_after>#include "gtest/gtest.h"
#include "dsb/execution.hpp"

using namespace dsb::execution;

TEST(dsb_execution, Controller)
{
    auto context = std::make_shared<zmq::context_t>();
    auto exec = SpawnExecution(context, "inproc://dsb_execution_test_Controller");

    // Unfortunately, at the current time, we can only check whether the
    // functions correctly handle the most trivial errors, and not whether they
    // actually do what they're supposed to do.  The latter requires us to have
    // actual slaves present, which is hard to achieve in simple unittests.

    EXPECT_NO_THROW(exec.SetSimulationTime(1.0));
    EXPECT_NO_THROW(exec.SetSimulationTime(1.0, 2.0));
    EXPECT_THROW(exec.SetSimulationTime(2.0, 1.0), std::runtime_error);
    EXPECT_NO_THROW(exec.SetSimulationTime(1.0, 2.0));

    EXPECT_NO_THROW(exec.AddSlave(1));
    EXPECT_NO_THROW(exec.AddSlave(2));
    EXPECT_THROW(exec.AddSlave(1), std::runtime_error);
    EXPECT_NO_THROW(exec.AddSlave(3));
    EXPECT_THROW(exec.SetSimulationTime(1.0, 2.0), std::runtime_error);

    EXPECT_NO_THROW(exec.SetVariables(1, dsb::sequence::EmptySequence<Variable>()));
    Variable v[2] = { { 1, 3.14 }, { 2, -10.0 } };
    EXPECT_NO_THROW(exec.SetVariables(2, dsb::sequence::ElementsOf(v, 2)));
    EXPECT_THROW(exec.SetVariables(4, dsb::sequence::EmptySequence<Variable>()), std::runtime_error);
    EXPECT_THROW(exec.SetVariables(5, dsb::sequence::ElementsOf(v, 2)), std::runtime_error);

    EXPECT_NO_THROW(exec.ConnectVariables(1, dsb::sequence::EmptySequence<VariableConnection>()));
    VariableConnection c[3] = { { 0, 2, 0 }, { 0, 3, 0 }, { 0, 4, 0 } };
    EXPECT_NO_THROW(exec.ConnectVariables(2, dsb::sequence::ElementsOf(c, 2)));
    EXPECT_THROW(exec.ConnectVariables(4, dsb::sequence::EmptySequence<VariableConnection>()), std::runtime_error);
    EXPECT_THROW(exec.ConnectVariables(5, dsb::sequence::ElementsOf(c, 2)), std::runtime_error);
    // The third connection has an invalid slave ID (4).
    EXPECT_THROW(exec.ConnectVariables(1, dsb::sequence::ElementsOf(c, 3)), std::runtime_error);
    
    EXPECT_NO_THROW(exec.Terminate());
}
{'fraction_non_alphanumeric': 0.14998849781458476, 'fraction_numerical': 0.02576489533011272, 'mean_word_length': 5.48955223880597, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3927141', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1483, 'n_words': 271}