Browse files

Nicer error reporting

  • Loading branch information...
1 parent 1800d8e commit ffd5a10ba907373bcbc6e48c5554d30cbabec238 @samstokes samstokes committed May 23, 2012
View
3 src/main/java/com/rapportive/jawbone/JawboneBinding.java
@@ -22,4 +22,7 @@
int wbxml_conv_wbxml2xml_run(Pointer conv, byte[] wbxml, long wbxmlLength, PointerByReference xmlPtr, LongByReference xmlLength);
void wbxml_conv_wbxml2xml_destroy(Pointer conv);
+
+
+ String wbxml_errors_string(int ret);
}
View
8 src/test/java/com/rapportive/jawbone/JawboneTest.java
@@ -50,7 +50,7 @@ public void testWbxmlToXml() throws Exception {
LongByReference xmlLength = new LongByReference();
ret = binding.wbxml_conv_wbxml2xml_run(conv, wbxml, wbxml.length, xmlPtr, xmlLength);
- assertEquals("wbxml_conv_wbxml2xml_run failed", 0, ret);
+ assertSuccess("wbxml_conv_wbxml2xml_run", ret);
assertTrue("returned no XML", xmlLength.getValue() > 0);
byte[] xmlBytes = xmlPtr.getValue().getByteArray(0L, (int) xmlLength.getValue());
@@ -65,6 +65,12 @@ public void testWbxmlToXml() throws Exception {
}
+ private void assertSuccess(String function, int ret) {
+ if (ret != 0) {
+ fail(function + ": " + binding.wbxml_errors_string(ret));
+ }
+ }
+
private static String testResource(String path) {
String testResourcesDir = System.getProperty("test.resources");
if (testResourcesDir == null) {

0 comments on commit ffd5a10

Please sign in to comment.