<commit_before>#include "test_common.h"

#include <iostream>
#include <thread>
#include <atomic>

static void func(const std::string& name, std::atomic<int>* count)
{
    count->fetch_add(1);
    std::cout << "Thread id=" << std::this_thread::get_id() << " name=" << name << std::endl;
    std::flush(std::cout);
}

TEST_UNIT(thread_test)
{
    std::atomic<int> count;
    std::thread t1(func, "thread1", &count);
    std::thread t2(func, "thread2", &count);
    t1.join();
    t2.join();
    H_TEST_ASSERT(count == 2);
}

<commit_msg>add more thread function test code<commit_after>#include "test_common.h"

#include <iostream>
#include <thread>
#include <atomic>

static void CountInc(const std::string& name, std::atomic<int>* count)
{
    count->fetch_add(1);
    std::cout << "Thread id=" << std::this_thread::get_id() << " name=" << name << std::endl;
    std::flush(std::cout);
}

namespace
{
    struct User
    {
        std::string name;
        std::string addr;

        void Print(const std::string& message, std::atomic<int>* count)
        {
            count->fetch_add(1);
            std::cout << "Thread id=" << std::this_thread::get_id() << " message=" << message << " name=" << name << " addr=" << addr << std::endl;
        }
    };
}

TEST_UNIT(thread_test)
{
    User u;
    u.name = "zieckey";
    u.addr = "beijing";
    std::atomic<int> count;
    std::thread t1(CountInc, "thread1", &count);
    std::thread t2(&CountInc, "thread2", &count);
    std::thread t3(std::bind(&User::Print, &u, "user", &count));
    t1.join();
    t2.join();
    t3.join();
    H_TEST_ASSERT(count == 3);
}


{'fraction_non_alphanumeric': 0.201363073110285, 'fraction_numerical': 0.011771995043370507, 'mean_word_length': 3.575070821529745, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 17, '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': '1593078', 'n_tokens_mistral': 587, 'n_tokens_neox': 579, 'n_words': 120}