|
Java example source code file (TripleTest.java)
The TripleTest.java Java example source code
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.commons.lang3.tuple;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Calendar;
import java.util.HashSet;
import org.junit.Test;
/**
* Test the Triple class.
*/
public class TripleTest {
@Test
public void testTripleOf() throws Exception {
final Triple<Integer, String, Boolean> triple = Triple.of(0, "foo", Boolean.TRUE);
assertTrue(triple instanceof ImmutableTriple<?, ?, ?>);
assertEquals(0, ((ImmutableTriple<Integer, String, Boolean>) triple).left.intValue());
assertEquals("foo", ((ImmutableTriple<Integer, String, Boolean>) triple).middle);
assertEquals(Boolean.TRUE, ((ImmutableTriple<Integer, String, Boolean>) triple).right);
final Triple<Object, String, Long> triple2 = Triple.of(null, "bar", Long.valueOf(200L));
assertTrue(triple2 instanceof ImmutableTriple<?, ?, ?>);
assertNull(((ImmutableTriple<Object, String, Long>) triple2).left);
assertEquals("bar", ((ImmutableTriple<Object, String, Long>) triple2).middle);
assertEquals(new Long(200L), ((ImmutableTriple<Object, String, Long>) triple2).right);
}
@Test
public void testCompatibilityBetweenTriples() throws Exception {
final Triple<Integer, String, Boolean> triple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
final Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
assertEquals(triple, triple2);
assertEquals(triple.hashCode(), triple2.hashCode());
final HashSet<Triple
Other Java examples (source code examples)Here is a short list of links related to this Java TripleTest.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.