Skip to content

Commit

Permalink
Merge pull request #8473 from doronhi/video-profile-eq
Browse files Browse the repository at this point in the history
Video profile eq
  • Loading branch information
ev-mp authored Mar 9, 2021
2 parents 76a3684 + e45f44a commit 6fef8a2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/librealsense2/hpp/rs_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ namespace rs2
return intr;
}

bool operator==(const video_stream_profile& other) const
{
return (((stream_profile&)*this)==other &&
width() == other.width() &&
height() == other.height());
}

using stream_profile::clone;

/**
Expand Down
51 changes: 51 additions & 0 deletions unit-tests/types/test-profile-eq.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

#include "../func/func-common.h"
#include "../../include/librealsense2/hpp/rs_frame.hpp"
#include <iostream>

using namespace rs2;

TEST_CASE("test video_stream_profile operator==", "[live]")
{
// Test that for 2 video_stream_profile objects, if width and height are different
// then, video_stream_profile.operator== returns false.

auto devices = find_devices_by_product_line_or_exit(RS2_PRODUCT_LINE_DEPTH);
if (devices.size() == 0) return;
auto dev = devices[0];

auto depth_sens = dev.first< rs2::depth_sensor >();

stream_profile profile0, profile1;
std::vector< stream_profile > stream_profiles;
REQUIRE_NOTHROW(stream_profiles = depth_sens.get_stream_profiles());
for (auto profile : stream_profiles)
{
if (profile.is<video_stream_profile>())
{
profile0 = profile;
}
}
if (!profile0) return;
video_stream_profile vprofile0 = profile0.as<video_stream_profile>();

for (auto profile : stream_profiles)
{
if (!profile.is<video_stream_profile>()) continue;
if (profile == profile0)
{
video_stream_profile vprofile = profile.as<video_stream_profile>();
if (vprofile0.width() == vprofile.width() &&
vprofile0.height() == vprofile.height())
{
REQUIRE(vprofile0 == vprofile);
}
else
{
REQUIRE(!(vprofile0 == vprofile));
}
}
}
}

0 comments on commit 6fef8a2

Please sign in to comment.