<commit_before>﻿/// @author <NAME>

#include "test.hpp"
#include <data/object>
#include <data/exception>

namespace data
{
    namespace test
    {
        class test_object : public test
        {
        public:
            virtual void run() override
            {
                data::object empty;
                DATA_CHECK_IS_TRUE(empty.is_null());
                DATA_CHECK_EXCEPTION_THROWN(null_representation_error, empty.as<int>());
                DATA_CHECK_EXCEPTION_THROWN(null_representation_error, empty.as<float>());
                DATA_CHECK_IS_FALSE(empty.as<bool>());

                data::object obj = data::object(123);
                DATA_CHECK_EQUAL(obj.as<int>(), 123);
                DATA_CHECK_EQUAL(obj.as<int64_t>(), 123);
                DATA_CHECK_EQUAL(obj.as<double>(), 123);
                DATA_CHECK_EQUAL(obj.as<uint8_t>(), 123);
                DATA_CHECK_IS_TRUE(obj.as<bool>());

                data::object real = data::object(3.14159);
                DATA_CHECK_CLOSE(real.as<double>(), 3.14159, 1e-15);
                DATA_CHECK_EQUAL(real.as<int>(), 4);
                DATA_CHECK_IS_TRUE(real.as<bool>());
            }
        } g_test_object;
    }
}

// sine qua non<commit_msg>Fixed bug in wrong test condition.<commit_after>﻿/// @author <NAME>

#include "test.hpp"
#include <data/object>
#include <data/exception>

namespace data
{
    namespace test
    {
        class test_object : public test
        {
        public:
            virtual void run() override
            {
                data::object empty;
                DATA_CHECK_IS_TRUE(empty.is_null());
                DATA_CHECK_EXCEPTION_THROWN(null_representation_error, empty.as<int>());
                DATA_CHECK_EXCEPTION_THROWN(null_representation_error, empty.as<float>());
                DATA_CHECK_IS_FALSE(empty.as<bool>());

                data::object obj = data::object(123);
                DATA_CHECK_EQUAL(obj.as<int>(), 123);
                DATA_CHECK_EQUAL(obj.as<int64_t>(), 123);
                DATA_CHECK_EQUAL(obj.as<double>(), 123);
                DATA_CHECK_EQUAL(obj.as<uint8_t>(), 123);
                DATA_CHECK_IS_TRUE(obj.as<bool>());

                data::object real = data::object(3.14159);
                DATA_CHECK_CLOSE(real.as<double>(), 3.14159, 1e-15);
                DATA_CHECK_EQUAL(real.as<int>(), 3);
                DATA_CHECK_IS_TRUE(real.as<bool>());
            }
        } g_test_object;
    }
}

// sine qua non
{'fraction_non_alphanumeric': 0.13036502206177297, 'fraction_numerical': 0.02727637384677096, 'mean_word_length': 1.9868263473053893, 'pattern_counts': {'":': 0, '<': 31, '<?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': '2238684', 'n_tokens_mistral': 850, 'n_tokens_neox': 755, 'n_words': 114}