001/* 002 * Units of Measurement TCK 003 * Copyright © 2005-2023, 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 static tech.units.tck.util.TestUtils.testHasPublicMethod; 037 038import org.jboss.test.audit.annotations.SpecAssertion; 039import org.jboss.test.audit.annotations.SpecVersion; 040import org.testng.annotations.Test; 041 042import tech.units.tck.TCKSetup; 043 044/** 045 * Tests for Unit Conversion 046 * 047 * @author Werner Keil 048 * @version 2.2, October 4, 2023 049 * @since 2.0 050 */ 051@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION) 052public class PrefixInterfaceTest { 053 private static final String SECTION = "4.2.4"; 054 055 /** 056 * Test that Dimension implementations override equals. 057 */ 058 @SpecAssertion(section = SECTION, id = "424-A1") 059 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix classes override equals.") 060 public void testEquals() { 061 for (@SuppressWarnings("rawtypes") 062 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 063 testHasPublicMethod(SECTION_PREFIX + SECTION, type, boolean.class, "equals", Object.class); 064 } 065 } 066 067 /** 068 * Test that Dimension implementations override hashCode. 069 */ 070 @SpecAssertion(section = SECTION, id = "424-A2") 071 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix classes override hashCode.") 072 public void testHashcode() { 073 for (@SuppressWarnings("rawtypes") 074 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 075 testHasPublicMethod(SECTION_PREFIX + SECTION, type, true, int.class,"hashCode"); 076 } 077 } 078 079 /** 080 * Test that Prefix implementations override getName. 081 */ 082 @SpecAssertion(section = SECTION, id = "424-A3") 083 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getName.") 084 public void testGetName() { 085 for (@SuppressWarnings("rawtypes") 086 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 087 testHasPublicMethod("Section " + SECTION, type, "getName", true); 088 } 089 } 090 091 /** 092 * Test that Prefix implementations override getSymbol. 093 */ 094 @SpecAssertion(section = SECTION, id = "424-A4") 095 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getSymbol.") 096 public void testGetSymbol() { 097 for (@SuppressWarnings("rawtypes") 098 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 099 testHasPublicMethod("Section " + SECTION, type, "getSymbol", true); 100 } 101 } 102 103 /** 104 * Test that Prefix implementations override getValue. 105 */ 106 @SpecAssertion(section = SECTION, id = "424-A5") 107 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getValue.") 108 public void testGetValue() { 109 for (@SuppressWarnings("rawtypes") 110 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 111 testHasPublicMethod(SECTION_PREFIX + SECTION, type, Number.class, "getValue"); 112 } 113 } 114 115 /** 116 * Test that Prefix implementations override getExponent. 117 */ 118 @SpecAssertion(section = SECTION, id = "424-A6") 119 @Test(groups = { CORE }, description = SECTION + " Ensure supported Prefix implementations override getExponent.") 120 public void testGetXponent() { 121 for (@SuppressWarnings("rawtypes") 122 Class type : TCKSetup.getConfiguration().getPrefixClasses()) { 123 testHasPublicMethod(SECTION_PREFIX + SECTION, type, int.class, "getExponent"); 124 } 125 } 126}