1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "data_convertor.h"
17 #include "dfs_error.h"
18 #include "rdb_helper.h"
19 #include "rdb_open_callback.h"
20 #include "rdb_store_config.h"
21 #include "sync_rule/cloud_status.h"
22 #include "result_set_mock.h"
23 #include <gmock/gmock.h>
24 #include <gtest/gtest.h>
25 #include <memory>
26
27 namespace OHOS::FileManagement::CloudSync::Test {
28 using namespace testing;
29 using namespace testing::ext;
30 using namespace std;
31 using namespace NativeRdb;
32 class DataConvertorMock final : public DataConvertor {
33 public:
34 MOCK_METHOD2(Convert, int32_t(DriveKit::DKRecord &, NativeRdb::ResultSet &));
Convert(DriveKit::DKRecord & record,NativeRdb::ValuesBucket & valueBucket)35 int32_t Convert(DriveKit::DKRecord &record, NativeRdb::ValuesBucket &valueBucket)
36 {
37 return E_OK;
38 }
39 };
40
41 class DataConvertorTest : public testing::Test {
42 public:
43 static void GenerateDefaultTable();
44 static void SetUpTestCase(void);
45 static void TearDownTestCase(void);
46 void SetUp();
47 void TearDown();
48 std::shared_ptr<DataConvertorMock> dataConvertor_;
49
50 static const std::string databaseName;
51 static std::shared_ptr<RdbStore> rdbStore_;
52 };
53
54 class SqliteSharedOpenCallback : public RdbOpenCallback {
55 public:
56 int OnCreate(RdbStore &rdbStore) override;
57 int OnUpgrade(RdbStore &rdbStore, int oldVersion, int newVersion) override;
58 static const std::string createTableTest;
59 };
60
61 std::string const SqliteSharedOpenCallback::createTableTest =
62 "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, data1 TEXT,data2 INTEGER, data3 FLOAT, data4 BLOB);";
63
OnCreate(RdbStore & rdbStore)64 int SqliteSharedOpenCallback::OnCreate(RdbStore &rdbStore)
65 {
66 GTEST_LOG_(INFO) << "OnCreate";
67 return E_OK;
68 }
69
OnUpgrade(RdbStore & rdbStore,int oldVersion,int newVersion)70 int SqliteSharedOpenCallback::OnUpgrade(RdbStore &rdbStore, int oldVersion, int newVersion)
71 {
72 GTEST_LOG_(INFO) << "OnUpgrade";
73 return E_OK;
74 }
75 const int ID1 = 1;
76 const int ID2 = 2;
77 const int ID3 = 3;
78 static const std::string RDB_TEST_PATH = "/data/test/";
79 const std::string DataConvertorTest::databaseName = RDB_TEST_PATH + "dataConvertortest.db";
80 std::shared_ptr<RdbStore> DataConvertorTest::rdbStore_ = nullptr;
81
GenerateDefaultTable()82 void DataConvertorTest::GenerateDefaultTable()
83 {
84 std::shared_ptr<RdbStore> &store = DataConvertorTest::rdbStore_;
85
86 int64_t id;
87 ValuesBucket values;
88
89 values.PutInt("id", ID1);
90 values.PutString("data1", std::string("hello"));
91 values.PutInt("data2", 1);
92 values.PutDouble("data3", 1.0);
93 values.PutBlob("data4", std::vector<uint8_t>{1});
94 store->Insert(id, "test", values);
95
96 values.Clear();
97 values.PutInt("id", ID2);
98 values.PutString("data1", std::string("1"));
99 values.PutInt("data2", 1);
100 values.PutDouble("data3", 1.0);
101 values.PutBlob("data4", std::vector<uint8_t>{});
102 store->Insert(id, "test", values);
103
104 values.Clear();
105 values.PutInt("id", ID3);
106 values.PutString("data1", std::string("hello world"));
107 values.PutInt("data2", 1);
108 values.PutDouble("data3", 1.0);
109 values.PutBlob("data4", std::vector<uint8_t>{});
110 store->Insert(id, "test", values);
111 }
112
SetUpTestCase(void)113 void DataConvertorTest::SetUpTestCase(void)
114 {
115 RdbStoreConfig sqliteSharedRstConfig(DataConvertorTest::databaseName);
116 SqliteSharedOpenCallback sqliteSharedRstHelper;
117 int errCode = E_OK;
118 DataConvertorTest::rdbStore_ =
119 OHOS::NativeRdb::RdbHelper::GetRdbStore(sqliteSharedRstConfig, 1, sqliteSharedRstHelper, errCode);
120 EXPECT_NE(DataConvertorTest::rdbStore_, nullptr);
121 DataConvertorTest::rdbStore_->ExecuteSql(SqliteSharedOpenCallback::createTableTest);
122 GenerateDefaultTable();
123 GTEST_LOG_(INFO) << "SetUpTestCase";
124 }
125
TearDownTestCase(void)126 void DataConvertorTest::TearDownTestCase(void)
127 {
128 NativeRdb::RdbHelper::DeleteRdbStore(DataConvertorTest::databaseName);
129 GTEST_LOG_(INFO) << "TearDownTestCase";
130 }
131
SetUp(void)132 void DataConvertorTest::SetUp(void)
133 {
134 dataConvertor_ = make_shared<DataConvertorMock>();
135 GTEST_LOG_(INFO) << "SetUp";
136 }
137
TearDown(void)138 void DataConvertorTest::TearDown(void)
139 {
140 dataConvertor_ = nullptr;
141 }
142
143 /**
144 * @tc.name: ResultSetToRecords001
145 * @tc.desc: Verify the ResultSetToRecords function
146 * @tc.type: FUNC
147 * @tc.require: I6JPKG
148 */
149 HWTEST_F(DataConvertorTest, DataConvertorTest001, TestSize.Level1)
150 {
151 GTEST_LOG_(INFO) << "ResultSetToRecords001 Begin";
152 try {
153 std::unique_ptr<ResultSetMock> resultSet = std::make_unique<ResultSetMock>();
154 std::vector<DriveKit::DKRecord> records;
155
156 EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(Return(1));
157
158 int32_t ret = dataConvertor_->ResultSetToRecords(std::move(resultSet), records);
159 EXPECT_EQ(E_RDB, ret);
160 } catch (...) {
161 EXPECT_TRUE(false);
162 GTEST_LOG_(INFO) << " ResultSetToRecords001 ERROR";
163 }
164
165 GTEST_LOG_(INFO) << "ResultSetToRecords001 End";
166 }
167
168 /**
169 * @tc.name: ResultSetToRecords002
170 * @tc.desc: Verify the ResultSetToRecords function
171 * @tc.type: FUNC
172 * @tc.require: I6JPKG
173 */
174 HWTEST_F(DataConvertorTest, DataConvertorTest002, TestSize.Level1)
175 {
176 GTEST_LOG_(INFO) << "ResultSetToRecords002 Begin";
177 try {
178 const int rowCount = 1;
179 std::unique_ptr<ResultSetMock> resultSet = std::make_unique<ResultSetMock>();
180 std::vector<DriveKit::DKRecord> records;
181
182 EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(DoAll(SetArgReferee<0>(rowCount), Return(0)));
183 EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(1));
184
185 int32_t ret = dataConvertor_->ResultSetToRecords(std::move(resultSet), records);
186 EXPECT_EQ(E_OK, ret);
187 } catch (...) {
188 EXPECT_TRUE(false);
189 GTEST_LOG_(INFO) << " ResultSetToRecords002 ERROR";
190 }
191
192 GTEST_LOG_(INFO) << "ResultSetToRecords002 End";
193 }
194
195 /**
196 * @tc.name: ResultSetToRecords003
197 * @tc.desc: Verify the ResultSetToRecords function
198 * @tc.type: FUNC
199 * @tc.require: I6JPKG
200 */
201 HWTEST_F(DataConvertorTest, ResultSetToRecords003, TestSize.Level1)
202 {
203 GTEST_LOG_(INFO) << "ResultSetToRecords003 Begin";
204 try {
205 std::unique_ptr<ResultSetMock> resultSet = std::make_unique<ResultSetMock>();
206 std::vector<DriveKit::DKRecord> records;
207 const int32_t rowCount = 3;
208 EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(DoAll(SetArgReferee<0>(rowCount), Return(0)));
209 EXPECT_CALL(*resultSet, GoToNextRow())
210 .Times(rowCount)
211 .WillOnce(Return(0))
212 .WillOnce(Return(0))
213 .WillRepeatedly(Return(1));
214 EXPECT_CALL(*dataConvertor_, Convert(_, _)).WillRepeatedly(Return(0));
215
216 int32_t ret = dataConvertor_->ResultSetToRecords(std::move(resultSet), records);
217 EXPECT_EQ(E_OK, ret);
218 } catch (...) {
219 EXPECT_TRUE(false);
220 GTEST_LOG_(INFO) << " ResultSetToRecords003 ERROR";
221 }
222
223 GTEST_LOG_(INFO) << "ResultSetToRecords003 End";
224 }
225
226 /**
227 * @tc.name: RecordToValueBucket001
228 * @tc.desc: Verify the RecordToValueBucket function
229 * @tc.type: FUNC
230 * @tc.require: I6JPKG
231 */
232 HWTEST_F(DataConvertorTest, RecordToValueBucket001, TestSize.Level1)
233 {
234 GTEST_LOG_(INFO) << "RecordToValueBucket001 Begin";
235 try {
236 DriveKit::DKRecord record;
237 NativeRdb::ValuesBucket valueBucket;
238 int32_t ret = dataConvertor_->RecordToValueBucket(record, valueBucket);
239 EXPECT_EQ(E_OK, ret);
240 } catch (...) {
241 EXPECT_TRUE(false);
242 GTEST_LOG_(INFO) << " RecordToValueBucket001 ERROR";
243 }
244
245 GTEST_LOG_(INFO) << "RecordToValueBucket001 End";
246 }
247
248 /**
249 * @tc.name: GetInt001
250 * @tc.desc: Verify the GetInt function
251 * @tc.type: FUNC
252 * @tc.require: I6JPKG
253 */
254 HWTEST_F(DataConvertorTest, GetInt001, TestSize.Level1)
255 {
256 GTEST_LOG_(INFO) << "GetInt001 Begin";
257 try {
258 std::string key;
259 int32_t val;
260 ResultSetMock resultSet;
261 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(1));
262 int32_t ret = DataConvertor::GetInt(key, val, resultSet);
263 EXPECT_EQ(E_RDB, ret);
264 } catch (...) {
265 EXPECT_TRUE(false);
266 GTEST_LOG_(INFO) << " GetInt001 ERROR";
267 }
268
269 GTEST_LOG_(INFO) << "GetInt001 End";
270 }
271
272 /**
273 * @tc.name: GetInt002
274 * @tc.desc: Verify the GetInt function
275 * @tc.type: FUNC
276 * @tc.require: I6JPKG
277 */
278 HWTEST_F(DataConvertorTest, GetInt002, TestSize.Level1)
279 {
280 GTEST_LOG_(INFO) << "GetInt002 Begin";
281 try {
282 std::string key;
283 int32_t val;
284 ResultSetMock resultSet;
285 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
286 EXPECT_CALL(resultSet, GetInt(_, _)).WillOnce(Return(1));
287 int32_t ret = DataConvertor::GetInt(key, val, resultSet);
288 EXPECT_EQ(E_RDB, ret);
289 } catch (...) {
290 EXPECT_TRUE(false);
291 GTEST_LOG_(INFO) << " GetInt002 ERROR";
292 }
293
294 GTEST_LOG_(INFO) << "GetInt002 End";
295 }
296
297 /**
298 * @tc.name: GetInt003
299 * @tc.desc: Verify the GetInt function
300 * @tc.type: FUNC
301 * @tc.require: I6JPKG
302 */
303 HWTEST_F(DataConvertorTest, GetInt003, TestSize.Level1)
304 {
305 GTEST_LOG_(INFO) << "GetInt003 Begin";
306 try {
307 std::string key;
308 int32_t val;
309 ResultSetMock resultSet;
310 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
311 EXPECT_CALL(resultSet, GetInt(_, _)).WillOnce(Return(0));
312 int32_t ret = DataConvertor::GetInt(key, val, resultSet);
313 EXPECT_EQ(E_OK, ret);
314 } catch (...) {
315 EXPECT_TRUE(false);
316 GTEST_LOG_(INFO) << " GetInt003 ERROR";
317 }
318
319 GTEST_LOG_(INFO) << "GetInt003 End";
320 }
321
322 /**
323 * @tc.name: GetLong001
324 * @tc.desc: Verify the GetLong function
325 * @tc.type: FUNC
326 * @tc.require: I6JPKG
327 */
328 HWTEST_F(DataConvertorTest, GetLong001, TestSize.Level1)
329 {
330 GTEST_LOG_(INFO) << "GetLong001 Begin";
331 try {
332 std::string key;
333 int64_t val;
334 ResultSetMock resultSet;
335 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(1));
336 int32_t ret = DataConvertor::GetLong(key, val, resultSet);
337 EXPECT_EQ(E_RDB, ret);
338 } catch (...) {
339 EXPECT_TRUE(false);
340 GTEST_LOG_(INFO) << " GetLong001 ERROR";
341 }
342
343 GTEST_LOG_(INFO) << "GetLong001 End";
344 }
345
346 /**
347 * @tc.name: GetLong002
348 * @tc.desc: Verify the GetLong function
349 * @tc.type: FUNC
350 * @tc.require: I6JPKG
351 */
352 HWTEST_F(DataConvertorTest, GetLong002, TestSize.Level1)
353 {
354 GTEST_LOG_(INFO) << "GetLong002 Begin";
355 try {
356 std::string key;
357 int64_t val;
358 ResultSetMock resultSet;
359 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
360 EXPECT_CALL(resultSet, GetLong(_, _)).WillOnce(Return(1));
361 int32_t ret = DataConvertor::GetLong(key, val, resultSet);
362 EXPECT_EQ(E_RDB, ret);
363 } catch (...) {
364 EXPECT_TRUE(false);
365 GTEST_LOG_(INFO) << " GetLong002 ERROR";
366 }
367
368 GTEST_LOG_(INFO) << "GetLong002 End";
369 }
370
371 /**
372 * @tc.name: GetLong003
373 * @tc.desc: Verify the GetLong function
374 * @tc.type: FUNC
375 * @tc.require: I6JPKG
376 */
377 HWTEST_F(DataConvertorTest, GetLong003, TestSize.Level1)
378 {
379 GTEST_LOG_(INFO) << "GetLong003 Begin";
380 try {
381 std::string key;
382 int64_t val;
383 ResultSetMock resultSet;
384 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
385 EXPECT_CALL(resultSet, GetLong(_, _)).WillOnce(Return(0));
386 int32_t ret = DataConvertor::GetLong(key, val, resultSet);
387 EXPECT_EQ(E_OK, ret);
388 } catch (...) {
389 EXPECT_TRUE(false);
390 GTEST_LOG_(INFO) << " GetLong003 ERROR";
391 }
392
393 GTEST_LOG_(INFO) << "GetLong003 End";
394 }
395
396 /**
397 * @tc.name: GetDouble001
398 * @tc.desc: Verify the GetDouble function
399 * @tc.type: FUNC
400 * @tc.require: I6JPKG
401 */
402 HWTEST_F(DataConvertorTest, GetDouble001, TestSize.Level1)
403 {
404 GTEST_LOG_(INFO) << "GetDouble001 Begin";
405 try {
406 std::string key;
407 double val;
408 ResultSetMock resultSet;
409 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(1));
410 int32_t ret = DataConvertor::GetDouble(key, val, resultSet);
411 EXPECT_EQ(E_RDB, ret);
412 } catch (...) {
413 EXPECT_TRUE(false);
414 GTEST_LOG_(INFO) << " GetDouble001 ERROR";
415 }
416
417 GTEST_LOG_(INFO) << "GetDouble001 End";
418 }
419
420 /**
421 * @tc.name: GetDouble002
422 * @tc.desc: Verify the GetDouble function
423 * @tc.type: FUNC
424 * @tc.require: I6JPKG
425 */
426 HWTEST_F(DataConvertorTest, GetDouble002, TestSize.Level1)
427 {
428 GTEST_LOG_(INFO) << "GetDouble002 Begin";
429 try {
430 std::string key;
431 double val;
432 ResultSetMock resultSet;
433 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
434 EXPECT_CALL(resultSet, GetDouble(_, _)).WillOnce(Return(1));
435 int32_t ret = DataConvertor::GetDouble(key, val, resultSet);
436 EXPECT_EQ(E_RDB, ret);
437 } catch (...) {
438 EXPECT_TRUE(false);
439 GTEST_LOG_(INFO) << " GetDouble002 ERROR";
440 }
441
442 GTEST_LOG_(INFO) << "GetDouble002 End";
443 }
444
445 /**
446 * @tc.name: GetDouble003
447 * @tc.desc: Verify the GetDouble function
448 * @tc.type: FUNC
449 * @tc.require: I6JPKG
450 */
451 HWTEST_F(DataConvertorTest, GetDouble003, TestSize.Level1)
452 {
453 GTEST_LOG_(INFO) << "GetDouble003 Begin";
454 try {
455 std::string key;
456 double val;
457 ResultSetMock resultSet;
458 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
459 EXPECT_CALL(resultSet, GetDouble(_, _)).WillOnce(Return(0));
460 int32_t ret = DataConvertor::GetDouble(key, val, resultSet);
461 EXPECT_EQ(E_OK, ret);
462 } catch (...) {
463 EXPECT_TRUE(false);
464 GTEST_LOG_(INFO) << " GetDouble003 ERROR";
465 }
466
467 GTEST_LOG_(INFO) << "GetDouble003 End";
468 }
469
470 /**
471 * @tc.name: GetString001
472 * @tc.desc: Verify the GetString function
473 * @tc.type: FUNC
474 * @tc.require: I6JPKG
475 */
476 HWTEST_F(DataConvertorTest, GetString001, TestSize.Level1)
477 {
478 GTEST_LOG_(INFO) << "GetString001 Begin";
479 try {
480 std::string key;
481 std::string val;
482 ResultSetMock resultSet;
483 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(1));
484 int32_t ret = DataConvertor::GetString(key, val, resultSet);
485 EXPECT_EQ(E_RDB, ret);
486 } catch (...) {
487 EXPECT_TRUE(false);
488 GTEST_LOG_(INFO) << " GetString001 ERROR";
489 }
490
491 GTEST_LOG_(INFO) << "GetString001 End";
492 }
493
494 /**
495 * @tc.name: GetString002
496 * @tc.desc: Verify the GetString function
497 * @tc.type: FUNC
498 * @tc.require: I6JPKG
499 */
500 HWTEST_F(DataConvertorTest, GetString002, TestSize.Level1)
501 {
502 GTEST_LOG_(INFO) << "GetString002 Begin";
503 try {
504 std::string key;
505 std::string val;
506 ResultSetMock resultSet;
507 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
508 EXPECT_CALL(resultSet, GetString(_, _)).WillOnce(Return(1));
509 int32_t ret = DataConvertor::GetString(key, val, resultSet);
510 EXPECT_EQ(E_RDB, ret);
511 } catch (...) {
512 EXPECT_TRUE(false);
513 GTEST_LOG_(INFO) << " GetString002 ERROR";
514 }
515
516 GTEST_LOG_(INFO) << "GetString002 End";
517 }
518
519 /**
520 * @tc.name: GetString003
521 * @tc.desc: Verify the GetString function
522 * @tc.type: FUNC
523 * @tc.require: I6JPKG
524 */
525 HWTEST_F(DataConvertorTest, GetString003, TestSize.Level1)
526 {
527 GTEST_LOG_(INFO) << "GetString003 Begin";
528 try {
529 std::string key;
530 std::string val;
531 ResultSetMock resultSet;
532 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
533 EXPECT_CALL(resultSet, GetString(_, _)).WillOnce(Return(0));
534 int32_t ret = DataConvertor::GetString(key, val, resultSet);
535 EXPECT_EQ(E_OK, ret);
536 } catch (...) {
537 EXPECT_TRUE(false);
538 GTEST_LOG_(INFO) << " GetString003 ERROR";
539 }
540
541 GTEST_LOG_(INFO) << "GetString003 End";
542 }
543
544 /**
545 * @tc.name: GetBool001
546 * @tc.desc: Verify the GetBool function
547 * @tc.type: FUNC
548 * @tc.require: I6JPKG
549 */
550 HWTEST_F(DataConvertorTest, GetBool001, TestSize.Level1)
551 {
552 GTEST_LOG_(INFO) << "GetBool001 Begin";
553 try {
554 std::string key;
555 bool val;
556 ResultSetMock resultSet;
557 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(1));
558 int32_t ret = DataConvertor::GetBool(key, val, resultSet);
559 EXPECT_EQ(E_RDB, ret);
560 } catch (...) {
561 EXPECT_TRUE(false);
562 GTEST_LOG_(INFO) << " GetBool001 ERROR";
563 }
564
565 GTEST_LOG_(INFO) << "GetBool001 End";
566 }
567
568 /**
569 * @tc.name: GetBool002
570 * @tc.desc: Verify the GetBool function
571 * @tc.type: FUNC
572 * @tc.require: I6JPKG
573 */
574 HWTEST_F(DataConvertorTest, GetBool002, TestSize.Level1)
575 {
576 GTEST_LOG_(INFO) << "GetBool002 Begin";
577 try {
578 std::string key;
579 bool val;
580 ResultSetMock resultSet;
581 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
582 EXPECT_CALL(resultSet, GetInt(_, _)).WillOnce(Return(1));
583 int32_t ret = DataConvertor::GetBool(key, val, resultSet);
584 EXPECT_EQ(E_RDB, ret);
585 } catch (...) {
586 EXPECT_TRUE(false);
587 GTEST_LOG_(INFO) << " GetBool002 ERROR";
588 }
589
590 GTEST_LOG_(INFO) << "GetBool002 End";
591 }
592
593 /**
594 * @tc.name: GetBool003
595 * @tc.desc: Verify the GetBool function
596 * @tc.type: FUNC
597 * @tc.require: I6JPKG
598 */
599 HWTEST_F(DataConvertorTest, GetBool003, TestSize.Level1)
600 {
601 GTEST_LOG_(INFO) << "GetBool003 Begin";
602 try {
603 std::string key;
604 bool val;
605 ResultSetMock resultSet;
606 EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(0));
607 EXPECT_CALL(resultSet, GetInt(_, _)).WillOnce(Return(0));
608 int32_t ret = DataConvertor::GetBool(key, val, resultSet);
609 EXPECT_EQ(E_OK, ret);
610 } catch (...) {
611 EXPECT_TRUE(false);
612 GTEST_LOG_(INFO) << " GetBool003 ERROR";
613 }
614
615 GTEST_LOG_(INFO) << "GetBool003 End";
616 }
617
618 /**
619 * @tc.name: GetLongComp001
620 * @tc.desc: Verify the GetLongComp function
621 * @tc.type: FUNC
622 * @tc.require: I6JPKG
623 */
624 HWTEST_F(DataConvertorTest, GetLongComp001, TestSize.Level1)
625 {
626 GTEST_LOG_(INFO) << "GetLongComp001 Begin";
627 try {
628 int64_t val;
629 DriveKit::DKRecordField field(std::string("1"));
630 int32_t ret = DataConvertor::GetLongComp(field, val);
631 EXPECT_EQ(E_OK, ret);
632 } catch (...) {
633 EXPECT_TRUE(false);
634 GTEST_LOG_(INFO) << " GetLongComp001 ERROR";
635 }
636
637 GTEST_LOG_(INFO) << "GetLongComp001 End";
638 }
639
640 /**
641 * @tc.name: GetLongComp002
642 * @tc.desc: Verify the GetLongComp function
643 * @tc.type: FUNC
644 * @tc.require: I6JPKG
645 */
646 HWTEST_F(DataConvertorTest, GetLongComp002, TestSize.Level1)
647 {
648 GTEST_LOG_(INFO) << "GetLongComp002 Begin";
649 try {
650 int64_t val;
651 DriveKit::DKRecordField field(1);
652 int32_t ret = DataConvertor::GetLongComp(field, val);
653 EXPECT_EQ(E_OK, ret);
654 } catch (...) {
655 EXPECT_TRUE(false);
656 GTEST_LOG_(INFO) << " GetLongComp002 ERROR";
657 }
658
659 GTEST_LOG_(INFO) << "GetLongComp002 End";
660 }
661 } // namespace OHOS::FileManagement::CloudSync::Test