Skip to content

Commit

Permalink
117 NullPointerException injacob-1.17-M2
Browse files Browse the repository at this point in the history
  • Loading branch information
clay_shooter committed Jul 26, 2013
1 parent eeefefd commit 01299f3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
2 changes: 2 additions & 0 deletions jacob/docs/BuildingJacobFromSource.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ <H1>Development Environment</h1>
<H1>Build Process</H1>
The build process is based on ANT.
You can run ANT from inside of eclipse or from the command line.
Running from inside eclipse means you don't have any installation, pathing or configuration to do.
You can just open the xml and then "run as ant" on the selected target in the "outline" pane.
The ant process is driven off of a configuration file named
<code>compilation_tools.properties</code> that describes the locations of the JDK and Microsoft
C++ tools. The <code>build.xml</code> file in the root directory contains examples of the contents
Expand Down
4 changes: 4 additions & 0 deletions jacob/docs/ReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ <h3>Tracked Changes</h3>
<td width="13%" valign="top">111 (new numbers)</td>
<td width="87%" valign="top">(M3)m_pDispatch is not 0 if not attached</td>
</tr>
<tr>
<td width="13%" valign="top">117 (new numbers)</td>
<td width="87%" valign="top">(M4) NullPointerException injacob-1.17-M2</td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
Expand Down
8 changes: 7 additions & 1 deletion jacob/src/com/jacob/com/Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,8 @@ public short toShort() {
* <li>"null" if VariantEmpty,
* <li>"null" if VariantError
* <li>"null" if VariantNull
* <li>"null" if Variant type didn't convert. This can happen for date
* conversions where the returned value was 0.
* <li>the value if we know how to describe one of that type
* <li>three question marks if can't convert
*
Expand All @@ -2186,7 +2188,11 @@ public String toString() {
try {
Object foo = toJavaObject();
// rely on java objects to do the right thing
return foo.toString();
if (foo == null) {
return "null";
} else {
return foo.toString();
}
} catch (NotImplementedException nie) {
// some types do not generate a good description yet
return "Description not available for type: " + getvt();
Expand Down
48 changes: 38 additions & 10 deletions jacob/unittest/com/jacob/com/VariantTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,32 @@ public void testToStringDoesNotConvert() {
}
}

/**
* Exercise ToString special cases
*/
public void testToStringEmptyValues() {
Variant v;
// create an empty variant
v = new Variant();
// check date per
v.changeType(Variant.VariantDate);
assertEquals("null", v.toString());
v.putDate(new Date());
assertNotNull(v.toString());
assertFalse("null".equals(v.toString()));

v.changeType(Variant.VariantInt);
v.putInt(1);

assertEquals("1", v.toString());
v.changeType(Variant.VariantEmpty);
assertEquals("null", v.toString());
v.changeType(Variant.VariantNull);
assertEquals("null", v.toString());
v.changeType(Variant.VariantError);
assertEquals("null", v.toString());
}

/**
* Verify that booleans can be released. Part of the suite that checks all
* types.
Expand Down Expand Up @@ -465,12 +491,12 @@ public void testDecimalConversion() {
new BigDecimal(i), v.getDecimal());
v.changeType(Variant.VariantFloat);
// now see if a float conversion would work
assertEquals("conversion to float failed " + i, new Float(i), v
.getFloat());
assertEquals("conversion to float failed " + i, new Float(i),
v.getFloat());
// now convert it back to decimal for reassignment
v.changeType(Variant.VariantDecimal);
assertTrue("Failed conversion of type back to Decimal " + i, v
.getvt() == Variant.VariantDecimal);
assertTrue("Failed conversion of type back to Decimal " + i,
v.getvt() == Variant.VariantDecimal);
}

}
Expand Down Expand Up @@ -545,9 +571,10 @@ public void testLargeDecimals() {
.unscaledValue().toString(16) + " scale=: "
+ modifiedDecimal.scale());
System.out.println("integer piece after rounding with scale 30 is "
+ VariantUtilities.roundToMSDecimal(
modifiedDecimal.setScale(30)).unscaledValue().toString(
16) + " scale=: " + modifiedDecimal.scale());
+ VariantUtilities
.roundToMSDecimal(modifiedDecimal.setScale(30))
.unscaledValue().toString(16) + " scale=: "
+ modifiedDecimal.scale());
try {
testVariant.putDecimal(VariantUtilities
.roundToMSDecimal(modifiedDecimal.setScale(30)));
Expand All @@ -568,9 +595,10 @@ public void testLargeDecimals() {
.unscaledValue().toString(16) + " scale=: "
+ modifiedDecimal.scale());
System.out.println("integer piece after rounding with scale 30 is "
+ VariantUtilities.roundToMSDecimal(
modifiedDecimal.setScale(30)).unscaledValue().toString(
16) + " scale=: " + modifiedDecimal.scale());
+ VariantUtilities
.roundToMSDecimal(modifiedDecimal.setScale(30))
.unscaledValue().toString(16) + " scale=: "
+ modifiedDecimal.scale());
testVariant.putDecimal(VariantUtilities
.roundToMSDecimal(modifiedDecimal.setScale(30)));
System.out.println("");
Expand Down

0 comments on commit 01299f3

Please sign in to comment.