This commit is contained in:
Looly
2023-05-28 23:14:37 +08:00
parent 1527d6e27c
commit 87a1b7e1a2
5 changed files with 249 additions and 41 deletions

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 looly(loolly@aliyun.com)
* Hutool is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.dromara.hutool.core.lang.tuple;
import org.dromara.hutool.core.lang.mutable.MutablePair;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* {@link Pair} 二元组单元测试
* {@link MutablePair} 二元组单元测试
*
* @author looly
*/
public class PairTest {
@Test
public void mutablePairTest() {
final MutablePair<String, String> pair = MutablePair
.of("1", "1");
Assertions.assertEquals("Pair{left=1, right=1}", pair.toString());
pair.setLeft("2");
pair.setRight("2");
Assertions.assertEquals("Pair{left=2, right=2}", pair.toString());
}
@Test
public void pairTest() {
final Pair<String, String> triple = Pair
.of("3", "3");
Assertions.assertEquals("Pair{left=3, right=3}", triple.toString());
}
}

View File

@@ -28,18 +28,18 @@ public class TripleTest {
public void mutableTripleTest() {
final MutableTriple<String, String, String> mutableTriple = MutableTriple
.of("1", "1", "1");
Assertions.assertEquals("Triple {left=1, middle=1, right=1}", mutableTriple.toString());
Assertions.assertEquals("Triple{left=1, middle=1, right=1}", mutableTriple.toString());
mutableTriple.setLeft("2");
mutableTriple.setMiddle("2");
mutableTriple.setRight("2");
Assertions.assertEquals("Triple {left=2, middle=2, right=2}", mutableTriple.toString());
Assertions.assertEquals("Triple{left=2, middle=2, right=2}", mutableTriple.toString());
}
@Test
public void tripleTest() {
final Triple<String, String, String> triple = Triple
.of("3", "3", "3");
Assertions.assertEquals("Triple {left=3, middle=3, right=3}", triple.toString());
Assertions.assertEquals("Triple{left=3, middle=3, right=3}", triple.toString());
}
}