include(cmake_test/cmake_test)

ct_add_test("cpp_map")
    include(cmakepp_core/map/map)

    ct_add_section("append")
        cpp_map(CTOR a_map foo bar)
        cpp_map(APPEND "${a_map}" foo 42)
        cpp_map(CTOR corr foo bar)
        cpp_map_append("${corr}" foo 42)
        cpp_map_equal("${corr}" result "${a_map}")
        ct_assert_equal(result TRUE)
    ct_end_section()

    ct_add_section("copy")
        cpp_map(CTOR a_map foo bar)
        cpp_map(COPY "${a_map}" other)
        cpp_map_equal("${other}" result "${a_map}")
        ct_assert_equal(result TRUE)
    ct_end_section()

    ct_add_section("ctor")
        ct_add_section("No initial state")
            cpp_map(CTOR a_map)
            cpp_map_ctor(corr)
            cpp_map_equal("${a_map}" result "${corr}")
            ct_assert_equal(result TRUE)
        ct_end_section()

        ct_add_section("With initial state")
            cpp_map(CTOR a_map foo bar)
            cpp_map_ctor(corr foo bar)
            cpp_map_equal("${a_map}" result "${corr}")
            ct_assert_equal(result TRUE)
        ct_end_section()
    ct_end_section()

    ct_add_section("equal")
        cpp_map(CTOR a_map foo bar)
        cpp_map(CTOR other)
        cpp_map(EQUAL "${a_map}" result "${other}")
        ct_assert_equal(result FALSE)
    ct_end_section()

    ct_add_section("get")
        cpp_map(CTOR a_map foo bar)
        cpp_map(GET "${a_map}" result foo)
        ct_assert_equal(result bar)
    ct_end_section()

    ct_add_section("has_key")
        cpp_map(CTOR a_map foo bar)
        cpp_map(HAS_KEY "${a_map}" result foo)
        ct_assert_equal(result TRUE)
    ct_end_section()

    ct_add_section("keys")
        cpp_map(CTOR a_map foo bar)
        cpp_map(KEYS "${a_map}" keys)
        ct_assert_equal(keys foo)
    ct_end_section()

    ct_add_section("set")
        cpp_map(CTOR a_map foo bar)
        cpp_map(SET "${a_map}" foo 42)
        cpp_map(GET "${a_map}" result foo)
        ct_assert_equal(result 42)
    ct_end_section()
ct_end_test()
