From 7eb42ae5ed70407f67908f3eaa3b9b7aafc4850e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 15 Dec 2023 23:28:53 +0000 Subject: [PATCH] bug 676: put maxloc.py test data into array --- src/openpower/decoder/isa/maxloc.py | 35 ++++++++++------------------- 1 file changed, 12 insertions(+), 23 deletions(-) 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) -- 2.30.2