|
| 1 | +// Copyright (c) 2016, Kentaro Wada |
| 2 | +// All rights reserved. |
| 3 | +// |
| 4 | +// Software License Agreement (BSD License 2.0) |
| 5 | +// |
| 6 | +// Redistribution and use in source and binary forms, with or without |
| 7 | +// modification, are permitted provided that the following conditions |
| 8 | +// are met: |
| 9 | +// |
| 10 | +// * Redistributions of source code must retain the above copyright |
| 11 | +// notice, this list of conditions and the following disclaimer. |
| 12 | +// * Redistributions in binary form must reproduce the above |
| 13 | +// copyright notice, this list of conditions and the following |
| 14 | +// disclaimer in the documentation and/or other materials provided |
| 15 | +// with the distribution. |
| 16 | +// * Neither the name of the copyright holder nor the names of its |
| 17 | +// contributors may be used to endorse or promote products derived |
| 18 | +// from this software without specific prior written permission. |
| 19 | +// |
| 20 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 23 | +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 24 | +// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 26 | +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 27 | +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 28 | +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 29 | +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 30 | +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 31 | +// POSSIBILITY OF SUCH DAMAGE. |
| 32 | + |
| 33 | +// this file is originally ported from ROS1: |
| 34 | +// https://github.com/ros/common_msgs/blob/53579e6bba3d7f692949227fc4fe06cf47689f3a/sensor_msgs/test/test_image_encodings.cpp |
| 35 | + |
| 36 | +#include <gtest/gtest.h> |
| 37 | +#include "sensor_msgs/image_encodings.hpp" |
| 38 | + |
| 39 | +TEST(sensor_msgs, NumChannels) |
| 40 | +{ |
| 41 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("mono8"), 1); |
| 42 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("rgb8"), 3); |
| 43 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("8UC"), 1); |
| 44 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("8UC3"), 3); |
| 45 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("8UC10"), 10); |
| 46 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("16UC"), 1); |
| 47 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("16UC3"), 3); |
| 48 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("16UC10"), 10); |
| 49 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("32SC"), 1); |
| 50 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("32SC3"), 3); |
| 51 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("32SC10"), 10); |
| 52 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC"), 1); |
| 53 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC3"), 3); |
| 54 | + ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC10"), 10); |
| 55 | +} |
| 56 | + |
| 57 | +TEST(sensor_msgs, bitDepth) |
| 58 | +{ |
| 59 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("mono8"), 8); |
| 60 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("rgb8"), 8); |
| 61 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("8UC"), 8); |
| 62 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("8UC3"), 8); |
| 63 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("8UC10"), 8); |
| 64 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("16UC"), 16); |
| 65 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("16UC3"), 16); |
| 66 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("16UC10"), 16); |
| 67 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("32SC"), 32); |
| 68 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("32SC3"), 32); |
| 69 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("32SC10"), 32); |
| 70 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC"), 64); |
| 71 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC3"), 64); |
| 72 | + ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC10"), 64); |
| 73 | +} |
0 commit comments