-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test - introduce unit tests for telemetry::Symlink
- Loading branch information
1 parent
947313c
commit 8b12cb4
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @file | ||
* @author Pavel Siska <[email protected]> | ||
* @brief Unit tests of telemetry::File class | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include <telemetry/directory.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace telemetry { | ||
|
||
/** | ||
* @test Test checking symlink target | ||
*/ | ||
TEST(TelemetrySymlink, hasTarget) | ||
{ | ||
auto root = Directory::create(); | ||
auto dir = root->addDir("dir"); | ||
auto file = dir->addFile("file", {}); | ||
auto symlink = root->addSymlink("symlink", file); | ||
|
||
auto target = symlink->getTarget(); | ||
|
||
EXPECT_EQ(file, target); | ||
} | ||
|
||
/** | ||
* @test Test checking symlink target lifetime | ||
*/ | ||
TEST(TelemetrySymlink, targetScopeLifetime) | ||
{ | ||
auto root = Directory::create(); | ||
auto dir = root->addDir("dir"); | ||
|
||
std::shared_ptr<Symlink> symlink; | ||
|
||
{ | ||
auto file = dir->addFile("file", {}); | ||
symlink = root->addSymlink("symlink", file); | ||
|
||
auto target = symlink->getTarget(); | ||
EXPECT_EQ(file, target); | ||
} | ||
|
||
auto target = symlink->getTarget(); | ||
EXPECT_EQ(nullptr, target); | ||
} | ||
|
||
} // namespace telemetry |