2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.misc.rosetta.test;
24 import org.junit.Test;
25 import org.onap.aaf.misc.rosetta.Ladder;
27 import static org.junit.Assert.*;
29 public class JU_Ladder {
33 Ladder<String> ladder = new Ladder<String>();
35 for(int i=0;i<30;++i) {
36 for(int j=0;j<i;++j)ladder.ascend();
37 String str = "Rung " + i;
38 assertEquals(ladder.peek(),null);
40 assertEquals(str,ladder.peek());
41 assertEquals(str,ladder.pop());
42 assertEquals(null,ladder.peek());
43 for(int j=0;j<i;++j)ladder.descend();
45 assertEquals(ladder.height(),32); // Sizing, when naturally created is by 8
48 assertEquals(ladder.height(),8);
50 for(int i=0;i<30;++i) {
52 String str = "Rung " + i;
53 assertEquals(ladder.peek(),null);
55 assertEquals(ladder.peek(),str);
60 for(int i=0;i<30;++i) {
61 assertEquals("Rung " + i,ladder.peek());
67 assertEquals("Rung 29",ladder.peek());
69 for(int i=0;i<30;++i) {
71 assertEquals("Rung " + i,ladder.peek());