javax.measure.quantity.Area Java Examples
The following examples show how to use
javax.measure.quantity.Area.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnitsTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests getting a unit for a given quantity type. */ @Test public void testGetForQuantity() { assertSame("Length", Units.METRE, Units.get(Length.class)); assertSame("Mass", Units.KILOGRAM, Units.get(Mass.class)); assertSame("Time", Units.SECOND, Units.get(Time.class)); assertSame("Temperature", Units.KELVIN, Units.get(Temperature.class)); assertSame("Area", Units.SQUARE_METRE, Units.get(Area.class)); assertSame("Volume", Units.CUBIC_METRE, Units.get(Volume.class)); assertSame("Speed", Units.METRES_PER_SECOND, Units.get(Speed.class)); assertSame("LuminousIntensity", Units.CANDELA, Units.get(LuminousIntensity.class)); assertSame("LuminousFlux", Units.LUMEN, Units.get(LuminousFlux.class)); assertSame("SolidAngle", Units.STERADIAN, Units.get(SolidAngle.class)); assertSame("Angle", Units.RADIAN, Units.get(Angle.class)); assertSame("Dimensionless", Units.UNITY, Units.get(Dimensionless.class)); }
Example #2
Source File: ScalarTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests {@link Scalar#multiply(Quantity)}, {@link Scalar#divide(Quantity)} and {@link Quantity#inverse()}. * Those tests depend on proper working of {@link Quantities#create(double, Unit)}, which depends in turn on * proper declarations of {@link ScalarFactory} in {@link Units} initialization. */ @Test public void testMultiplyDivideQuantity() { final Quantity<Length> q1 = new Scalar.Length(24, Units.METRE); final Quantity<Time> q2 = new Scalar.Time ( 4, Units.SECOND); final Quantity<Speed> q3 = q1.divide(q2).asType(Speed.class); assertSame ("unit", Units.METRES_PER_SECOND, q3.getUnit()); assertEquals("value", 6, q3.getValue().doubleValue(), STRICT); assertInstanceOf("Length/Time", Scalar.Speed.class, q3); final Quantity<Area> q4 = q1.multiply(q1).asType(Area.class); assertSame ("unit", Units.SQUARE_METRE, q4.getUnit()); assertEquals("value", 576, q4.getValue().doubleValue(), STRICT); assertInstanceOf("Lengthâ‹…Length", Scalar.Area.class, q4); final Quantity<Frequency> q5 = q2.inverse().asType(Frequency.class); assertSame ("unit", Units.HERTZ, q5.getUnit()); assertEquals("value", 0.25, q5.getValue().doubleValue(), STRICT); assertInstanceOf("1/Time", Scalar.Frequency.class, q5); }
Example #3
Source File: UnitFormatTest.java From uom-systems with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testFormat6() { Unit<Area> b = CLDR.ACRE; assertEquals("ac", b.toString()); }
Example #4
Source File: WaterTankUnitTest.java From tutorials with MIT License | 4 votes |
@Test public void givenUnit_whenProduct_ThenGetProductUnit() { Unit<Area> squareMetre = METRE.multiply(METRE).asType(Area.class); Quantity<Length> line = Quantities.getQuantity(2, METRE); assertEquals(line.multiply(line).getUnit(), squareMetre); }