001/* 002 * Units of Measurement TCK 003 * Copyright © 2005-2020, Jean-Marie Dautelle, Werner Keil, Otavio Santana. 004 * 005 * All rights reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without modification, 008 * are permitted provided that the following conditions are met: 009 * 010 * 1. Redistributions of source code must retain the above copyright notice, 011 * this list of conditions and the following disclaimer. 012 * 013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 014 * and the following disclaimer in the documentation and/or other materials provided with the distribution. 015 * 016 * 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products 017 * derived from this software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030package tech.units.tck.tests.unit; 031 032import static tech.units.tck.TCKRunner.SECTION_PREFIX; 033import static tech.units.tck.TCKRunner.SPEC_ID; 034import static tech.units.tck.TCKRunner.SPEC_VERSION; 035import static tech.units.tck.util.TestGroups.CORE; 036import org.jboss.test.audit.annotations.SpecAssertion; 037import org.jboss.test.audit.annotations.SpecVersion; 038import org.testng.annotations.Test; 039 040import tech.units.tck.TCKSetup; 041import tech.units.tck.util.TestUtils; 042 043/** 044 * Tests for Unit Conversion 045 * 046 * @author Werner Keil 047 * @version 2.0, November 15, 2020 048 * @since 2.0 049 */ 050@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION) 051public class PrefixInterfaceTest { 052 private static final String SECTION = "4.2.4"; 053 054 /** 055 * Test that Dimension implementations override equals. 056 */ 057 @SpecAssertion(section = SECTION, id = "424-A1") 058 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix classes override equals.") 059 public void testEquals() { 060 for (@SuppressWarnings("rawtypes") 061 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 062 TestUtils.testHasPublicMethod(SECTION_PREFIX + SECTION, type, boolean.class, "equals", Object.class); 063 } 064 } 065 066 /** 067 * Test that Dimension implementations override hashCode. 068 */ 069 @SpecAssertion(section = SECTION, id = "424-A2") 070 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix classes override hashCode.") 071 public void testHashcode() { 072 for (@SuppressWarnings("rawtypes") 073 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 074 TestUtils.testHasPublicMethod(SECTION_PREFIX + SECTION, type, int.class, "hashCode"); 075 } 076 } 077 078 /** 079 * Test that Prefix implementations override getName. 080 */ 081 @SpecAssertion(section = SECTION, id = "424-A3") 082 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getName.") 083 public void testGetName() { 084 for (@SuppressWarnings("rawtypes") 085 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 086 TestUtils.testHasPublicMethod("Section " + SECTION, type, "getName", true); 087 } 088 } 089 090 /** 091 * Test that Prefix implementations override getSymbol. 092 */ 093 @SpecAssertion(section = SECTION, id = "424-A4") 094 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getSymbol.") 095 public void testGetSymbol() { 096 for (@SuppressWarnings("rawtypes") 097 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 098 TestUtils.testHasPublicMethod("Section " + SECTION, type, "getSymbol", true); 099 } 100 } 101 102 /** 103 * Test that Prefix implementations override getValue. 104 */ 105 @SpecAssertion(section = SECTION, id = "424-A5") 106 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getValue.") 107 public void testGetValue() { 108 for (@SuppressWarnings("rawtypes") 109 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 110 TestUtils.testHasPublicMethod(SECTION_PREFIX + SECTION, type, Number.class, "getValue"); 111 } 112 } 113 114 /** 115 * Test that Prefix implementations override getExponent. 116 */ 117 @SpecAssertion(section = SECTION, id = "424-A6") 118 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getExponent.") 119 public void testGetXponent() { 120 for (@SuppressWarnings("rawtypes") 121 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 122 TestUtils.testHasPublicMethod(SECTION_PREFIX + SECTION, type, int.class, "getExponent"); 123 } 124 } 125}