Java example source code file (LinkedHashTreeMapTest.java)
This example Java source code file (LinkedHashTreeMapTest.java) is included in the alvinalexander.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
The LinkedHashTreeMapTest.java Java example source code
/*
* Copyright (C) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.internal;
import com.google.gson.common.MoreAsserts;
import com.google.gson.internal.LinkedHashTreeMap.AvlBuilder;
import com.google.gson.internal.LinkedHashTreeMap.AvlIterator;
import com.google.gson.internal.LinkedHashTreeMap.Node;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import junit.framework.TestCase;
public final class LinkedHashTreeMapTest extends TestCase {
public void testIterationOrder() {
LinkedHashTreeMap<String, String> map = new LinkedHashTreeMap();
map.put("a", "android");
map.put("c", "cola");
map.put("b", "bbq");
assertIterationOrder(map.keySet(), "a", "c", "b");
assertIterationOrder(map.values(), "android", "cola", "bbq");
}
public void testRemoveRootDoesNotDoubleUnlink() {
LinkedHashTreeMap<String, String> map = new LinkedHashTreeMap();
map.put("a", "android");
map.put("c", "cola");
map.put("b", "bbq");
Iterator<Map.Entry it = map.entrySet().iterator();
it.next();
it.next();
it.next();
it.remove();
assertIterationOrder(map.keySet(), "a", "c");
}
public void testPutNullKeyFails() {
LinkedHashTreeMap<String, String> map = new LinkedHashTreeMap();
try {
map.put(null, "android");
fail();
} catch (NullPointerException expected) {
}
}
public void testPutNonComparableKeyFails() {
LinkedHashTreeMap<Object, String> map = new LinkedHashTreeMap
Other Java examples (source code examples)
Here is a short list of links related to this Java LinkedHashTreeMapTest.java source code file: