@@ -55,8 +55,8 @@ class TestCopyWords : public ::testing::Test
55
55
protected:
56
56
void SetUp () override
57
57
{
58
- pIn = (GByte *)malloc (256 );
59
- pOut = (GByte *)malloc (256 );
58
+ pIn = (GByte *)malloc (2048 );
59
+ pOut = (GByte *)malloc (2048 );
60
60
}
61
61
62
62
void TearDown () override
@@ -74,8 +74,8 @@ class TestCopyWords : public ::testing::Test
74
74
GDALDataType outtype, ConstantType outval, ConstantType outvali,
75
75
int numLine)
76
76
{
77
- memset (pIn, 0xff , 128 );
78
- memset (pOut, 0xff , 128 );
77
+ memset (pIn, 0xff , 1024 );
78
+ memset (pOut, 0xff , 1024 );
79
79
80
80
*(InType *)(pIn) = (InType)inval;
81
81
*(InType *)(pIn + 32 ) = (InType)inval;
@@ -89,14 +89,14 @@ class TestCopyWords : public ::testing::Test
89
89
GDALCopyWords (pIn, intype, 32 , pOut, outtype, 32 , 2 );
90
90
91
91
/* Test negative offsets */
92
- GDALCopyWords (pIn + 32 , intype, -32 , pOut + 128 - 16 , outtype, -32 , 2 );
92
+ GDALCopyWords (pIn + 32 , intype, -32 , pOut + 1024 - 16 , outtype, -32 , 2 );
93
93
94
94
MY_EXPECT (intype, inval, outtype, outval, *(OutType *)(pOut));
95
95
MY_EXPECT (intype, inval, outtype, outval, *(OutType *)(pOut + 32 ));
96
96
MY_EXPECT (intype, inval, outtype, outval,
97
- *(OutType *)(pOut + 128 - 16 ));
97
+ *(OutType *)(pOut + 1024 - 16 ));
98
98
MY_EXPECT (intype, inval, outtype, outval,
99
- *(OutType *)(pOut + 128 - 16 - 32 ));
99
+ *(OutType *)(pOut + 1024 - 16 - 32 ));
100
100
101
101
if (GDALDataTypeIsComplex (outtype))
102
102
{
@@ -105,38 +105,29 @@ class TestCopyWords : public ::testing::Test
105
105
((OutType *)(pOut + 32 ))[1 ]);
106
106
107
107
MY_EXPECT (intype, invali, outtype, outvali,
108
- ((OutType *)(pOut + 128 - 16 ))[1 ]);
108
+ ((OutType *)(pOut + 1024 - 16 ))[1 ]);
109
109
MY_EXPECT (intype, invali, outtype, outvali,
110
- ((OutType *)(pOut + 128 - 16 - 32 ))[1 ]);
110
+ ((OutType *)(pOut + 1024 - 16 - 32 ))[1 ]);
111
111
}
112
112
else
113
113
{
114
- *(InType *)(pIn + GDALGetDataTypeSizeBytes (intype)) = (InType)inval;
115
- /* Test packed offsets */
116
- GDALCopyWords (pIn, intype, GDALGetDataTypeSizeBytes (intype), pOut,
117
- outtype, GDALGetDataTypeSizeBytes (outtype), 2 );
118
-
119
- MY_EXPECT (intype, inval, outtype, outval, *(OutType *)(pOut));
120
- MY_EXPECT (intype, inval, outtype, outval,
121
- *(OutType *)(pOut + GDALGetDataTypeSizeBytes (outtype)));
114
+ constexpr int N = 32 + 31 ;
115
+ for (int i = 0 ; i < N; ++i)
116
+ {
117
+ *(InType *)(pIn + i * GDALGetDataTypeSizeBytes (intype)) =
118
+ (InType)inval;
119
+ }
122
120
123
- *(InType *)(pIn + 2 * GDALGetDataTypeSizeBytes (intype)) =
124
- (InType)inval;
125
- *(InType *)(pIn + 3 * GDALGetDataTypeSizeBytes (intype)) =
126
- (InType)inval;
127
121
/* Test packed offsets */
128
122
GDALCopyWords (pIn, intype, GDALGetDataTypeSizeBytes (intype), pOut,
129
- outtype, GDALGetDataTypeSizeBytes (outtype), 4 );
130
-
131
- MY_EXPECT (intype, inval, outtype, outval, *(OutType *)(pOut));
132
- MY_EXPECT (intype, inval, outtype, outval,
133
- *(OutType *)(pOut + GDALGetDataTypeSizeBytes (outtype)));
134
- MY_EXPECT (
135
- intype, inval, outtype, outval,
136
- *(OutType *)(pOut + 2 * GDALGetDataTypeSizeBytes (outtype)));
137
- MY_EXPECT (
138
- intype, inval, outtype, outval,
139
- *(OutType *)(pOut + 3 * GDALGetDataTypeSizeBytes (outtype)));
123
+ outtype, GDALGetDataTypeSizeBytes (outtype), N);
124
+
125
+ for (int i = 0 ; i < N; ++i)
126
+ {
127
+ MY_EXPECT (
128
+ intype, inval, outtype, outval,
129
+ *(OutType *)(pOut + i * GDALGetDataTypeSizeBytes (outtype)));
130
+ }
140
131
}
141
132
}
142
133
0 commit comments