include(cmake_test/cmake_test)

ct_add_test(NAME "test_cpp_is_bool")
function("${test_cpp_is_bool}")
    include(cmakepp_lang/types/bool)

    ct_add_section(NAME "test_signature" EXPECTFAIL)
    function("${test_signature}")
        cpp_is_bool(return TRUE hello)
    endfunction()

    ct_add_section(NAME "test_bool")
    function("${test_bool}")
        ct_add_section(NAME "case_insens")
        function("${case_insens}")
            cpp_is_bool(return TrUe)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_ON")
        function("${val_ON}")
            cpp_is_bool(return ON)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_YES")
        function("${val_YES}")
            cpp_is_bool(return YES)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_TRUE")
        function("${val_TRUE}")
            cpp_is_bool(return TRUE)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_Y")
        function("${val_Y}")
            cpp_is_bool(return Y)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_OFF")
        function("${val_OFF}")
            cpp_is_bool(return OFF)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_NO")
        function("${val_NO}")
            cpp_is_bool(return NO)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_FALSE")
        function("${val_FALSE}")
            cpp_is_bool(return FALSE)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_N")
        function("${val_N}")
            cpp_is_bool(return N)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_IGNORE")
        function("${val_IGNORE}")
            cpp_is_bool(return IGNORE)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_NOTFOUND")
        function("${val_NOTFOUND}")
            cpp_is_bool(return NOTFOUND)
            ct_assert_equal(return TRUE)
        endfunction()

        ct_add_section(NAME "val_end_NOTFOUND")
        function("${val_end_NOTFOUND}")
            cpp_is_bool(return hello-notfound)
            ct_assert_equal(return TRUE)
        endfunction()
    endfunction()  # add_section(bool)

    ct_add_section(NAME "test_class")
    function("${test_class}")
        include(cmakepp_lang/class/class)
        cpp_class(MyClass)

        cpp_is_bool(return MyClass)
        ct_assert_equal(return FALSE)
    endfunction()

    ct_add_section(NAME "test_command")
    function("${test_command}")
        cpp_is_bool(return add_subdirectory)
        ct_assert_equal(return FALSE)
    endfunction()

    ct_add_section(NAME "descriptions")
    function("${descriptions}")
        ct_add_section(NAME "description_without_bool")
        function("${description_without_bool}")
            cpp_is_bool(return "Hello World")
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "description_contains_bool")
        function("${description_contains_bool}")
            cpp_is_bool(return "Hello World TRUE")
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "bool_with_whitespace")
        function("${bool_with_whitespace}")
            cpp_is_bool(return " TRUE")
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "contains_notfound_in_middle")
        function("${contains_notfound_in_middle}")
            cpp_is_bool(return "hello-notfound-world")
            ct_assert_equal(return FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "test_float")
    function("${test_float}")
        cpp_is_bool(return 3.14)
        ct_assert_equal(return FALSE)
    endfunction()

    ct_add_section(NAME "test_integer")
    function("${test_integer}")
        ct_add_section(NAME "int_one")
        function("${int_one}")
            cpp_is_bool(return 1)
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "int_zero")
        function("${int_zero}")
            cpp_is_bool(return 0)
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "int_42")
        function("${int_42}")
            cpp_is_bool(return 42)
            ct_assert_equal(return FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "test_list")
    function("${test_list}")
        ct_add_section(NAME "normal_list")
        function("${normal_list}")
            cpp_is_bool(return "1;2;3")
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "list_with_bool_literals")
        function("${list_with_bool_literals}")
            cpp_is_bool(return "TRUE;FALSE")
            ct_assert_equal(return FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "test_map")
    function("${test_map}")
        include(cmakepp_lang/map/map)
        cpp_map(CTOR a_map)
        cpp_is_bool(result a_map)
        ct_assert_equal(result FALSE)
    endfunction()

    ct_add_section(NAME "test_obj")
    function("${test_obj}")
        include(cmakepp_lang/object/object)
        cpp_is_bool(result "${__CMAKEPP_LANG_OBJECT_SINGLETON__}")
        ct_assert_equal(result FALSE)
    endfunction()

    ct_add_section(NAME "test_path")
    function("${test_path}")
        ct_add_section(NAME "normal_path")
        function("${normal_path}")
            cpp_is_bool(return "${CMAKE_CURRENT_LIST_DIR}")
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "path_contains_bool")
        function("${path_contains_bool}")
            cpp_is_bool(return "${CMAKE_CURRENT_LIST_DIR}/TRUE")
            ct_assert_equal(return FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "test_target")
    function("${test_target}")
        ct_add_section(NAME "normal_target_name")
        function("${normal_target_name}")
            add_library(lib STATIC IMPORTED)
            cpp_is_bool(return lib)
            ct_assert_equal(return FALSE)
        endfunction()

        ct_add_section(NAME "target_name_contains_bool")
        function("${target_name_contains_bool}")
            add_library(libTRUE STATIC IMPORTED)
            cpp_is_bool(return libTRUE)
            ct_assert_equal(return FALSE)
        endfunction()
    endfunction()

    ct_add_section(NAME "test_type")
    function("${test_type}")
        cpp_is_bool(return bool)
        ct_assert_equal(return FALSE)
    endfunction()
endfunction()
