<commit_before>#include "common.h"
#include <string>

#include <rtosc/thread-link.h>

void verify_msg(rtosc::msg_t read_msg, const char *portname, int value, const char *test_id, int line)
{
    const std::string test_string = test_id;

    assert_str_eq(portname, read_msg, (test_string + " (portname)").c_str(), line);
    const char* arg_str = rtosc_argument_string(read_msg);
    assert_str_eq("i", arg_str, (test_string + " (arg type)").c_str(), line);
    if(!strcmp(arg_str, "i"))
        assert_int_eq(value, rtosc_argument(read_msg, 0).i, (test_string + " (arg value)").c_str(), line);
}

void test_contiguous_write()
{
    // max 4 messages of each 32 -> 128 bytes size
    rtosc::ThreadLink thread_link(32,4);
    char portname[] = "abcdefghijklmnop"; // length 16, array size 17
    rtosc::msg_t read_msg;

    // always write one message ahead, to check that a second message
    // does not corrupt the "message under test"
    thread_link.write(portname, "i", 42);

    // 10 rounds are enough to have 1 discontigous write
    for (int round = 0; round < 10; ++round)
    {
        // write 17 bytes + 3 bytes padding + 4 bytes argstr + 4 bytes args = 28 bytes
        thread_link.write(portname, "i", 42);
        read_msg = thread_link.read();

        char test_name [] = "round 0";
        test_name[6] += round % 10;
        verify_msg(read_msg, portname, 42, test_name, __LINE__);
    }
}

int main()
{
    test_contiguous_write();

    return test_summary();
}<commit_msg>thread_link_test: Augment contiguous write test<commit_after>#include "common.h"
#include <string>

#include <rtosc/thread-link.h>

void verify_msg(rtosc::msg_t read_msg, const char *portname, int value, const char *test_id, int line)
{
    const std::string test_string = test_id;

    assert_str_eq(portname, read_msg, (test_string + " (portname)").c_str(), line);
    const char* arg_str = rtosc_argument_string(read_msg);
    assert_str_eq("i", arg_str, (test_string + " (arg type)").c_str(), line);
    if(!strcmp(arg_str, "i"))
        assert_int_eq(value, rtosc_argument(read_msg, 0).i, (test_string + " (arg value)").c_str(), line);
}

void test_contiguous_write()
{
    // max 4 messages of each 32 -> 128 bytes size
    rtosc::ThreadLink thread_link(32,4);
    char portname[] = "abcdefghijklmnop"; // length 16, array size 17
    rtosc::msg_t read_msg;

    // always write one message ahead, to check that a second message
    // does not corrupt the "message under test"
    thread_link.write(portname, "i", 42);

    // 10 rounds are enough to have 1 discontigous write
    for (int round = 0; round < 10; ++round)
    {
        // write 17 bytes + 3 bytes padding + 4 bytes argstr + 4 bytes args = 28 bytes
        thread_link.write(portname, "i", 43 + round);
        read_msg = thread_link.read();

        char test_name [] = "round 0";
        test_name[6] += round % 10;
        verify_msg(read_msg, portname, 42 + round, test_name, __LINE__);
    }
}

int main()
{
    test_contiguous_write();

    return test_summary();
}
{'fraction_non_alphanumeric': 0.1326530612244898, 'fraction_numerical': 0.024358130348913758, 'mean_word_length': 3.4364963503649637, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3188692', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1029, 'n_words': 292}