Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit fab78f5

Browse files
committed
- Review changes. Add NULL as additional value for abs sql test
1 parent ec1ab90 commit fab78f5

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

test/sql/decimal_functions_sql_test.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
120120
auto txn = txn_manager.BeginTransaction();
121121
// Adding in 200 random decimal inputs between [-127, 127]
122122
int i;
123-
std::vector<int8_t> inputs;
124123
int lo = 0;
125124
int hi = 254;
126125
int numEntries = 200;
@@ -133,7 +132,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
133132
std::srand(std::time(0));
134133
for (i = 0; i < numEntries; i++) {
135134
int32_t num = (std::rand() % (hi - lo)) - 127;
136-
inputs.push_back(num);
137135
std::ostringstream os;
138136
os << "insert into foo values(" << i << ", " << num << ");";
139137
TestingSQLUtil::ExecuteSQLQuery(os.str());
@@ -144,6 +142,10 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
144142
ref_result.push_back(result_string.str());
145143
}
146144
EXPECT_EQ(i, numEntries);
145+
146+
// Add an additional entry of NULL
147+
TestingSQLUtil::ExecuteSQLQuery("insert into foo values(0, NULL)");
148+
ref_result.push_back("0|");
147149
txn_manager.CommitTransaction(txn);
148150

149151
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
@@ -157,7 +159,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
157159
auto txn = txn_manager.BeginTransaction();
158160
// Adding in 200 random integer inputs between [-32767, 32767]
159161
int i;
160-
std::vector<int16_t> inputs;
161162
int lo = 0;
162163
int hi = 65534;
163164
int numEntries = 200;
@@ -170,7 +171,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
170171
std::srand(std::time(0));
171172
for (i = 0; i < numEntries; i++) {
172173
int32_t num = (std::rand() % (hi - lo)) - 32767;
173-
inputs.push_back(num);
174174
std::ostringstream os;
175175
os << "insert into foo values(" << i << ", " << num << ");";
176176
TestingSQLUtil::ExecuteSQLQuery(os.str());
@@ -181,6 +181,10 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
181181
ref_result.push_back(result_string.str());
182182
}
183183
EXPECT_EQ(i, numEntries);
184+
185+
// Add an additional entry of NULL
186+
TestingSQLUtil::ExecuteSQLQuery("insert into foo values(0, NULL)");
187+
ref_result.push_back("0|");
184188
txn_manager.CommitTransaction(txn);
185189

186190
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
@@ -194,7 +198,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
194198
auto txn = txn_manager.BeginTransaction();
195199
// Adding in 200 random integer inputs between [-32767, 32767]
196200
int i;
197-
std::vector<int32_t> inputs;
198201
int lo = 0;
199202
int hi = 65534;
200203
int numEntries = 200;
@@ -207,7 +210,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
207210
std::srand(std::time(0));
208211
for (i = 0; i < numEntries; i++) {
209212
int32_t num = (std::rand() % (hi - lo)) - 32767;
210-
inputs.push_back(num);
211213
std::ostringstream os;
212214
os << "insert into foo values(" << i << ", " << num << ");";
213215
TestingSQLUtil::ExecuteSQLQuery(os.str());
@@ -218,6 +220,10 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
218220
ref_result.push_back(result_string.str());
219221
}
220222
EXPECT_EQ(i, numEntries);
223+
224+
// Add an additional entry of NULL
225+
TestingSQLUtil::ExecuteSQLQuery("insert into foo values(0, NULL)");
226+
ref_result.push_back("0|");
221227
txn_manager.CommitTransaction(txn);
222228

223229
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
@@ -231,7 +237,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
231237
auto txn = txn_manager.BeginTransaction();
232238
// Adding in 200 random integer inputs between [-32767, 32767]
233239
int i;
234-
std::vector<int32_t> inputs;
235240
int lo = 0;
236241
int hi = 65534;
237242
int numEntries = 200;
@@ -244,7 +249,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
244249
std::srand(std::time(0));
245250
for (i = 0; i < numEntries; i++) {
246251
int32_t num = (std::rand() % (hi - lo)) - 32767;
247-
inputs.push_back(num);
248252
std::ostringstream os;
249253
os << "insert into foo values(" << i << ", " << num << ");";
250254
TestingSQLUtil::ExecuteSQLQuery(os.str());
@@ -255,6 +259,10 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
255259
ref_result.push_back(result_string.str());
256260
}
257261
EXPECT_EQ(i, numEntries);
262+
263+
// Add an additional entry of NULL
264+
TestingSQLUtil::ExecuteSQLQuery("insert into foo values(0, NULL)");
265+
ref_result.push_back("0|");
258266
txn_manager.CommitTransaction(txn);
259267

260268
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
@@ -268,7 +276,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
268276
auto txn = txn_manager.BeginTransaction();
269277
// Adding in 2500 random decimal inputs between [-500, 500]
270278
int i;
271-
std::vector<double> inputs;
272279
int lo = -500;
273280
int hi = 500;
274281
int numEntries = 500;
@@ -281,7 +288,6 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
281288
std::srand(std::time(0));
282289
for (i = 0; i < numEntries; i++) {
283290
double num = 0.45 + (std::rand() % (hi - lo));
284-
inputs.push_back(num);
285291
std::ostringstream os;
286292
os << "insert into foo values(" << i << ", " << num << ");";
287293
TestingSQLUtil::ExecuteSQLQuery(os.str());
@@ -292,6 +298,8 @@ class DecimalFunctionsSQLTest : public PelotonTest {};
292298
ref_result.push_back(result_string.str());
293299
}
294300
EXPECT_EQ(i, numEntries);
301+
TestingSQLUtil::ExecuteSQLQuery("insert into foo values(0, NULL)");
302+
ref_result.push_back("0|");
295303
txn_manager.CommitTransaction(txn);
296304

297305
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,

0 commit comments

Comments
 (0)