#
# Copyright (c) 2013-2019 Vinnie Falco (vinnie.falco@gmail.com)
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/boostorg/json
#

import testing ;
import ../../config/checks/config : requires ;

import os ;
STANDALONE = [ os.environ STANDALONE ] ;
if $(STANDALONE)
{
    LIB =
        <define>BOOST_JSON_STANDALONE=1
        <source>../src/src.cpp
        ;
}
else
{
    LIB = <library>/boost/json//boost_json ;
}

local SOURCES =
    array.cpp
    basic_parser.cpp
    doc_background.cpp
    doc_parsing.cpp
    doc_quick_look.cpp
    doc_serializing.cpp
    doc_storage_ptr.cpp
    doc_uses_allocator.cpp
    doc_using_numbers.cpp
    double.cpp
    error.cpp
    fwd.cpp
    json.cpp
    kind.cpp
    monotonic_resource.cpp
    natvis.cpp
    null_resource.cpp
    object.cpp
    parse.cpp
    parser.cpp
    pilfer.cpp
    serialize.cpp
    serializer.cpp
    snippets.cpp
    static_resource.cpp
    storage_ptr.cpp
    stream_parser.cpp
    string.cpp
    string_view.cpp
    system_error.cpp
    value.cpp
    value_from.cpp
    value_stack.cpp
    value_to.cpp
    value_ref.cpp
    visit.cpp
    ryu/d2s_intrinsics_test.cpp
    ryu/d2s_table_test.cpp
    ryu/d2s_test.cpp
    ;

local LIMIT_SOURCES =
    limits.cpp
    ;

local RUN_TESTS ;

project : requirements $(c11-requires) ;

for local f in $(SOURCES)
{
    RUN_TESTS += [
        run $(f) main.cpp
            /boost//container/<warnings-as-errors>off
            : : : $(LIB) <include>.
        ] ;
}

RUN_TESTS += [
    run memory_resource.cpp main.cpp
        /boost//container/<warnings-as-errors>off
        : : :
        $(LIB)
        <include>.
        ] ;

for local f in $(LIMIT_SOURCES)
{
    RUN_TESTS += [
        run $(f) main.cpp
            /boost//container/<warnings-as-errors>off
            : : :
            <source>../src/src.cpp
            <include>.
            <define>BOOST_JSON_MAX_STRING_SIZE=1000
            <define>BOOST_JSON_MAX_STRUCTURED_SIZE=20
            <define>BOOST_JSON_STACK_BUFFER_SIZE=256
        ] ;
}

if ! $(STANDALONE)
{
    RUN_TESTS += [
        compile standalone_with_boost.cpp
            : [ requires
              cxx17_hdr_string_view
              cxx17_hdr_memory_resource
              ]
              <define>BOOST_JSON_STANDALONE=1
    ] ;
}

alias run-tests : $(RUN_TESTS) ;
