Search in sources :

Example 86 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method iteratorAsReturnType_mix_severalIterators.

@org.junit.Test
public void iteratorAsReturnType_mix_severalIterators() {
    final List<Integer> is = new ArrayList<Integer>();
    final List<Integer> js = new ArrayList<Integer>();
    final List<String> strings = new ArrayList<String>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Iterator<Object[]> mixIterator = Arrays.<Object[]>asList(new Object[] { 89898, 176253, "123" }, new Object[] { 34324, 343424, "345" }).iterator();

        Iterator<Integer> iter_1 = Arrays.asList(89898, 34324).iterator();

        Iterator<Integer> iter_2 = Arrays.asList(176253, 343424).iterator();

        Iterator<String> iter_3 = Arrays.asList("123", "345").iterator();

        @TestCase
        public void test(@TestData("iter_1") int i, @TestData("iter_2") int j, @TestData("iter_3") String s) throws Throwable {
            is.add(i);
            js.add(j);
            strings.add(s);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(2, is.size());
    Assert.assertEquals(2, js.size());
    Assert.assertEquals(2, strings.size());
    Assert.assertEquals(89898, (int) is.get(0));
    Assert.assertEquals(176253, (int) js.get(0));
    Assert.assertEquals("123", strings.get(0));
    Assert.assertEquals(34324, (int) is.get(1));
    Assert.assertEquals(343424, (int) js.get(1));
    Assert.assertEquals("345", strings.get(1));
}
Also used : ArrayList(java.util.ArrayList) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 87 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method iteratorAsReturnType_strings.

@org.junit.Test
public void iteratorAsReturnType_strings() {
    final List<String> is = new ArrayList<String>();
    final List<String> js = new ArrayList<String>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Iterator<Object[]> stringITerator = Arrays.<Object[]>asList(new String[] { "a", "b" }, new String[] { "v", "n" }).iterator();

        @TestCase
        @TestData("stringITerator")
        public void test(String i, String j) throws Throwable {
            is.add(i);
            js.add(j);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(2, is.size());
    Assert.assertEquals(2, js.size());
    Assert.assertEquals("a", is.get(0));
    Assert.assertEquals("b", js.get(0));
    Assert.assertEquals("v", is.get(1));
    Assert.assertEquals("n", js.get(1));
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) ArrayList(java.util.ArrayList) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestCase(com.sun.tck.test.TestCase) Test(org.junit.Test)

Example 88 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method iteratorAsReturnType_String_2.

@org.junit.Test
public void iteratorAsReturnType_String_2() {
    final List<String> passed = new ArrayList<>();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

        Iterator<String> strings = Arrays.asList("a", "bb", "cc").iterator();

        @TestCase
        public void test(@TestData("strings") String s) throws Throwable {
            passed.add(s);
        }
    }, TU.EMPTY_ARGV);
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(3, passed.size());
    Assert.assertEquals(passed.get(0), "a");
    Assert.assertEquals(passed.get(1), "bb");
    Assert.assertEquals(passed.get(2), "cc");
}
Also used : TestCase(com.sun.tck.test.TestCase) ArrayList(java.util.ArrayList) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Test(org.junit.Test)

Example 89 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method test_04_IteratorOfIntegers.

@Test
public void test_04_IteratorOfIntegers() {
    @TestGroup
    class Test {

        Iterator<Integer> component() {
            return IntStream.range(55, 67).iterator();
        }

        int counter;

        @TestCase
        @Operation(MULTIPLY)
        public void test(@TestData("component") int r, @TestData("component") int g, @TestData("component") int b) {
            Color color = new Color(r, g, b);
            assertEquals(r, color.getRed());
            assertEquals(g, color.getGreen());
            assertEquals(b, color.getBlue());
            counter++;
        }
    }
    Test tg = new Test();
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(tg);
    Assert.assertTrue(s.isOK());
    Assert.assertEquals(1728, tg.counter);
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Test(org.junit.Test) Color(java.awt.Color) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestGroup(com.sun.tck.test.TestGroup) Test(org.junit.Test)

Example 90 with com.oracle.tck.lib.autd2

use of com.oracle.tck.lib.autd2 in project jtharness by openjdk.

the class ReferenceAttachedToParam method mixed_mult_3.

@org.junit.Test
public void mixed_mult_3() {
    final List<Class<?>> list_1 = new ArrayList<Class<?>>();
    final List<String> list_2 = new ArrayList<String>();
    com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(new BaseTestGroup() {

        private Values classes_ = DataFactory.createColumn(String.class, Throwable.class);

        @TestCase
        @Operation(Operation.TYPE.MULTIPLY)
        public void test(@TestData("classes_") Class<?> c, @Strings({ "x", "y", "z" }) String s) throws Throwable {
            list_1.add(c);
            list_2.add(s);
        }
    });
    Assert.assertTrue(status.isOK());
    Assert.assertEquals(6, list_1.size());
    Assert.assertEquals(6, list_2.size());
    Assert.assertEquals(String.class, list_1.get(0));
    Assert.assertEquals(String.class, list_1.get(1));
    Assert.assertEquals(String.class, list_1.get(2));
    Assert.assertEquals(Throwable.class, list_1.get(3));
    Assert.assertEquals(Throwable.class, list_1.get(4));
    Assert.assertEquals(Throwable.class, list_1.get(5));
    Assert.assertEquals("x", list_2.get(0));
    Assert.assertEquals("y", list_2.get(1));
    Assert.assertEquals("z", list_2.get(2));
    Assert.assertEquals("x", list_2.get(3));
    Assert.assertEquals("y", list_2.get(4));
    Assert.assertEquals("z", list_2.get(5));
}
Also used : ArrayList(java.util.ArrayList) Values(com.sun.tck.lib.tgf.Values) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) Operation(com.sun.tck.lib.tgf.data.Operation) TestCase(com.sun.tck.test.TestCase)

Aggregations

TestCase (com.sun.tck.test.TestCase)139 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)135 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)73 TestData (com.sun.tck.lib.tgf.TestData)61 TestResult (com.oracle.tck.lib.autd2.TestResult)52 Values (com.sun.tck.lib.tgf.Values)50 TestGroup (com.sun.tck.test.TestGroup)30 HashSet (java.util.HashSet)13 DataFactory.createValues (com.sun.tck.lib.tgf.DataFactory.createValues)12 NonTestCase (com.oracle.tck.lib.autd2.NonTestCase)11 Operation (com.sun.tck.lib.tgf.data.Operation)10 TestObject (com.oracle.tck.lib.autd2.unittests.TestObject)8 Color (java.awt.Color)7 List (java.util.List)5 DataFactory (com.sun.tck.lib.tgf.DataFactory)4 DataFactory.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)3 DataFactory.createRow (com.sun.tck.lib.tgf.DataFactory.createRow)3 PrintWriter (java.io.PrintWriter)3 java.util (java.util)3