|
1 | 1 | /* |
2 | | - * Copyright 2019-2022 Diligent Graphics LLC |
| 2 | + * Copyright 2019-2025 Diligent Graphics LLC |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -372,30 +372,33 @@ TEST(Platforms_FileSystem, GetRelativePath) |
372 | 372 | return Path; |
373 | 373 | }; |
374 | 374 |
|
375 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from", true, "a/b/c", true).c_str(), BuildPath({".."})); |
376 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c", true).c_str(), BuildPath({"..", ".."})); |
377 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c", true).c_str(), BuildPath({".."})); |
378 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir/file", false, "a/b/c", true).c_str(), BuildPath({"..", ".."})); |
379 | | - |
380 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from", true, "a/b/c/file", false).c_str(), BuildPath({"..", "file"})); |
381 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c/file", false).c_str(), BuildPath({"..", "..", "file"})); |
382 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/file", false).c_str(), BuildPath({"..", "file"})); |
383 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir/file", false, "a/b/c/file", false).c_str(), BuildPath({"..", "..", "file"})); |
384 | | - |
385 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/to", true).c_str(), BuildPath({"to"})); |
386 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/to/dir", true).c_str(), BuildPath({"to", "dir"})); |
387 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/to", true).c_str(), BuildPath({"to"})); |
388 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/to/dir", true).c_str(), BuildPath({"to", "dir"})); |
389 | | - |
390 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/file", false).c_str(), BuildPath({"file"})); |
391 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/to/file", false).c_str(), BuildPath({"to", "file"})); |
392 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/file2", false).c_str(), BuildPath({"file2"})); |
393 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/to/file", false).c_str(), BuildPath({"to", "file"})); |
394 | | - |
395 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c/to/dir", true).c_str(), BuildPath({"..", "..", "to", "dir"})); |
396 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/to/dir", true).c_str(), BuildPath({"..", "to", "dir"})); |
397 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c/to/file", false).c_str(), BuildPath({"..", "..", "to", "file"})); |
398 | | - EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/to/file", false).c_str(), BuildPath({"..", "to", "file"})); |
| 375 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from", true, "a/b/c", true), BuildPath({".."})); |
| 376 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c", true), BuildPath({"..", ".."})); |
| 377 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c", true), BuildPath({".."})); |
| 378 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir/file", false, "a/b/c", true), BuildPath({"..", ".."})); |
| 379 | + |
| 380 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from", true, "a/b/c/file", false), BuildPath({"..", "file"})); |
| 381 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c/file", false), BuildPath({"..", "..", "file"})); |
| 382 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/file", false), BuildPath({"..", "file"})); |
| 383 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir/file", false, "a/b/c/file", false), BuildPath({"..", "..", "file"})); |
| 384 | + |
| 385 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/to", true), BuildPath({"to"})); |
| 386 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/to/dir", true), BuildPath({"to", "dir"})); |
| 387 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/to", true), BuildPath({"to"})); |
| 388 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/to/dir", true), BuildPath({"to", "dir"})); |
| 389 | + |
| 390 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/file", false), BuildPath({"file"})); |
| 391 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c", true, "a/b/c/to/file", false), BuildPath({"to", "file"})); |
| 392 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/file2", false), BuildPath({"file2"})); |
| 393 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/file", false, "a/b/c/to/file", false), BuildPath({"to", "file"})); |
| 394 | + |
| 395 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c/to/dir", true), BuildPath({"..", "..", "to", "dir"})); |
| 396 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/to/dir", true), BuildPath({"..", "to", "dir"})); |
| 397 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/dir", true, "a/b/c/to/file", false), BuildPath({"..", "..", "to", "file"})); |
| 398 | + EXPECT_EQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/to/file", false), BuildPath({"..", "to", "file"})); |
| 399 | + |
| 400 | + EXPECT_STREQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/to/file", false, '/').c_str(), "../to/file"); |
| 401 | + EXPECT_STREQ(FileSystem::GetRelativePath("a/b/c/from/file", false, "a/b/c/to/file", false, '\\').c_str(), "..\\to\\file"); |
399 | 402 | } |
400 | 403 |
|
401 | 404 |
|
|
0 commit comments