1/*
2 * Copyright 2018 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 */
16package androidx.collection;
17
18import static org.junit.Assert.assertEquals;
19import static org.junit.Assert.assertFalse;
20import static org.junit.Assert.assertTrue;
21import static org.junit.Assert.fail;
22
23import org.junit.Test;
24
25import java.util.Iterator;
26import java.util.NoSuchElementException;
27
28public class ArraySetCompatTest {
29    @Test
30    public void testCanNotIteratePastEnd() {
31        ArraySet<String> set = new ArraySet<>();
32        set.add("value");
33        Iterator<String> iterator = set.iterator();
34
35        assertTrue(iterator.hasNext());
36        assertEquals("value", iterator.next());
37        assertFalse(iterator.hasNext());
38
39        try {
40            iterator.next();
41            fail();
42        } catch (NoSuchElementException expected) {
43        }
44    }
45}
46