1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * https://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */1718package org.apache.commons.lang3.function;
1920importstatic org.junit.jupiter.api.Assertions.assertEquals;
21importstatic org.junit.jupiter.api.Assertions.assertNotNull;
22importstatic org.junit.jupiter.api.Assertions.assertThrows;
2324import java.io.IOException;
2526import org.apache.commons.lang3.AbstractLangTest;
27import org.junit.jupiter.api.Test;
2829/**30 * Tests {@link FailableDoubleToIntFunction}.31 */32classFailableDoubleToIntFunctionTestextendsAbstractLangTest {
3334 @Test
35void testApplyAsInt_returnsResult() throws IOException {
36final FailableDoubleToIntFunction<IOException> f = v -> (int) v;
37 assertEquals(3, f.applyAsInt(3.9));
38 }
3940 @Test
41void testApplyAsInt_throwsException() {
42final IOException expected = new IOException("fail");
43final FailableDoubleToIntFunction<IOException> f = v -> {
44throw expected;
45 };
46final IOException thrown = assertThrows(IOException.class, () -> f.applyAsInt(1.0));
47 assertEquals(expected, thrown);
48 }
4950 @Test
51void testNop_applyAsIntReturnsZero() throws Throwable {
52 assertEquals(0, FailableDoubleToIntFunction.nop().applyAsInt(1.0));
53 }
5455 @Test
56void testNop_returnsNonNull() {
57 assertNotNull(FailableDoubleToIntFunction.nop());
58 }
59 }