• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 
17 /*
18  * @test
19  * @bug 7123229
20  * @summary (coll) EnumMap.containsValue(null) returns true
21  * @author ngmr
22  */
23 package test.java.util.EnumMap;
24 
25 import java.util.EnumMap;
26 import java.util.Map;
27 
28 import org.testng.Assert;
29 import org.testng.annotations.Test;
30 
31 public class UniqueNullValue {
32     static enum TestEnum { e00, e01 }
33 
34     @Test
testUniqueNull()35     public void testUniqueNull() {
36         Map<TestEnum, Integer> map = new EnumMap<>(TestEnum.class);
37 
38         map.put(TestEnum.e00, 0);
39         Assert.assertTrue(map.containsValue(0));
40         Assert.assertFalse(map.containsValue(null));
41 
42         map.put(TestEnum.e00, null);
43         Assert.assertFalse(map.containsValue(0));
44         Assert.assertTrue(map.containsValue(null));
45     }
46 }