Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: crosstest/test_arith_main.cpp

Issue 404553007: Fix array index in test initialization. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Push Values and NumValues to testsInt() and testsVecInt(). Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/test_arith_main.cpp
diff --git a/crosstest/test_arith_main.cpp b/crosstest/test_arith_main.cpp
index d9bbbe9c7490e1a725412dc40946a9de94e9923d..1c67b6bd61cecc1764da6d9cda6c7519c7bd2e73 100644
--- a/crosstest/test_arith_main.cpp
+++ b/crosstest/test_arith_main.cpp
@@ -19,9 +19,6 @@ namespace Subzero_ {
#include "test_arith.h"
}
-volatile unsigned Values[] = INT_VALUE_ARRAY;
-const static size_t NumValues = sizeof(Values) / sizeof(*Values);
-
template <class T> bool inputsMayTriggerException(T Value1, T Value2) {
// Avoid HW divide-by-zero exception.
if (Value2 == 0)
@@ -37,6 +34,8 @@ template <typename TypeUnsigned, typename TypeSigned>
void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned);
+ volatile unsigned Values[] = INT_VALUE_ARRAY;
+ const static size_t NumValues = sizeof(Values) / sizeof(*Values);
static struct {
const char *Name;
FuncTypeUnsigned FuncLlc;
@@ -160,6 +159,8 @@ template <typename TypeUnsigned, typename TypeSigned,
void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned);
+ volatile unsigned Values[] = INT_VALUE_ARRAY;
+ const static size_t NumValues = sizeof(Values) / sizeof(*Values);
static struct {
const char *Name;
FuncTypeUnsigned FuncLlc;
@@ -192,8 +193,8 @@ void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
// Initialize the test vectors.
TypeUnsigned Value1, Value2;
for (size_t j = 0; j < NumElementsInType;) {
- ElementTypeUnsigned Element1 = Values[Index() % NumElementsInType];
- ElementTypeUnsigned Element2 = Values[Index() % NumElementsInType];
+ ElementTypeUnsigned Element1 = Values[Index() % NumValues];
+ ElementTypeUnsigned Element2 = Values[Index() % NumValues];
if (Funcs[f].ExcludeDivExceptions &&
inputsMayTriggerException<ElementTypeSigned>(Element1, Element2))
continue;
@@ -310,8 +311,8 @@ void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
// Initialize the test vectors.
v4f32 Value1, Value2;
for (size_t j = 0; j < NumElementsInType; ++j) {
- Value1[j] = Values[Index() % NumElementsInType];
- Value2[j] = Values[Index() % NumElementsInType];
+ Value1[j] = Values[Index() % NumValues];
+ Value2[j] = Values[Index() % NumValues];
}
// Perform the test.
v4f32 ResultSz = Funcs[f].FuncSz(Value1, Value2);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698