SF3065265 Bit masking in Variant.getXXXRef() uses wrong mask allowing more than one type to be seen as the requested type. Code that passed in the correct type always worked but invalid types were not always detected.

This commit is contained in:
clay_shooter
2010-11-08 02:48:55 +00:00
parent 657e5980d9
commit 742c8dcd1b
4 changed files with 73 additions and 26 deletions

View File

@@ -648,6 +648,7 @@ public class VariantTest extends BaseTestCase {
*
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
for (int variantIndex = 0; variantIndex < initialRunSize; variantIndex++) {
try {
@@ -664,4 +665,40 @@ public class VariantTest extends BaseTestCase {
isComplete = true;
}
}
/**
* there was a bitwise masking error that let booleans be seen as dispatch
* objects Bug Report SF3065265
*/
public void testGetDispatch() {
Variant testVariant = new Variant();
testVariant.putBooleanRef(true);
try {
// throws IllegalStateException if Jacob detects the type
// throws some other bad exception if COM blows up failing the
// conversion
testVariant.getDispatchRef();
fail("Should not have converted boolean to dispatch");
} catch (IllegalStateException e) {
// yeah! can't get dispatch from boolean
}
}
/**
* there was a bitwise masking error that let booleans be seen as dispatch
* objects Bug Report SF3065265
*/
public void testGetError() {
Variant testVariant = new Variant();
testVariant.putErrorRef(3);
try {
// throws IllegalStateException if Jacob detects the type
// throws some other bad exception if COM blows up failing the
// conversion
testVariant.getStringRef();
fail("Should not have converted error to string");
} catch (IllegalStateException e) {
// yeah! can't get dispatch from boolean
}
}
}