ArrayMapTest.kt revision b9b8af241d3be7d0d26a04cb2ec331db28c295c8
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *       http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package androidx.collection
18
19import com.google.common.truth.Truth.assertThat
20import org.junit.Assert.assertEquals
21import org.junit.Test
22
23class ArrayMapTest {
24    @Test fun empty() {
25        val map = arrayMapOf<String, String>()
26        assertEquals(0, map.size)
27    }
28
29    @Test fun nonEmpty() {
30        val map = arrayMapOf("foo" to "bar", "bar" to "baz")
31        assertThat(map).containsExactly("foo", "bar", "bar", "baz")
32    }
33
34    @Test fun duplicateKeyKeepsLast() {
35        val map = arrayMapOf("foo" to "bar", "foo" to "baz")
36        assertThat(map).containsExactly("foo", "baz")
37    }
38}
39