org.apache.commons.lang3.math.NumberUtils.min()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.commons.lang3.math.NumberUtils.min()方法的一些代码示例,展示了NumberUtils.min()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NumberUtils.min()方法的具体详情如下:
包路径:org.apache.commons.lang3.math.NumberUtils
类名称:NumberUtils
方法名:min

NumberUtils.min介绍

[英]Gets the minimum of three byte values.
[中]获取至少三个byte值。

代码示例

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinDouble_nullArray() {
  NumberUtils.min((double[]) null);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinLong_nullArray() {
  NumberUtils.min((long[]) null);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinInt_nullArray() {
  NumberUtils.min((int[]) null);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinDouble_emptyArray() {
  NumberUtils.min(new double[0]);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinShort_nullArray() {
  NumberUtils.min((short[]) null);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinFloat_emptyArray() {
  NumberUtils.min(new float[0]);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinLong_emptyArray() {
  NumberUtils.min(new long[0]);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinShort_emptyArray() {
  NumberUtils.min(new short[0]);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinInt_emptyArray() {
  NumberUtils.min(new int[0]);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinByte_emptyArray() {
  NumberUtils.min();
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected = IllegalArgumentException.class)
public void testMinFloat_nullArray() {
  NumberUtils.min((float[]) null);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinimumInt() {
  assertEquals("minimum(int,int,int) 1 failed", 12345, NumberUtils.min(12345, 12345 + 1, 12345 + 2));
  assertEquals("minimum(int,int,int) 2 failed", 12345, NumberUtils.min(12345 + 1, 12345, 12345 + 2));
  assertEquals("minimum(int,int,int) 3 failed", 12345, NumberUtils.min(12345 + 1, 12345 + 2, 12345));
  assertEquals("minimum(int,int,int) 4 failed", 12345, NumberUtils.min(12345 + 1, 12345, 12345));
  assertEquals("minimum(int,int,int) 5 failed", 12345, NumberUtils.min(12345, 12345, 12345));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinimumByte() {
  final byte low = 123;
  final byte mid = 123 + 1;
  final byte high = 123 + 2;
  assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(low, mid, high));
  assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, low, high));
  assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(mid, high, low));
  assertEquals("minimum(byte,byte,byte) 1 failed", low, NumberUtils.min(low, mid, low));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinimumLong() {
  assertEquals("minimum(long,long,long) 1 failed", 12345L, NumberUtils.min(12345L, 12345L + 1L, 12345L + 2L));
  assertEquals("minimum(long,long,long) 2 failed", 12345L, NumberUtils.min(12345L + 1L, 12345L, 12345 + 2L));
  assertEquals("minimum(long,long,long) 3 failed", 12345L, NumberUtils.min(12345L + 1L, 12345L + 2L, 12345L));
  assertEquals("minimum(long,long,long) 4 failed", 12345L, NumberUtils.min(12345L + 1L, 12345L, 12345L));
  assertEquals("minimum(long,long,long) 5 failed", 12345L, NumberUtils.min(12345L, 12345L, 12345L));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinimumDouble() {
  final double low = 12.3;
  final double mid = 12.3 + 1;
  final double high = 12.3 + 2;
  assertEquals(low, NumberUtils.min(low, mid, high), 0.0001);
  assertEquals(low, NumberUtils.min(mid, low, high), 0.0001);
  assertEquals(low, NumberUtils.min(mid, high, low), 0.0001);
  assertEquals(low, NumberUtils.min(low, mid, low), 0.0001);
  assertEquals(mid, NumberUtils.min(high, mid, high), 0.0001);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinimumFloat() {
  final float low = 12.3f;
  final float mid = 12.3f + 1;
  final float high = 12.3f + 2;
  assertEquals(low, NumberUtils.min(low, mid, high), 0.0001f);
  assertEquals(low, NumberUtils.min(mid, low, high), 0.0001f);
  assertEquals(low, NumberUtils.min(mid, high, low), 0.0001f);
  assertEquals(low, NumberUtils.min(low, mid, low), 0.0001f);
  assertEquals(mid, NumberUtils.min(high, mid, high), 0.0001f);
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinimumShort() {
  final short low = 1234;
  final short mid = 1234 + 1;
  final short high = 1234 + 2;
  assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(low, mid, high));
  assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, low, high));
  assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(mid, high, low));
  assertEquals("minimum(short,short,short) 1 failed", low, NumberUtils.min(low, mid, low));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinInt() {
  assertEquals(
    "min(int[]) failed for array length 1",
    5,
    NumberUtils.min(5));
  assertEquals(
    "min(int[]) failed for array length 2",
    6,
    NumberUtils.min(6, 9));
  assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10));
  assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinShort() {
  assertEquals(
    "min(short[]) failed for array length 1",
    5,
    NumberUtils.min(new short[] { 5 }));
  assertEquals(
    "min(short[]) failed for array length 2",
    6,
    NumberUtils.min(new short[] { 6, 9 }));
  assertEquals(-10, NumberUtils.min(new short[] { -10, -5, 0, 5, 10 }));
  assertEquals(-10, NumberUtils.min(new short[] { -5, 0, -10, 5, 10 }));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testMinByte() {
  assertEquals(
    "min(byte[]) failed for array length 1",
    5,
    NumberUtils.min(new byte[] { 5 }));
  assertEquals(
    "min(byte[]) failed for array length 2",
    6,
    NumberUtils.min(new byte[] { 6, 9 }));
  assertEquals(-10, NumberUtils.min(new byte[] { -10, -5, 0, 5, 10 }));
  assertEquals(-10, NumberUtils.min(new byte[] { -5, 0, -10, 5, 10 }));
}

相关文章