include(cmake_test/cmake_test)

ct_add_test(NAME "test_cpp_contains")
function("${test_cpp_contains}")
    include(cmakepp_lang/algorithm/contains)

    ct_add_section(NAME "signature")
    function("${signature}")
        set(CMAKEPP_LANG_DEBUG_MODE ON)

        ct_add_section(NAME "arg_must_be_desc" EXPECTFAIL)
        function("${arg_must_be_desc}")
            cpp_contains(TRUE an_item a_list)
        endfunction()

        ct_add_section(NAME "three_args" EXPECTFAIL)
        function("${three_args}")
            cpp_contains(result an_item a_list hello)
        endfunction()
    endfunction()

    ct_add_section(NAME "list")
    function("${list}")
        set(a_list 1 2 3)
        ct_add_section(NAME "is_in_list")
        function("${is_in_list}")
            cpp_contains(result 1 "${a_list}")
            ct_assert_equal(result TRUE)
        endfunction()

        ct_add_section(NAME "is_not_in_list")
        function("${is_not_in_list}")
            cpp_contains(result 42 "${a_list}")
            ct_assert_equal(result FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "map")
    function("${map}")
        include(cmakepp_lang/map/map)

        cpp_map(CTOR a_map a_key a_value foo bar)

        ct_add_section(NAME "has_key")
        function("${has_key}")
            cpp_contains(result "foo" "${a_map}")
            ct_assert_equal(result TRUE)
        endfunction()

        ct_add_section(NAME "does_not_have_key")
        function("${does_not_have_key}")
            cpp_contains(result "bar" "${a_map}")
            ct_assert_equal(result FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "string")
    function("${string}")
        ct_add_section(NAME "is_in_string")
        function("${is_in_string}")
            cpp_contains(result "world" "Hello world")
            ct_assert_equal(result TRUE)
        endfunction()

        ct_add_section(NAME "is_not_in_string")
        function("${is_not_in_string}")
            cpp_contains(result "goodbye" "Hello world")
            ct_assert_equal(result FALSE)
        endfunction()
    endfunction()
endfunction()
