<commit_before>#include <catch.hpp>
#include <limits>

#include "../picojson_serializer.h"
#include "test_helpers.h"

namespace picojson {
    namespace convert {

        template<typename T>
        struct value_converter<T,
                               typename enable_if<std::numeric_limits<T>::is_iec559>::type> {
            static value to_value(T v) {
                return value_converter<double>::to_value(v);
            }
            static void from_value(value const& ov, T& v) {
                double v2(0.);
                value_converter<double>::from_value(ov, v2);
                v = static_cast<T>(v2);
            }
        };

    }
}

TEST_CASE("Non-class type") {

    SECTION("serialization") {

        float f(1.2f);
        picojson::value pv = picojson::convert::to_value(f);
        CHECK(is<double>(pv, 1.2f));

        SECTION("deserialization from value") {
            float f_(0.f);
            picojson::convert::from_value(pv, f_);
            CHECK(f_ == f);

            SECTION("deserialization from string") {
                std::string fs = picojson::convert::to_string(f);
                float f__(0.f);
                picojson::convert::from_string(fs, f__);
                CHECK(f__ == f);
            }
        }

    }

}<commit_msg>added a manual compile test<commit_after>#include <catch.hpp>
#include <limits>

#include "../picojson_serializer.h"
#include "test_helpers.h"

namespace picojson {
    namespace convert {

        template<typename T>
        struct value_converter<T,
                               typename enable_if<std::numeric_limits<T>::is_iec559>::type> {
            static value to_value(T v) {
                return value_converter<double>::to_value(v);
            }
            static void from_value(value const& ov, T& v) {
                double v2(0.);
                value_converter<double>::from_value(ov, v2);
                v = static_cast<T>(v2);
            }
        };

    }
}

TEST_CASE("Non-class type") {

    SECTION("serialization") {

        float f(1.2f);
        picojson::value pv = picojson::convert::to_value(f);
        CHECK(is<double>(pv, 1.2f));

        SECTION("deserialization from value") {
            float f_(0.f);
            picojson::convert::from_value(pv, f_);
            CHECK(f_ == f);

            SECTION("deserialization from string") {
                std::string fs = picojson::convert::to_string(f);
                float f__(0.f);
                picojson::convert::from_string(fs, f__);
                CHECK(f__ == f);
            }
        }

    }

    SECTION("should not compile from predicate") {
        wchar_t c(1);
        //picojson::convert::to_value(c);
    }

}
{'fraction_non_alphanumeric': 0.1325478645066274, 'fraction_numerical': 0.009941089837997054, 'mean_word_length': 1.8243243243243243, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '1170356', 'n_tokens_mistral': 865, 'n_tokens_neox': 825, 'n_words': 148}