001/*
002 * Units of Measurement TCK
003 * Copyright © 2005-2019, 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.SPEC_ID;
033import static tech.units.tck.TCKRunner.SPEC_VERSION;
034import org.jboss.test.audit.annotations.SpecAssertion;
035import org.jboss.test.audit.annotations.SpecVersion;
036import org.testng.annotations.Test;
037
038import tech.units.tck.TCKSetup;
039import tech.units.tck.util.TestUtils;
040
041/**
042 * Tests for Unit Conversion
043 *
044 * @author Werner Keil
045 * @version 1.2, July 7, 2019
046 * @since 2.0
047 */
048@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION)
049public class PrefixInterfaceTest {
050    private static final String SECTION = "4.2.4";
051    
052    /**
053     * Test that Dimension implementations override equals.
054     */
055    @SuppressWarnings("deprecation")
056        @SpecAssertion(section = SECTION, id = "424-A1")
057    @Test(groups = {"core"}, description = SECTION + " Ensure supported Prefix classes override equals.")
058    public void testEquals() {
059        for (@SuppressWarnings("rawtypes")
060        Class type : TCKSetup.getConfiguration().getPrefixClasses()) {
061            TestUtils.testHasPublicMethod("Section "+ SECTION, type, boolean.class, "equals", Object.class);
062        }
063    }
064
065    /**
066     * Test that Dimension implementations override hashCode.
067     */
068    @SuppressWarnings("deprecation")
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 "+ 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    @SuppressWarnings("deprecation")
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            TestUtils.testHasPublicMethod("Section "+ SECTION, type, Number.class, "getValue");
112        }
113    }
114    
115    /**
116     * Test that Prefix implementations override getExponent.
117     */
118    @SuppressWarnings("deprecation")
119        @SpecAssertion(section = SECTION, id = "424-A6")
120    @Test(groups = {"core"}, description = SECTION + " Ensure supported Prefix implementations override getExponent.")
121    public void testGetXponent() {
122        for (@SuppressWarnings("rawtypes")
123        Class type : TCKSetup.getConfiguration().getPrefixClasses()) {
124            TestUtils.testHasPublicMethod("Section "+ SECTION, type, int.class, "getExponent");
125        }
126    }
127}