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
|
#!/usr/local/bin/python
#
# File: orderingtest
# Copyright: (c) 2002 The Regents of the University of California
# Revision: @(#) $Revision: 4434 $
# Date: $Date: 2005-03-17 09:05:29 -0800 (Thu, 17 Mar 2005) $
# Description: Exercise array ordering code
#
# Try to exercise everything possible in Python.
from Ordering.IntOrderTest import *
from Numeric import *
from synch.ResultType import *
from synch import RegOut
class TestCounter:
def __init__(self, numparts = -1):
self.partno = 0
self.tracker = RegOut.RegOut()
self.tracker.setExpectations(numparts)
def describeTest(self, description):
self.partno = self.partno + 1
self.tracker.startPart(self.partno)
self.tracker.writeComment(description)
def evalTest(self, res, expected):
if (res):
if (expected):
self.tracker.endPart(self.partno, PASS)
else:
self.tracker.endPart(self.partno, XPASS)
else:
if (expected):
self.tracker.endPart(self.partno, FAIL)
else:
self.tracker.endPart(part.partno, XFAIL)
def finish(self):
self.tracker.close()
if __name__ == '__main__':
counter = TestCounter()
A = makeColumnIMatrix(10, 1)
counter.describeTest("makeColumnIMatrix(10,1) != None")
counter.evalTest(A, 1)
counter.describeTest("isIMatrixTwo(A)")
counter.evalTest(isIMatrixTwo(A), 1)
counter.describeTest("isColumnIMatrixTwo(A)")
counter.evalTest(isColumnIMatrixTwo(A), 1)
counter.describeTest("isRowIMatrixTwo(A)")
counter.evalTest(isRowIMatrixTwo(A), 1)
counter.describeTest("A = ensureRow(A) then isIMatrixTwo(A)")
A = ensureRow(A)
counter.evalTest(isIMatrixTwo(A), 1)
counter.describeTest("A = ensureColumn(A) then isIMatrixTwo(A)")
A = ensureColumn(A)
counter.evalTest(isIMatrixTwo(A), 1)
A = None
A = makeRowIMatrix(10, 0)
counter.describeTest("A != None and isIMatrixTwo(A)")
counter.evalTest(A and isIMatrixTwo(A), 1)
counter.describeTest("A != None and isColumnIMatrixTwo(A)")
counter.evalTest(A and isColumnIMatrixTwo(A), 1)
A = None
A = makeRowIMatrix(10, 1)
counter.describeTest("A != None and isIMatrixTwo(A)")
counter.evalTest(A and isIMatrixTwo(A), 1)
A = None
A = createColumnIMatrix(10, 1)
counter.describeTest("A = createColumnIMatrix -> A != None")
counter.evalTest(A and isIMatrixTwo(A), 1)
A = None
A = makeIMatrix(4, 1)
counter.describeTest("A != None and isIMatrixFour(A)")
counter.evalTest(A and isIMatrixFour(A), 1)
A = None
counter.describeTest("isSliceWorking(1)")
counter.evalTest(isSliceWorking(1), 1)
counter.describeTest("isSliceWorking(0)")
counter.evalTest(isSliceWorking(0), 1)
counter.finish()
0
|