From: Luke Kenneth Casson Leighton Date: Fri, 15 Dec 2023 23:28:53 +0000 (+0000) Subject: bug 676: put maxloc.py test data into array X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7eb42ae5ed70407f67908f3eaa3b9b7aafc4850e;p=openpower-isa.git bug 676: put maxloc.py test data into array --- diff --git a/src/openpower/decoder/isa/maxloc.py b/src/openpower/decoder/isa/maxloc.py index 345dd11c..83d89569 100644 --- a/src/openpower/decoder/isa/maxloc.py +++ b/src/openpower/decoder/isa/maxloc.py @@ -22,27 +22,16 @@ def m2(a): # /*Testbench*/ -if __name__ == '__main__': - arr = [5,2,8,1,3,7,9,4] - print("search list", arr) - result = m2(arr) - print("Index of the maximum value in an array is: %d" % result) - assert (result == 6) - - arr = [5,2,8,9,9,7,9,4] - print("search list", arr) - result = m2(arr) - print("Index of the maximum value in an array is: %d" % result) - assert (result == 3) +test_data = [ + ([5,2,8,1,3,7,9,4], 6), + ([5,2,8,9,9,7,9,4], 3), + ([0,0,0,0,0,0,0,0], 0), + ([5,5,5,5,5,5,5,5], 0), +] - arr = [0,0,0,0,0,0,0,0] - print("search list", arr) - result = m2(arr) - print("Index of the maximum value in an array is: %d" % result) - assert (result == 0) - - arr = [5,5,5,5,5,5,5,5] - print("search list", arr) - result = m2(arr) - print("Index of the maximum value in an array is: %d" % result) - assert (result == 0) +if __name__ == '__main__': + for arr, expected in test_data: + print("search list", arr) + result = m2(arr) + print("Index of the maximum value in an array is: %d" % result) + assert (result == expected)