<commit_before>#include "gtest/gtest.h"

#include "mocca/base/ObjectPool.h"

using namespace mocca;

class ObjectPoolTest : public ::testing::Test {
protected:
    ObjectPoolTest() {
        // You can do set-up work for each test here.
    }

    virtual ~ObjectPoolTest() {
        // You can do clean-up work that doesn't throw exceptions here.
    }

    struct MyObject {
        void clear() { str.clear(); }
        std::string str;
    };

};

TEST_F(ObjectPoolTest, CreateAndReturnOneObject) {
    ObjectPool<MyObject> pool(20);
    for (int i = 1; i <= 50; ++i) {
        auto obj = pool.getObject();
        ASSERT_TRUE(obj->str.empty());
        obj->str = "bla";
        ASSERT_EQ("bla", obj->str);
        ASSERT_EQ(19, pool.numFreeObjects());
    }
}

TEST_F(ObjectPoolTest, CreateAndReturnMultipleObjects) {
    ObjectPool<MyObject> pool(20);
    std::vector<std::shared_ptr<MyObject>> objects;
    for (int i = 1; i <= 20; ++i) {
        auto obj = pool.getObject();
        ASSERT_TRUE(obj->str.empty());
        obj->str = "bla";
        objects.push_back(obj);
        ASSERT_EQ(20 - i, pool.numFreeObjects());
    }
    objects.clear();
    ASSERT_EQ(20, pool.numFreeObjects());
}

TEST_F(ObjectPoolTest, IncreasePoolSize) {
    ObjectPool<MyObject> pool(20);
    std::vector<std::shared_ptr<MyObject>> objects;
    for (int i = 1; i <= 50; ++i) {
        objects.push_back(pool.getObject());
    }
    objects.clear();
    ASSERT_EQ(60, pool.numFreeObjects()); // pool size is increase twice by 20
}<commit_msg>fixed tests<commit_after>#include "gtest/gtest.h"

#include "mocca/base/ObjectPool.h"

using namespace mocca;

class ObjectPoolTest : public ::testing::Test {
protected:
    ObjectPoolTest() {
        // You can do set-up work for each test here.
    }

    virtual ~ObjectPoolTest() {
        // You can do clean-up work that doesn't throw exceptions here.
    }

    struct MyObject {
        void clear() { str.clear(); }
        std::string str;
    };

};

TEST_F(ObjectPoolTest, CreateAndReturnOneObject) {
    ObjectPool<MyObject> pool(20);
    for (int i = 1; i <= 50; ++i) {
        auto obj = pool.getObject();
        ASSERT_TRUE(obj->str.empty());
        obj->str = "bla";
        ASSERT_EQ("bla", obj->str);
        ASSERT_EQ(19, pool.numFreeObjects());
    }
}

TEST_F(ObjectPoolTest, CreateAndReturnMultipleObjects) {
    ObjectPool<MyObject> pool(20);
    std::vector<ObjectPool<MyObject>::ObjectPtr> objects;
    for (int i = 1; i <= 20; ++i) {
        auto obj = pool.getObject();
        ASSERT_TRUE(obj->str.empty());
        obj->str = "bla";
        objects.push_back(std::move(obj));
        ASSERT_EQ(20 - i, pool.numFreeObjects());
    }
    objects.clear();
    ASSERT_EQ(20, pool.numFreeObjects());
}

TEST_F(ObjectPoolTest, IncreasePoolSize) {
    ObjectPool<MyObject> pool(20);
    std::vector<ObjectPool<MyObject>::ObjectPtr> objects;
    for (int i = 1; i <= 50; ++i) {
        objects.push_back(pool.getObject());
    }
    objects.clear();
    ASSERT_EQ(60, pool.numFreeObjects()); // pool size is increase twice by 20
}
{'fraction_non_alphanumeric': 0.15225137674117267, 'fraction_numerical': 0.016196954972465177, 'mean_word_length': 2.889168765743073, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '2336776', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1010, 'n_words': 225}