This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new e151438  Add test case.
e151438 is described below

commit e151438181c6c46a190d97735e976606b5cea146
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Nov 15 08:30:38 2021 -0500

    Add test case.
---
 .../commons/lang3/function/TriFunctionTest.java    | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git 
a/src/test/java/org/apache/commons/lang3/function/TriFunctionTest.java 
b/src/test/java/org/apache/commons/lang3/function/TriFunctionTest.java
new file mode 100644
index 0000000..8826be6
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/function/TriFunctionTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.function;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.math.BigInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Function;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@linkTriConsumer}.
+ */
+public class TriFunctionTest {
+
+    @Test
+    public void testAccept() throws Throwable {
+        final AtomicReference<Character> ref1 = new AtomicReference<>();
+        final AtomicReference<Short> ref2 = new AtomicReference<>();
+        final AtomicReference<String> ref3 = new AtomicReference<>();
+        final TriFunction<AtomicReference<Character>, AtomicReference<Short>, 
AtomicReference<String>, String> tri = (t, u, v) -> {
+            ref1.set(Character.valueOf('a'));
+            ref2.set(Short.valueOf((short) 1));
+            ref3.set("z");
+            return "ABC";
+        };
+        assertEquals("ABC", tri.apply(ref1, ref2, ref3));
+        assertEquals(Character.valueOf('a'), ref1.get());
+        assertEquals(Short.valueOf((short) 1), ref2.get());
+        assertEquals("z", ref3.get());
+    }
+
+    @Test
+    public void testAndThen() throws Throwable {
+        final AtomicReference<Character> ref1 = new AtomicReference<>();
+        final AtomicReference<Short> ref2 = new AtomicReference<>();
+        final AtomicReference<String> ref3 = new AtomicReference<>();
+        final TriFunction<AtomicReference<Character>, AtomicReference<Short>, 
AtomicReference<String>, String> tri = (t, u, v) -> {
+            ref1.set(Character.valueOf('a'));
+            ref2.set(Short.valueOf((short) 1));
+            ref3.set("z");
+            return "9";
+        };
+        final Function<String, BigInteger> after = t -> {
+            ref1.set(Character.valueOf('b'));
+            ref2.set(Short.valueOf((short) 2));
+            ref3.set("zz");
+            return BigInteger.valueOf(Long.parseLong(t)).add(BigInteger.ONE);
+        };
+        assertEquals(BigInteger.TEN, tri.andThen(after).apply(ref1, ref2, 
ref3));
+        assertEquals(Character.valueOf('b'), ref1.get());
+        assertEquals(Short.valueOf((short) 2), ref2.get());
+        assertEquals("zz", ref3.get());
+    }
+
+}

Reply via email to