1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
//
// File: StringTest.java
// Copyright: (c) 2001 The Regents of the University of California
// Revision: @(#) $Revision: 4434 $
// Date: $Date: 2005-03-17 09:05:29 -0800 (Thu, 17 Mar 2005) $
// Description: string regression test case for Java calling other languages
//
/**
* The following class runs the string regression test cases for Java.
*/
public class StringTest {
private final static String[] s_results = {
"FAIL",
"XFAIL",
"synch.ResultType.PASS",
"Xsynch.ResultType.PASS",
"UNSUPPORTED"
};
private static int s_part = 0;
private static int s_result = synch.ResultType.PASS;
private static synch.RegOut tracker;
/**
* Check the results of the test case.
*/
//Comments should really be passed in here.
private static void startTest(String test) {
tracker.startPart(++s_part);
if(test != null)
tracker.writeComment(test);
}
private static void check(int expected, boolean pass, String test ) {
if (test != null)
tracker.writeComment(test);
if(expected == synch.ResultType.PASS)
if(pass)
tracker.endPart(s_part, synch.ResultType.PASS);
else
tracker.endPart(s_part, synch.ResultType.FAIL);
else if (expected == synch.ResultType.XFAIL)
if(pass)
tracker.endPart(s_part, synch.ResultType.XPASS);
else
tracker.endPart(s_part, synch.ResultType.XFAIL);
else
tracker.endPart(s_part, synch.ResultType.FAIL);
}
/**
* The main test driver takes no command-line arguments and runs the
* regression tests.
*/
public static void main(String args[]) {
try {
/*
* Begin the test
*/
tracker = new synch.RegOut();
tracker.setExpectations(-1);
s_part = 0;
s_result = synch.ResultType.PASS;
/*
* Run the string tests
*/
String in = "Three";
sidl.String.Holder out = new sidl.String.Holder();
sidl.String.Holder inout = new sidl.String.Holder("Three");
String rbr = null;
Strings.Cstring obj = new Strings.Cstring();
startTest(null);
check(synch.ResultType.PASS,
(obj.returnback(true).equals("Three")),
"(obj.returnback(true).equals(\"Three\"))");
rbr = obj.returnback(false);
startTest(null);
check(synch.ResultType.PASS,
((rbr == null) || rbr.equals("")),
"(obj.returnback(false) == null)");
startTest(null);
check(synch.ResultType.PASS,
(obj.passin(in) == true),
"(obj.passin(in) == true)");
startTest(null);
check(synch.ResultType.PASS,
(obj.passin(null) == false),
"(obj.passin(null) == false)");
startTest(null);
check(synch.ResultType.PASS,
(obj.passout(true,out) == true && out.get().equals("Three")),
"(obj.passout(true,out) == true && out.get().equals(\"Three\"))");
startTest(null);
check(synch.ResultType.PASS,
(obj.passinout(inout) == true && inout.get().equals("threes")),
"(obj.passinout(inout) == true && inout.get().equals(\"threes\"))");
startTest(null);
check(synch.ResultType.PASS,
(obj.passeverywhere(in , out, inout).equals("Three")
&& out.get().equals("Three")
&& inout.get().equals("Three")),
"(obj.passeverywhere(in, out, inout).equals(\"Three\")"
+ " && out.get().equals(\"Three\")"
+ " && inout.get().equals(\"Three\"))");
startTest(null);
check(synch.ResultType.PASS,
(obj.mixedarguments("Test", 'z', "Test", 'z')),
"(obj.mixedarguments(\"Test\", 'z', \"Test\", 'z'))");
startTest(null);
check(synch.ResultType.PASS,
(!obj.mixedarguments("Not", 'A', "Equal", 'a')),
"(!obj.mixedarguments(\"Not\", 'A', \"Equal\", 'a'))");
/*
* Output final test results
*/
tracker.close();
//System.out.println("TEST_RESULT " + s_results[s_result]);
Runtime.getRuntime().exit(0); /* workaround for Linux JVM 1.3.1 bug */
/*
* Catch any unexpected exceptions and return a test failure
*/
} catch (Throwable ex) {
tracker.close();
//System.out.println("TEST_RESULT FAIL");
System.out.println(ex.toString());
System.exit(1);
}
}
}
|