summaryrefslogtreecommitdiff
path: root/test/shared-fd.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-11-29 20:38:10 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-04 23:05:07 +0200
commit560f5cf998646ddc54a20dc1c7326012834d3204 (patch)
treeb0b4da6084cdf2c10b359b986ad27e33baa6bdfb /test/shared-fd.cpp
parent5c85e7024027c90b1b054782e510691b8b9c7419 (diff)
libcamera: base: shared_fd: Rename fd() to get()
For consistency with UniqueFD, rename the fd() function to get(). Renaming UniqueFD::get() to fd() would have been another option, but was rejected to keep as close as possible to the std::shared_ptr<> and std::unique_ptr<> APIs. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Diffstat (limited to 'test/shared-fd.cpp')
-rw-r--r--test/shared-fd.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/test/shared-fd.cpp b/test/shared-fd.cpp
index 60e5d0aa..997d7be1 100644
--- a/test/shared-fd.cpp
+++ b/test/shared-fd.cpp
@@ -46,7 +46,7 @@ protected:
/* Test creating empty SharedFD. */
desc1_ = new SharedFD();
- if (desc1_->fd() != -1) {
+ if (desc1_->get() != -1) {
std::cout << "Failed fd numerical check (default constructor)"
<< std::endl;
return TestFail;
@@ -60,19 +60,19 @@ protected:
* descriptor.
*/
desc1_ = new SharedFD(fd_);
- if (desc1_->fd() == fd_) {
+ if (desc1_->get() == fd_) {
std::cout << "Failed fd numerical check (lvalue ref constructor)"
<< std::endl;
return TestFail;
}
- if (!isValidFd(fd_) || !isValidFd(desc1_->fd())) {
+ if (!isValidFd(fd_) || !isValidFd(desc1_->get())) {
std::cout << "Failed fd validity after construction (lvalue ref constructor)"
<< std::endl;
return TestFail;
}
- int fd = desc1_->fd();
+ int fd = desc1_->get();
delete desc1_;
desc1_ = nullptr;
@@ -91,19 +91,19 @@ protected:
int dupFdCopy = dupFd;
desc1_ = new SharedFD(std::move(dupFd));
- if (desc1_->fd() != dupFdCopy) {
+ if (desc1_->get() != dupFdCopy) {
std::cout << "Failed fd numerical check (rvalue ref constructor)"
<< std::endl;
return TestFail;
}
- if (dupFd != -1 || !isValidFd(fd_) || !isValidFd(desc1_->fd())) {
+ if (dupFd != -1 || !isValidFd(fd_) || !isValidFd(desc1_->get())) {
std::cout << "Failed fd validity after construction (rvalue ref constructor)"
<< std::endl;
return TestFail;
}
- fd = desc1_->fd();
+ fd = desc1_->get();
delete desc1_;
desc1_ = nullptr;
@@ -118,13 +118,14 @@ protected:
desc1_ = new SharedFD(fd_);
desc2_ = new SharedFD(*desc1_);
- if (desc1_->fd() == fd_ || desc2_->fd() == fd_ || desc1_->fd() != desc2_->fd()) {
+ if (desc1_->get() == fd_ || desc2_->get() == fd_ ||
+ desc1_->get() != desc2_->get()) {
std::cout << "Failed fd numerical check (copy constructor)"
<< std::endl;
return TestFail;
}
- if (!isValidFd(desc1_->fd()) || !isValidFd(desc2_->fd())) {
+ if (!isValidFd(desc1_->get()) || !isValidFd(desc2_->get())) {
std::cout << "Failed fd validity after construction (copy constructor)"
<< std::endl;
return TestFail;
@@ -133,7 +134,7 @@ protected:
delete desc1_;
desc1_ = nullptr;
- if (!isValidFd(desc2_->fd())) {
+ if (!isValidFd(desc2_->get())) {
std::cout << "Failed fd validity after destruction (copy constructor)"
<< std::endl;
return TestFail;
@@ -144,16 +145,16 @@ protected:
/* Test creating SharedFD by taking over other SharedFD. */
desc1_ = new SharedFD(fd_);
- fd = desc1_->fd();
+ fd = desc1_->get();
desc2_ = new SharedFD(std::move(*desc1_));
- if (desc1_->fd() != -1 || desc2_->fd() != fd) {
+ if (desc1_->get() != -1 || desc2_->get() != fd) {
std::cout << "Failed fd numerical check (move constructor)"
<< std::endl;
return TestFail;
}
- if (!isValidFd(desc2_->fd())) {
+ if (!isValidFd(desc2_->get())) {
std::cout << "Failed fd validity after construction (move constructor)"
<< std::endl;
return TestFail;
@@ -168,16 +169,16 @@ protected:
desc1_ = new SharedFD();
desc2_ = new SharedFD(fd_);
- fd = desc2_->fd();
+ fd = desc2_->get();
*desc1_ = *desc2_;
- if (desc1_->fd() != fd || desc2_->fd() != fd) {
+ if (desc1_->get() != fd || desc2_->get() != fd) {
std::cout << "Failed fd numerical check (copy assignment)"
<< std::endl;
return TestFail;
}
- if (!isValidFd(desc1_->fd()) || !isValidFd(desc2_->fd())) {
+ if (!isValidFd(desc1_->get()) || !isValidFd(desc2_->get())) {
std::cout << "Failed fd validity after construction (copy assignment)"
<< std::endl;
return TestFail;
@@ -192,16 +193,16 @@ protected:
desc1_ = new SharedFD();
desc2_ = new SharedFD(fd_);
- fd = desc2_->fd();
+ fd = desc2_->get();
*desc1_ = std::move(*desc2_);
- if (desc1_->fd() != fd || desc2_->fd() != -1) {
+ if (desc1_->get() != fd || desc2_->get() != -1) {
std::cout << "Failed fd numerical check (move assignment)"
<< std::endl;
return TestFail;
}
- if (!isValidFd(desc1_->fd())) {
+ if (!isValidFd(desc1_->get())) {
std::cout << "Failed fd validity after construction (move assignment)"
<< std::endl;
return TestFail;