<commit_before>// Copyright (c) 2012-2013 Plenluno All rights reserved.

#include <gtest/gtest.h>
#include <libnode/util.h>

namespace libj {
namespace node {

TEST(GTestUtil, TestExtend) {
    JsObject::Ptr super = JsObject::create();
    super->put(str("a"), 3);
    super->put(str("b"), str("c"));
    JsObject::Ptr derived = JsObject::create();
    ASSERT_TRUE(util::extend(derived, super));
    ASSERT_TRUE(derived->get(str("a")).equals(3));
    ASSERT_TRUE(derived->get(str("b")).equals(str("c")));
}

TEST(GTestUtil, TestHexEncode) {
    String::CPtr encoded = util::hexEncode(Buffer::create());
    ASSERT_TRUE(encoded && encoded->isEmpty());

    Buffer::Ptr buf = Buffer::create(1);
    buf->writeUInt8(0xa9, 0);
    encoded = util::hexEncode(buf);
    ASSERT_EQ(2, encoded->length());
    ASSERT_EQ('a', encoded->charAt(0));
    ASSERT_EQ('9', encoded->charAt(1));
}

TEST(GTestUtil, TestHexDecode) {
    Buffer::Ptr decoded = util::hexDecode(str());
    ASSERT_EQ(0, decoded->length());

    decoded = util::hexDecode(str("a9"));
    ASSERT_EQ(1, decoded->length());<commit_msg>fix a build error<commit_after>// Copyright (c) 2012-2013 Plenluno All rights reserved.

#include <gtest/gtest.h>
#include <libnode/util.h>

namespace libj {
namespace node {

TEST(GTestUtil, TestExtend) {
    JsObject::Ptr addtion = JsObject::create();
    addtion->put(str("a"), 3);
    addtion->put(str("b"), str("c"));

    JsObject::Ptr target = JsObject::create();
    target->put(str("d"), 5);

    ASSERT_EQ(target, util::extend(target, addtion));
    ASSERT_TRUE(target->get(str("a")).equals(3));
    ASSERT_TRUE(target->get(str("b")).equals(str("c")));
    ASSERT_TRUE(target->get(str("d")).equals(5));
}

TEST(GTestUtil, TestHexEncode) {
    String::CPtr encoded = util::hexEncode(Buffer::create());
    ASSERT_TRUE(encoded && encoded->isEmpty());

    Buffer::Ptr buf = Buffer::create(1);
    buf->writeUInt8(0xa9, 0);
    encoded = util::hexEncode(buf);
    ASSERT_EQ(2, encoded->length());
    ASSERT_EQ('a', encoded->charAt(0));
    ASSERT_EQ('9', encoded->charAt(1));
}

TEST(GTestUtil, TestHexDecode) {
    Buffer::Ptr decoded = util::hexDecode(str());
    ASSERT_EQ(0, decoded->length());

    decoded = util::hexDecode(str("a9"));
    ASSERT_EQ(1, decoded->length());
{'fraction_non_alphanumeric': 0.20430579964850615, 'fraction_numerical': 0.020210896309314587, 'mean_word_length': 4.945169712793733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, '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': '3701099', 'n_tokens_mistral': 825, 'n_tokens_neox': 784, 'n_words': 132}