<commit_before>#include <gtest/gtest.h>
#include <JsonObject.h>
#include <JsonValue.h>
#include <StaticJsonBuffer.h>

class JsonObjectSerializationTests : public testing::Test
{
protected:
    virtual void SetUp()
    {
        object = json.createObject();
    }

    void outputMustBe(const char* expected)
    {        
        char actual[256];
        int result = object.printTo(actual, sizeof(actual));

        EXPECT_STREQ(expected, actual);
        EXPECT_EQ(strlen(expected), result);
    }

    JsonObject object;

private:
    StaticJsonBuffer<42> json;
};

TEST_F(JsonObjectSerializationTests, EmptyObject)
{
    outputMustBe("{}");
}

TEST_F(JsonObjectSerializationTests, OneString)
{
    object["key"] = "value";

    outputMustBe("{\"key\":\"value\"}");
}

TEST_F(JsonObjectSerializationTests, TwoStrings)
{
    object["key1"] = "value1";
    object["key2"] = "value2";

    outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
}
/*
TEST_F(JsonObjectSerializationTests, RemoveFirst)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object.remove("key1");

    outputMustBe("{\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, RemoveLast)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object.remove("key2");

    outputMustBe("{\"key1\":\"value1\"}");
}

TEST_F(JsonObjectSerializationTests, RemoveUnexistingKey)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object.remove("key3");

    outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, ReplaceExistingKey)
{
    object["key"] = "value1";
    object["key"] = "value2";

    outputMustBe("{\"key\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, OneStringOverCapacity)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object["key3"] = "value3";

    outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, OneInteger)
{
    object["key"] = 1;
    outputMustBe("{\"key\":1}");
}

TEST_F(JsonObjectSerializationTests, OneDoubleFourDigits)
{
    object["key"].set<4>(3.14159265358979323846);
    outputMustBe("{\"key\":3.1416}");
}

TEST_F(JsonObjectSerializationTests, OneDoubleDefaultDigits)
{
    object["key"] = 3.14159265358979323846;
    outputMustBe("{\"key\":3.14}");
}

TEST_F(JsonObjectSerializationTests, OneNull)
{<commit_msg>Restored tests from previous test suite<commit_after>#include <gtest/gtest.h>
#include <JsonObject.h>
#include <JsonValue.h>
#include <StaticJsonBuffer.h>

class JsonObjectSerializationTests : public testing::Test
{
protected:
    virtual void SetUp()
    {
        object = json.createObject();
    }

    void outputMustBe(const char* expected)
    {        
        char actual[256];
        int result = object.printTo(actual, sizeof(actual));

        EXPECT_STREQ(expected, actual);
        EXPECT_EQ(strlen(expected), result);
    }

    JsonObject object;

private:
    StaticJsonBuffer<42> json;
};

TEST_F(JsonObjectSerializationTests, EmptyObject)
{
    outputMustBe("{}");
}

TEST_F(JsonObjectSerializationTests, OneString)
{
    object["key"] = "value";

    outputMustBe("{\"key\":\"value\"}");
}

TEST_F(JsonObjectSerializationTests, TwoStrings)
{
    object["key1"] = "value1";
    object["key2"] = "value2";

    outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, RemoveFirst)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object.remove("key1");

    outputMustBe("{\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, RemoveLast)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object.remove("key2");

    outputMustBe("{\"key1\":\"value1\"}");
}

TEST_F(JsonObjectSerializationTests, RemoveUnexistingKey)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object.remove("key3");

    outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, ReplaceExistingKey)
{
    object["key"] = "value1";
    object["key"] = "value2";

    outputMustBe("{\"key\":\"value2\"}");
}
/*
TEST_F(JsonObjectSerializationTests, OneStringOverCapacity)
{
    object["key1"] = "value1";
    object["key2"] = "value2";
    object["key3"] = "value3";

    outputMustBe("{\"key1\":\"value1\",\"key2\":\"value2\"}");
}

TEST_F(JsonObjectSerializationTests, OneInteger)
{
    object["key"] = 1;
    outputMustBe("{\"key\":1}");
}

TEST_F(JsonObjectSerializationTests, OneDoubleFourDigits)
{
    object["key"].set<4>(3.14159265358979323846);
    outputMustBe("{\"key\":3.1416}");
}

TEST_F(JsonObjectSerializationTests, OneDoubleDefaultDigits)
{
    object["key"] = 3.14159265358979323846;
    outputMustBe("{\"key\":3.14}");
}

TEST_F(JsonObjectSerializationTests, OneNull)
{
{'fraction_non_alphanumeric': 0.19436386241193535, 'fraction_numerical': 0.042271031910484876, 'mean_word_length': 4.387276785714286, 'pattern_counts': {'":': 26, '<': 15, '<?xml version=': 0, '>': 15, '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': '3504903', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1706, 'n_words': 221}