Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value Types: Add arraycopy unit test for value types #20753

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,36 @@ static private void testOBJOBJ(Object[] src, Object[] dst) {
System.arraycopy(src, 0, dst, 0, ARRAY_SIZE);
}

static private SomeValueClass[] testVTVTReturnVT(SomeValueClass[] src) {
SomeValueClass[] dst = (SomeValueClass[])ValueClass.newNullRestrictedArray(SomeValueClass.class, ARRAY_SIZE);
System.arraycopy(src, 0, dst, 0, ARRAY_SIZE);
return dst;
}

static private SomeInterface[] testVTIFReturnIF(SomeValueClass[] src) {
SomeInterface[] dst = (SomeValueClass[])ValueClass.newNullRestrictedArray(SomeValueClass.class, ARRAY_SIZE);
System.arraycopy(src, 0, dst, 0, ARRAY_SIZE);
return dst;
}

static private SomeValueClass[] testIFVTReturnVT(SomeInterface[] src) {
SomeValueClass[] dst = (SomeValueClass[])ValueClass.newNullRestrictedArray(SomeValueClass.class, ARRAY_SIZE);
System.arraycopy(src, 0, dst, 0, ARRAY_SIZE);
return dst;
}

static private Object[] testVTOBJReturnOBJ(SomeValueClass[] src) {
Object[] dst = (SomeValueClass[])ValueClass.newNullRestrictedArray(SomeValueClass.class, ARRAY_SIZE);
System.arraycopy(src, 0, dst, 0, ARRAY_SIZE);
return dst;
}

static private SomeValueClass[] testOBJVTReturnVT(Object[] src) {
SomeValueClass[] dst = (SomeValueClass[])ValueClass.newNullRestrictedArray(SomeValueClass.class, ARRAY_SIZE);
System.arraycopy(src, 0, dst, 0, ARRAY_SIZE);
return dst;
}

@Test(priority=1)
static public void testSystemArrayCopy1() throws Throwable {

Expand Down Expand Up @@ -785,4 +815,82 @@ static public void testSystemArrayCopy29() throws Throwable {
testVTVT(vtArraySrc, nullRestrictedVtArrayDst);
checkResults(vtArraySrc, nullRestrictedVtArrayDst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy30() throws Throwable {
initArrays();
SomeValueClass[] dst = testVTVTReturnVT(vtArraySrc);
checkResults(vtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy31() throws Throwable {
initArrays();
SomeValueClass[] dst = testVTVTReturnVT(nullRestrictedVtArraySrc);
checkResults(nullRestrictedVtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy32() throws Throwable {
initArrays();
SomeInterface[] dst = testVTIFReturnIF(vtArraySrc);
checkResults(vtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy33() throws Throwable {
initArrays();
SomeInterface[] dst = testVTIFReturnIF(nullRestrictedVtArraySrc);
checkResults(nullRestrictedVtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy34() throws Throwable {
initArrays();
SomeValueClass[] dst = testIFVTReturnVT(ifVtArraySrc);
checkResults(ifVtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy35() throws Throwable {
initArrays();
SomeValueClass[] dst = testIFVTReturnVT(ifNullRestrictedVtArraySrc);
checkResults(ifNullRestrictedVtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy36() throws Throwable {
initArrays();
Object[] dst = testVTOBJReturnOBJ(vtArraySrc);
checkResults(vtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy37() throws Throwable {
initArrays();
Object[] dst = testVTOBJReturnOBJ(nullRestrictedVtArraySrc);
checkResults(nullRestrictedVtArraySrc, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy38() throws Throwable {
Object[] src = new Object[ARRAY_SIZE];
for (int i=0; i < ARRAY_SIZE; i++) {
src[i] = new SomeValueClass(i*25);
}

SomeValueClass[] dst = testOBJVTReturnVT(src);
checkResults(src, dst);
}

@Test(priority=1, invocationCount=2)
static public void testSystemArrayCopy39() throws Throwable {
Object[] src = (SomeValueClass[])ValueClass.newNullRestrictedArray(SomeValueClass.class, ARRAY_SIZE);
for (int i=0; i < ARRAY_SIZE; i++) {
src[i] = new SomeValueClass(i*25);
}

SomeValueClass[] dst = testOBJVTReturnVT(src);
checkResults(src, dst);
}
}