include(cmake_test/cmake_test)

ct_add_test(NAME "test_cpp_map_ctor")
function("${test_cpp_map_ctor}")
    include(cmakepp_lang/map/map)
    include(cmakepp_lang/types/type_of)
    include(cmakepp_lang/utilities/compare_lists)

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

        cpp_map_ctor(TRUE)
    endfunction()

    ct_add_section(NAME "default_ctor")
    function("${default_ctor}")
        cpp_map_ctor(a_map)

        ct_add_section(NAME "map_recognized")
        function("${map_recognized}")
            cpp_type_of(result "${a_map}")
            ct_assert_equal(result map)
        endfunction()

        ct_add_section(NAME "has_no_keys")
        function("${has_no_keys}")
            cpp_map(KEYS "${a_map}" keys)
            set(corr)
            cpp_compare_lists(result corr keys)
            ct_assert_equal(result TRUE)
        endfunction()
    endfunction()

    ct_add_section(NAME "one_key_val_pair")
    function("${one_key_val_pair}")
        cpp_map_ctor(a_map foo bar)

        ct_add_section(NAME "map_recognized")
        function("${map_recognized}")
            cpp_type_of(result "${a_map}")
            ct_assert_equal(result map)
        endfunction()

        ct_add_section(NAME "keys_equal_foo")
        function("${keys_equal_foo}")
            cpp_map(KEYS "${a_map}" keys)
            set(corr foo)
            cpp_compare_lists(result corr keys)
            ct_assert_equal(result TRUE)
        endfunction()

        ct_add_section(NAME "foo_val_not_set_right")
        function("${foo_val_not_set_right}")
            cpp_map(GET "${a_map}" result foo)
            ct_assert_equal(result bar)
        endfunction()
    endfunction()

    ct_add_section(NAME "two_key_val_pairs")
    function("${two_key_val_pairs}")
        cpp_map_ctor(a_map foo bar hello world)

        ct_add_section(NAME "map_recognized")
        function("${map_recognized}")
            cpp_type_of(result "${a_map}")
            ct_assert_equal(result map)
        endfunction()

        ct_add_section(NAME "keys_equal_foo_hello")
        function("${keys_equal_foo_hello}")
            cpp_map(KEYS "${a_map}" keys)
            set(corr foo hello)
            cpp_compare_lists(result corr keys)
            ct_assert_equal(result TRUE)
        endfunction()

        ct_add_section(NAME "foo_val_not_set_right")
        function("${foo_val_not_set_right}")
            cpp_map(GET "${a_map}" result foo)
            ct_assert_equal(result bar)
        endfunction()

        ct_add_section(NAME "hello_val_not_set_right")
        function("${hello_val_not_set_right}")
            cpp_map(GET "${a_map}" result hello)
            ct_assert_equal(result world)
        endfunction()
    endfunction()
endfunction()
