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 <gtest/gtest.h> 17 18 #include <fcntl.h> 19 #include <string> 20 #include <unistd.h> 21 22 #include "rust_file.h" 23 24 namespace OHOS { 25 namespace FileManagement { 26 namespace ModuleFileIO { 27 using namespace std; 28 class RustTest : public testing::Test { 29 public: SetUpTestCase(void)30 static void SetUpTestCase(void) {}; TearDownTestCase()31 static void TearDownTestCase() {}; SetUp()32 void SetUp() {}; TearDown()33 void TearDown() {}; 34 }; 35 /** 36 * @tc.name: RustTest_ReaderIterator_0001 37 * @tc.desc: Test function of ReaderIterator() interface for SUCCESS. 38 * @tc.size: MEDIUM 39 * @tc.type: FUNC 40 * @tc.level Level 1 41 * @tc.require: AR000IGDNF 42 */ 43 HWTEST_F(RustTest, RustTest_ReaderIterator_0001, testing::ext::TestSize.Level1) 44 { 45 GTEST_LOG_(INFO) << "RustTest-begin RustTest_ReaderIterator_0001"; 46 47 char filePath[] = "/data/test/rust_test.txt"; 48 void *iter = ReaderIterator(filePath); 49 EXPECT_TRUE(iter != nullptr); 50 51 GTEST_LOG_(INFO) << "RustTest-end RustTest_ReaderIterator_0001"; 52 } 53 54 /** 55 * @tc.name: RustTest_ReaderIterator_0002 56 * @tc.desc: Test function of ReaderIterator() interface for SUCCESS. 57 * @tc.size: MEDIUM 58 * @tc.type: FUNC 59 * @tc.level Level 1 60 * @tc.require: AR000IGDNF 61 */ 62 HWTEST_F(RustTest, RustTest_ReaderIterator_0002, testing::ext::TestSize.Level1) 63 { 64 GTEST_LOG_(INFO) << "RustTest-begin RustTest_ReaderIterator_0002"; 65 66 char filePath[] = "/data/test/rust_false.txt"; 67 void *iter = ReaderIterator(filePath); 68 ASSERT_TRUE(errno == 2); 69 EXPECT_TRUE(iter == nullptr); 70 71 GTEST_LOG_(INFO) << "RustTest-end RustTest_ReaderIterator_0002"; 72 } 73 74 /** 75 * @tc.name: RustTest_ReaderIterator_0003 76 * @tc.desc: Test function of ReaderIterator() interface for SUCCESS. 77 * @tc.size: MEDIUM 78 * @tc.type: FUNC 79 * @tc.level Level 1 80 * @tc.require: AR000IGDNF 81 */ 82 HWTEST_F(RustTest, RustTest_ReaderIterator_0003, testing::ext::TestSize.Level1) 83 { 84 GTEST_LOG_(INFO) << "RustTest-begin RustTest_ReaderIterator_0003"; 85 86 void *iter = ReaderIterator(nullptr); 87 ASSERT_TRUE(errno = 22); 88 EXPECT_TRUE(iter == nullptr); 89 90 GTEST_LOG_(INFO) << "RustTest-end RustTest_ReaderIterator_0003"; 91 } 92 93 /** 94 * @tc.name: RustTest_NextLine_0001 95 * @tc.desc: Test function of NextLine() interface for SUCCESS. 96 * @tc.size: MEDIUM 97 * @tc.type: FUNC 98 * @tc.level Level 1 99 * @tc.require: AR000IGDNF 100 */ 101 HWTEST_F(RustTest, RustTest_NextLine_0001, testing::ext::TestSize.Level1) 102 { 103 GTEST_LOG_(INFO) << "RustTest-begin RustTest_NextLine_0001"; 104 105 char filePath[] = "/data/test/rust_test.txt"; 106 void *iter = ReaderIterator(filePath); 107 Str *ret = NextLine(iter); 108 ASSERT_TRUE(ret != nullptr); 109 int result = strcmp(ret->str, "abc\n"); 110 EXPECT_TRUE(result == 0); 111 EXPECT_TRUE(ret->len == 4); 112 StrFree(ret); 113 114 GTEST_LOG_(INFO) << "RustTest-end RustTest_NextLine_0001"; 115 } 116 117 /** 118 * @tc.name: RustTest_NextLine_0002 119 * @tc.desc: Test function of NextLine() interface for SUCCESS. 120 * @tc.size: MEDIUM 121 * @tc.type: FUNC 122 * @tc.level Level 1 123 * @tc.require: AR000IGDNF 124 */ 125 HWTEST_F(RustTest, RustTest_NextLine_0002, testing::ext::TestSize.Level1) 126 { 127 GTEST_LOG_(INFO) << "RustTest-begin RustTest_NextLine_0002"; 128 129 char filePath[] = "/data/test/false.txt"; 130 void *iter = ReaderIterator(filePath); 131 Str *ret = NextLine(iter); 132 EXPECT_TRUE(ret == nullptr); 133 StrFree(ret); 134 135 GTEST_LOG_(INFO) << "RustTest-end RustTest_NextLine_0002"; 136 } 137 138 /** 139 * @tc.name: RustTest_NextLine_0003 140 * @tc.desc: Test function of NextLine() interface for SUCCESS. 141 * @tc.size: MEDIUM 142 * @tc.type: FUNC 143 * @tc.level Level 1 144 * @tc.require: AR000IGDNF 145 */ 146 HWTEST_F(RustTest, RustTest_NextLine_0003, testing::ext::TestSize.Level1) 147 { 148 GTEST_LOG_(INFO) << "RustTest-begin RustTest_NextLine_0003"; 149 150 Str *ret = NextLine(nullptr); 151 EXPECT_TRUE(ret == nullptr); 152 StrFree(ret); 153 154 GTEST_LOG_(INFO) << "RustTest-end RustTest_NextLine_0003"; 155 } 156 157 /** 158 * @tc.name: RustTest_Lseek_0001 159 * @tc.desc: Test function of Lseek() interface for SUCCESS. 160 * @tc.size: MEDIUM 161 * @tc.type: FUNC 162 * @tc.level Level 1 163 * @tc.require: AR000IGCS3 164 */ 165 HWTEST_F(RustTest, RustTest_Lseek_0001, testing::ext::TestSize.Level1) 166 { 167 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0001"; 168 169 const char fileStr[] = "/data/test/rust_test.txt"; 170 int fd = open(fileStr, O_RDWR); 171 ASSERT_TRUE(fd >= 0); 172 long long offset = -15; 173 long long ret = Lseek(fd, offset, END); 174 EXPECT_TRUE(ret == 105); 175 close(fd); 176 177 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0001"; 178 } 179 180 /** 181 * @tc.name: RustTest_Lseek_0002 182 * @tc.desc: Test function of Lseek() interface for SUCCESS. 183 * @tc.size: MEDIUM 184 * @tc.type: FUNC 185 * @tc.level Level 1 186 * @tc.require: AR000IGCS3 187 */ 188 HWTEST_F(RustTest, RustTest_Lseek_0002, testing::ext::TestSize.Level1) 189 { 190 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0002"; 191 192 const char fileStr[] = "/data/test/rust_test.txt"; 193 int fd = open(fileStr, O_RDWR); 194 ASSERT_TRUE(fd >= 0); 195 long long offset = -15; 196 long long ret = Lseek(fd, offset, END); 197 EXPECT_TRUE(ret == 105); 198 offset = -10; 199 ret = Lseek(fd, offset, CURRENT); 200 EXPECT_TRUE(ret == 95); 201 close(fd); 202 203 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0002"; 204 } 205 206 /** 207 * @tc.name: RustTest_Lseek_0003 208 * @tc.desc: Test function of Lseek() interface for SUCCESS. 209 * @tc.size: MEDIUM 210 * @tc.type: FUNC 211 * @tc.level Level 1 212 * @tc.require: AR000IGCS3 213 */ 214 HWTEST_F(RustTest, RustTest_Lseek_0003, testing::ext::TestSize.Level1) 215 { 216 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0003"; 217 218 const char fileStr[] = "/data/test/rust_test.txt"; 219 int fd = open(fileStr, O_RDWR); 220 ASSERT_TRUE(fd >= 0); 221 long long offset = 20; 222 long long ret = Lseek(fd, offset, START); 223 EXPECT_TRUE(ret == 20); 224 close(fd); 225 226 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0003"; 227 } 228 229 /** 230 * @tc.name: RustTest_Lseek_0004 231 * @tc.desc: Test function of Lseek() interface for SUCCESS. 232 * @tc.size: MEDIUM 233 * @tc.type: FUNC 234 * @tc.level Level 1 235 * @tc.require: AR000IGCS3 236 */ 237 HWTEST_F(RustTest, RustTest_Lseek_0004, testing::ext::TestSize.Level1) 238 { 239 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0004"; 240 241 const char fileStr[] = "/data/test/rust_test.txt"; 242 int fd = open(fileStr, O_RDWR); 243 ASSERT_TRUE(fd >= 0); 244 long long offset = -10; 245 long long ret = Lseek(fd, offset, START); 246 EXPECT_TRUE(ret == -1); 247 close(fd); 248 249 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0004"; 250 } 251 252 /** 253 * @tc.name: RustTest_Lseek_0005 254 * @tc.desc: Test function of Lseek() interface for SUCCESS. 255 * @tc.size: MEDIUM 256 * @tc.type: FUNC 257 * @tc.level Level 1 258 * @tc.require: AR000IGCS3 259 */ 260 HWTEST_F(RustTest, RustTest_Lseek_0005, testing::ext::TestSize.Level1) 261 { 262 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0005"; 263 264 const char fileStr[] = "/data/test/rust_test.txt"; 265 int fd = open(fileStr, O_RDWR); 266 ASSERT_TRUE(fd >= 0); 267 long long offset = 20; 268 long long ret = Lseek(fd, offset, START); 269 EXPECT_TRUE(ret == 20); 270 offset = 18; 271 ret = Lseek(fd, offset, CURRENT); 272 EXPECT_TRUE(ret == 38); 273 close(fd); 274 275 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0005"; 276 } 277 278 /** 279 * @tc.name: RustTest_Lseek_0006 280 * @tc.desc: Test function of Lseek() interface for SUCCESS. 281 * @tc.size: MEDIUM 282 * @tc.type: FUNC 283 * @tc.level Level 1 284 * @tc.require: AR000IGCS3 285 */ 286 HWTEST_F(RustTest, RustTest_Lseek_0006, testing::ext::TestSize.Level1) 287 { 288 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0006"; 289 290 const char fileStr[] = "/data/test/rust_test.txt"; 291 int fd = open(fileStr, O_RDWR); 292 ASSERT_TRUE(fd >= 0); 293 long long offset = 30; 294 long long ret = Lseek(fd, offset, END); 295 EXPECT_TRUE(ret == 150); 296 close(fd); 297 298 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0006"; 299 } 300 301 /** 302 * @tc.name: RustTest_Lseek_0007 303 * @tc.desc: Test function of Lseek() interface for SUCCESS. 304 * @tc.size: MEDIUM 305 * @tc.type: FUNC 306 * @tc.level Level 1 307 * @tc.require: AR000IGCS3 308 */ 309 HWTEST_F(RustTest, RustTest_Lseek_0007, testing::ext::TestSize.Level1) 310 { 311 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Lseek_0007"; 312 313 long long offset = 30; 314 long long ret = Lseek(34, offset, END); 315 EXPECT_TRUE(ret == -1); 316 317 GTEST_LOG_(INFO) << "RustTest-end RustTest_Lseek_0007"; 318 } 319 320 /** 321 * @tc.name: RustTest_Mkdirs_0001 322 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 323 * @tc.size: MEDIUM 324 * @tc.type: FUNC 325 * @tc.level Level 1 326 * @tc.require: AR000IGDNJ 327 */ 328 HWTEST_F(RustTest, RustTest_Mkdirs_0001, testing::ext::TestSize.Level1) 329 { 330 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0001"; 331 332 char filePathSingle[] = "/data/test/test1"; 333 int ret1 = access(filePathSingle, F_OK); 334 ASSERT_TRUE(ret1 == -1); 335 int ret = Mkdirs(filePathSingle, SINGLE); 336 EXPECT_TRUE(ret == 0); 337 ret1 = access(filePathSingle, F_OK); 338 ASSERT_TRUE(ret1 == 0); 339 int ret2 = remove(filePathSingle); 340 EXPECT_TRUE(ret2 == 0); 341 342 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0001"; 343 } 344 345 /** 346 * @tc.name: RustTest_Mkdirs_0002 347 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 348 * @tc.size: MEDIUM 349 * @tc.type: FUNC 350 * @tc.level Level 1 351 * @tc.require: AR000IGDNJ 352 */ 353 HWTEST_F(RustTest, RustTest_Mkdirs_0002, testing::ext::TestSize.Level1) 354 { 355 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0002"; 356 357 char filePathMultiple[] = "/data/test/test2/test3"; 358 int ret1 = access(filePathMultiple, F_OK); 359 ASSERT_TRUE(ret1 == -1); 360 int ret = Mkdirs(filePathMultiple, MULTIPLE); 361 EXPECT_TRUE(ret == 0); 362 ret1 = access(filePathMultiple, F_OK); 363 ASSERT_TRUE(ret1 == 0); 364 int ret2 = remove(filePathMultiple); 365 EXPECT_TRUE(ret2 == 0); 366 367 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0002"; 368 } 369 370 /** 371 * @tc.name: RustTest_Mkdirs_0003 372 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 373 * @tc.size: MEDIUM 374 * @tc.type: FUNC 375 * @tc.level Level 1 376 * @tc.require: AR000IGDNJ 377 */ 378 HWTEST_F(RustTest, RustTest_Mkdirs_0003, testing::ext::TestSize.Level1) 379 { 380 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0003"; 381 382 char filePathSingle[] = "/data/test/testfalse/test"; 383 int ret1 = access(filePathSingle, F_OK); 384 ASSERT_TRUE(ret1 == -1); 385 int ret = Mkdirs(filePathSingle, SINGLE); 386 EXPECT_TRUE(ret == -1); 387 388 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0003"; 389 } 390 391 /** 392 * @tc.name: RustTest_Mkdirs_0004 393 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 394 * @tc.size: MEDIUM 395 * @tc.type: FUNC 396 * @tc.level Level 1 397 * @tc.require: AR000IGDNJ 398 */ 399 HWTEST_F(RustTest, RustTest_Mkdirs_0004, testing::ext::TestSize.Level1) 400 { 401 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0004"; 402 403 char filePathMultiplr[] = "/data/test"; 404 int ret = Mkdirs(filePathMultiplr, MULTIPLE); 405 EXPECT_TRUE(ret == 0); 406 407 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0004"; 408 } 409 410 /** 411 * @tc.name: RustTest_Mkdirs_0005 412 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 413 * @tc.size: MEDIUM 414 * @tc.type: FUNC 415 * @tc.level Level 1 416 * @tc.require: AR000IGDNJ 417 */ 418 HWTEST_F(RustTest, RustTest_Mkdirs_0005, testing::ext::TestSize.Level1) 419 { 420 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0005"; 421 422 char filePath[] = ""; 423 int ret = Mkdirs(filePath, SINGLE); 424 ASSERT_TRUE(errno == 2); 425 EXPECT_TRUE(ret == -1); 426 427 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0005"; 428 } 429 430 /** 431 * @tc.name: RustTest_Mkdirs_0006 432 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 433 * @tc.size: MEDIUM 434 * @tc.type: FUNC 435 * @tc.level Level 1 436 * @tc.require: AR000IGDNJ 437 */ 438 HWTEST_F(RustTest, RustTest_Mkdirs_0006, testing::ext::TestSize.Level1) 439 { 440 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0006"; 441 442 char filePath[] = ""; 443 int ret = Mkdirs(filePath, MULTIPLE); 444 ASSERT_TRUE(errno == 2); 445 EXPECT_TRUE(ret == 0); 446 447 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0006"; 448 } 449 450 /** 451 * @tc.name: RustTest_Mkdirs_0007 452 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 453 * @tc.size: MEDIUM 454 * @tc.type: FUNC 455 * @tc.level Level 1 456 * @tc.require: AR000IGDNJ 457 */ 458 HWTEST_F(RustTest, RustTest_Mkdirs_0007, testing::ext::TestSize.Level1) 459 { 460 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0007"; 461 462 char filePath[] = "/data/test/rust_test.txt"; 463 int ret = Mkdirs(filePath, SINGLE); 464 ASSERT_TRUE(errno == 17); 465 EXPECT_TRUE(ret == -1); 466 467 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0007"; 468 } 469 470 /** 471 * @tc.name: RustTest_Mkdirs_0008 472 * @tc.desc: Test function of Mkdirs() interface for SUCCESS. 473 * @tc.size: MEDIUM 474 * @tc.type: FUNC 475 * @tc.level Level 1 476 * @tc.require: AR000IGDNJ 477 */ 478 HWTEST_F(RustTest, RustTest_Mkdirs_0008, testing::ext::TestSize.Level1) 479 { 480 GTEST_LOG_(INFO) << "RustTest-begin RustTest_Mkdirs_0008"; 481 482 char filePath[] = "/data/test/rust_test.txt"; 483 int ret = Mkdirs(filePath, MULTIPLE); 484 ASSERT_TRUE(errno == 17); 485 EXPECT_TRUE(ret == -1); 486 487 GTEST_LOG_(INFO) << "RustTest-end RustTest_Mkdirs_0008"; 488 } 489 490 /** 491 * @tc.name: RustTest_GetParent_0001 492 * @tc.desc: Test function of GetParent() interface for SUCCESS. 493 * @tc.size: MEDIUM 494 * @tc.type: FUNC 495 * @tc.level Level 1 496 * @tc.require: AR000IGDNL 497 */ 498 HWTEST_F(RustTest, RustTest_GetParent_0001, testing::ext::TestSize.Level1) 499 { 500 GTEST_LOG_(INFO) << "RustTest-begin RustTest_GetParent_0001"; 501 502 const char fileStr[] = "/data/test/rust_test.txt"; 503 int fd = open(fileStr, O_RDWR); 504 Str *str = GetParent(fd); 505 ASSERT_TRUE(str != nullptr); 506 int result = strcmp(str->str, "/data/test"); 507 EXPECT_TRUE(result == 0); 508 StrFree(str); 509 close(fd); 510 511 GTEST_LOG_(INFO) << "RustTest-end RustTest_GetParent_0001"; 512 } 513 514 /** 515 * @tc.name: RustTest_GetParent_0002 516 * @tc.desc: Test function of GetParent() interface for SUCCESS. 517 * @tc.size: MEDIUM 518 * @tc.type: FUNC 519 * @tc.level Level 1 520 * @tc.require: AR000IGDNL 521 */ 522 HWTEST_F(RustTest, RustTest_GetParent_0002, testing::ext::TestSize.Level1) 523 { 524 GTEST_LOG_(INFO) << "RustTest-begin RustTest_GetParent_0002"; 525 526 Str *str = GetParent(-1); 527 ASSERT_TRUE(errno != 0); 528 EXPECT_TRUE(str == nullptr); 529 530 GTEST_LOG_(INFO) << "RustTest-end RustTest_GetParent_0002"; 531 } 532 533 /** 534 * @tc.name: RustTest_GetParent_0003 535 * @tc.desc: Test function of GetParent() interface for SUCCESS. 536 * @tc.size: MEDIUM 537 * @tc.type: FUNC 538 * @tc.level Level 1 539 * @tc.require: AR000IGDNL 540 */ 541 HWTEST_F(RustTest, RustTest_GetParent_0003, testing::ext::TestSize.Level1) 542 { 543 GTEST_LOG_(INFO) << "RustTest-begin RustTest_GetParent_0003"; 544 545 Str *str = GetParent(34); 546 ASSERT_TRUE(errno == 2); 547 EXPECT_TRUE(str == nullptr); 548 549 GTEST_LOG_(INFO) << "RustTest-end RustTest_GetParent_0003"; 550 } 551 552 /** 553 * @tc.name: RustTest_StrFree_0001 554 * @tc.desc: Test function of StrFree() interface for SUCCESS. 555 * @tc.size: MEDIUM 556 * @tc.type: FUNC 557 * @tc.level Level 1 558 * @tc.require: AR000IGDNF 559 */ 560 HWTEST_F(RustTest, RustTest_StrFree_0001, testing::ext::TestSize.Level1) 561 { 562 GTEST_LOG_(INFO) << "RustTest-begin RustTest_StrFree_0001"; 563 564 const char fileStr[] = "/data/test/rust_test.txt"; 565 int fd = open(fileStr, O_RDWR); 566 Str *str1 = GetParent(fd); 567 int result = strcmp(str1->str, "/data/test"); 568 EXPECT_TRUE(result == 0); 569 StrFree(str1); 570 close(fd); 571 572 GTEST_LOG_(INFO) << "RustTest-end RustTest_StrFree_0001"; 573 } 574 575 /** 576 * @tc.name: RustTest_StrFree_0002 577 * @tc.desc: Test function of StrFree() interface for SUCCESS. 578 * @tc.size: MEDIUM 579 * @tc.type: FUNC 580 * @tc.level Level 1 581 * @tc.require: AR000IGDNF 582 */ 583 HWTEST_F(RustTest, RustTest_StrFree_0002, testing::ext::TestSize.Level1) 584 { 585 GTEST_LOG_(INFO) << "RustTest-begin RustTest_StrFree_0002"; 586 587 Str *str = nullptr; 588 StrFree(str); 589 EXPECT_TRUE(str == nullptr); 590 591 GTEST_LOG_(INFO) << "RustTest-end RustTest_StrFree_0002"; 592 } 593 594 /** 595 * @tc.name: RustTest_CutFileName_0000 596 * @tc.desc: Test function of CutFileName() interface for SUCCESS. 597 * @tc.size: MEDIUM 598 * @tc.type: FUNC 599 * @tc.level Level 1 600 * @tc.require: AR000IGDNF 601 */ 602 HWTEST_F(RustTest, RustTest_CutFileName_0000, testing::ext::TestSize.Level1) 603 { 604 GTEST_LOG_(INFO) << "RustTest-begin RustTest_CutFileName_0000"; 605 string myStr = "<?,你好,世界!hello, world! ?XML, 你好,世界!"; 606 607 Str *str1 = CutFileName(myStr.c_str(), 2); 608 GTEST_LOG_(INFO) << "RustTest_CutFileName_0000 str1" << str1->str; 609 GTEST_LOG_(INFO) << "RustTest_CutFileName_0000 str1" << str1->len; 610 EXPECT_TRUE(string(str1->str).compare("<?,你好,世界!hello, world! ?XML, 你好,世") == 0); 611 StrFree(str1); 612 Str *str2 = CutFileName(myStr.c_str(), 10); 613 GTEST_LOG_(INFO) << "RustTest_CutFileName_0000 str2" << str2->str; 614 GTEST_LOG_(INFO) << "RustTest_CutFileName_0000 str2" << str2->len; 615 EXPECT_TRUE(string(str2->str).compare("<?,你好,世界!hello, world! ?X") == 0); 616 StrFree(str2); 617 618 GTEST_LOG_(INFO) << "RustTest-end RustTest_CutFileName_0000"; 619 } 620 621 } 622 } 623 }