unit-tests-offline.cpp
Go to the documentation of this file.
00001 // License: Apache 2.0. See LICENSE file in root directory.
00002 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
00003 
00004 #if !defined(MAKEFILE) || ( defined(OFFLINE_TEST) )
00005 
00006 #define CATCH_CONFIG_MAIN
00007 #include "catch/catch.hpp"
00008 
00009 #include "unit-tests-common.h"
00010 #include "../src/device.h"
00011 
00012 #include <sstream>
00013 
00014 static std::string unknown = "UNKNOWN"; 
00015 
00016 // Helper to produce a not-null pointer to a specific object type, to help validate API methods.
00017 // Use with caution, the resulting pointer does not address a real object!
00018 struct fake_object_pointer { template<class T> operator T * () const { return (T *)(0x100); } };
00019 
00020 
00021 TEST_CASE("wraparound_mechanism produces correct output", "[offline] [validation]")
00022 {
00023     auto unsigned_short_max = std::numeric_limits<uint16_t>::max();
00024     rsimpl::wraparound_mechanism<unsigned long long> wm(1, unsigned_short_max);
00025 
00026     unsigned long long last_number = 65532;
00027     for (unsigned i = 65533; last_number < unsigned_short_max * 5; ++i)
00028     {
00029         if (i > unsigned_short_max)
00030             i = 1;
00031 
00032         auto new_number = wm.fix(i);
00033         REQUIRE((new_number - last_number) == 1);
00034         last_number = new_number;
00035     }
00036 }
00037 
00038 TEST_CASE( "rs_create_context() validates input", "[offline] [validation]" )
00039 {
00040     REQUIRE(rs_create_context(RS_API_VERSION - 100, require_error("", false)) == nullptr);
00041     REQUIRE(rs_create_context(RS_API_VERSION + 100, require_error("", false)) == nullptr);
00042     auto ctx = rs_create_context(RS_API_VERSION + 1, require_no_error()); // make sure changes in patch do not fail context creation
00043     REQUIRE(ctx != nullptr);
00044     rs_delete_context(ctx, require_no_error());
00045 }
00046 
00047 TEST_CASE( "rs_delete_context() validates input", "[offline] [validation]" )
00048 {
00049     rs_delete_context(nullptr, require_error("null pointer passed for argument \"context\""));
00050 }
00051 
00052 TEST_CASE( "rs_get_device_count() validates input", "[offline] [validation]" )
00053 {
00054     REQUIRE(rs_get_device_count(nullptr, require_error("null pointer passed for argument \"context\"")) == 0);
00055 }
00056 
00057 TEST_CASE( "rs_get_device() validates input", "[offline] [validation]" )
00058 {
00059     REQUIRE(rs_get_device(nullptr, 0, require_error("null pointer passed for argument \"context\"")) == nullptr);
00060 
00061     REQUIRE(rs_get_device(fake_object_pointer(), -1, require_error("out of range value for argument \"index\"")) == nullptr);
00062     // NOTE: Index upper bound determined by rs_get_device_count(), can't validate without a live object
00063 }
00064 
00065 TEST_CASE( "rs_get_device_name() validates input", "[offline] [validation]" )
00066 {
00067     REQUIRE(rs_get_device_name(nullptr, require_error("null pointer passed for argument \"device\"")) == nullptr);
00068 }
00069 
00070 TEST_CASE( "rs_get_device_serial() validates input", "[offline] [validation]" )
00071 {
00072     REQUIRE(rs_get_device_serial(nullptr, require_error("null pointer passed for argument \"device\"")) == nullptr);
00073 }
00074 
00075 TEST_CASE( "rs_get_device_firmware_version() validates input", "[offline] [validation]" )
00076 {
00077     REQUIRE(rs_get_device_firmware_version(nullptr, require_error("null pointer passed for argument \"device\"")) == nullptr);
00078 }
00079 
00080 TEST_CASE( "rs_get_device_extrinsics() validates input", "[offline] [validation]" )
00081 {
00082     rs_extrinsics extrin;
00083     rs_get_device_extrinsics(nullptr,               RS_STREAM_DEPTH,    RS_STREAM_COLOR,    &extrin, require_error("null pointer passed for argument \"device\""));
00084                                                                                             
00085     rs_get_device_extrinsics(fake_object_pointer(), (rs_stream)-1,      RS_STREAM_COLOR,    &extrin, require_error("bad enum value for argument \"from\""));
00086     rs_get_device_extrinsics(fake_object_pointer(), RS_STREAM_COUNT,    RS_STREAM_COLOR,    &extrin, require_error("bad enum value for argument \"from\""));
00087 
00088     rs_get_device_extrinsics(fake_object_pointer(), RS_STREAM_DEPTH,    (rs_stream)-1,      &extrin, require_error("bad enum value for argument \"to\""));
00089     rs_get_device_extrinsics(fake_object_pointer(), RS_STREAM_DEPTH,    RS_STREAM_COUNT,    &extrin, require_error("bad enum value for argument \"to\""));
00090                                                                         
00091     rs_get_device_extrinsics(fake_object_pointer(), RS_STREAM_DEPTH,    RS_STREAM_COLOR,    nullptr, require_error("null pointer passed for argument \"extrin\""));
00092 }
00093 
00094 TEST_CASE( "rs_get_device_depth_scale() validates input", "[offline] [validation]" )
00095 {
00096     REQUIRE(rs_get_device_depth_scale(nullptr, require_error("null pointer passed for argument \"device\"")) == 0.0f);
00097 }
00098 
00099 TEST_CASE( "rs_device_supports_option() validates input", "[offline] [validation]" )
00100 {
00101     REQUIRE(rs_device_supports_option(nullptr,               RS_OPTION_COLOR_GAIN, require_error("null pointer passed for argument \"device\"")) == 0);
00102 
00103     REQUIRE(rs_device_supports_option(fake_object_pointer(), (rs_option)-1,        require_error("bad enum value for argument \"option\"")) == 0);
00104     REQUIRE(rs_device_supports_option(fake_object_pointer(), RS_OPTION_COUNT,      require_error("bad enum value for argument \"option\"")) == 0);
00105 }
00106 
00107 TEST_CASE( "rs_get_stream_mode_count() validates input", "[offline] [validation]" )
00108 {
00109     REQUIRE(rs_get_stream_mode_count(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\"")) == 0);
00110                                                                                 
00111     REQUIRE(rs_get_stream_mode_count(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\"")) == 0);
00112     REQUIRE(rs_get_stream_mode_count(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\"")) == 0);
00113 }
00114 
00115 TEST_CASE( "rs_get_stream_mode() validates input", "[offline] [validation]" )
00116 {
00117     int width, height, framerate; rs_format format;
00118     rs_get_stream_mode(nullptr,               RS_STREAM_DEPTH,     0, &width, &height, &format, &framerate, require_error("null pointer passed for argument \"device\""));
00119                                                                    
00120     rs_get_stream_mode(fake_object_pointer(), (rs_stream)-1,       0, &width, &height, &format, &framerate, require_error("bad enum value for argument \"stream\""));
00121     rs_get_stream_mode(fake_object_pointer(), RS_STREAM_COUNT,     0, &width, &height, &format, &framerate, require_error("bad enum value for argument \"stream\""));
00122 
00123     rs_get_stream_mode(fake_object_pointer(), RS_STREAM_DEPTH,    -1, &width, &height, &format, &framerate, require_error("out of range value for argument \"index\""));
00124     // NOTE: Index upper bound determined by rs_get_stream_mode_count(), can't validate without a live object
00125 
00126     // NOTE: width, height, format, framerate are all permitted to be null, nothing to validate
00127 }
00128 
00129 TEST_CASE( "rs_enable_stream() validates input", "[offline] [validation]" )
00130 {
00131     rs_enable_stream(nullptr, RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60, require_error("null pointer passed for argument \"device\""));
00132                                                                                               
00133     const auto RS_STREAM_MAX_ENUM = (rs_stream)0xFFFF;
00134     const auto RS_FORMAT_MAX_ENUM = (rs_format)0xFFFF;
00135     rs_enable_stream(fake_object_pointer(), (rs_stream)-1, 640, 480, RS_FORMAT_Z16, 60, require_error("bad enum value for argument \"stream\""));
00136     rs_enable_stream(fake_object_pointer(), RS_STREAM_COUNT, 640, 480, RS_FORMAT_Z16, 60, require_error("bad enum value for argument \"stream\""));
00137     rs_enable_stream(fake_object_pointer(), RS_STREAM_MAX_ENUM, 640, 480, RS_FORMAT_Z16, 60, require_error("bad enum value for argument \"stream\""));
00138                                                                                               
00139     rs_enable_stream(fake_object_pointer(), RS_STREAM_DEPTH, -1, 480, RS_FORMAT_Z16, 60, require_error("out of range value for argument \"width\""));
00140                                                                                               
00141     rs_enable_stream(fake_object_pointer(), RS_STREAM_DEPTH, 640, -1, RS_FORMAT_Z16, 60, require_error("out of range value for argument \"height\""));
00142                                                                                               
00143     rs_enable_stream(fake_object_pointer(), RS_STREAM_DEPTH, 640, 480, (rs_format)-1, 60, require_error("bad enum value for argument \"format\""));
00144     rs_enable_stream(fake_object_pointer(), RS_STREAM_DEPTH, 640, 480, RS_FORMAT_COUNT, 60, require_error("bad enum value for argument \"format\""));
00145     rs_enable_stream(fake_object_pointer(), RS_STREAM_DEPTH, 640, 480, RS_FORMAT_MAX_ENUM, 60, require_error("bad enum value for argument \"format\""));
00146                                                                 
00147     rs_enable_stream(fake_object_pointer(), RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, -1, require_error("out of range value for argument \"framerate\""));
00148 }
00149 
00150 TEST_CASE( "rs_enable_stream_preset() validates input", "[offline] [validation]" )
00151 {
00152     rs_enable_stream_preset(nullptr,               RS_STREAM_DEPTH,    RS_PRESET_BEST_QUALITY, require_error("null pointer passed for argument \"device\""));
00153                                                                        
00154     rs_enable_stream_preset(fake_object_pointer(), (rs_stream)-1,      RS_PRESET_BEST_QUALITY, require_error("bad enum value for argument \"stream\""));
00155     rs_enable_stream_preset(fake_object_pointer(), RS_STREAM_COUNT,    RS_PRESET_BEST_QUALITY, require_error("bad enum value for argument \"stream\""));
00156 
00157     rs_enable_stream_preset(fake_object_pointer(), RS_STREAM_DEPTH,    (rs_preset)-1,          require_error("bad enum value for argument \"preset\""));
00158     rs_enable_stream_preset(fake_object_pointer(), RS_STREAM_DEPTH,    RS_PRESET_COUNT,        require_error("bad enum value for argument \"preset\""));
00159 }
00160 
00161 TEST_CASE( "rs_disable_stream() validates input", "[offline] [validation]" )
00162 {
00163     rs_disable_stream(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\""));
00164                                                                  
00165     rs_disable_stream(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\""));
00166     rs_disable_stream(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\""));
00167 }
00168 
00169 TEST_CASE( "rs_is_stream_enabled() validates input", "[offline] [validation]" )
00170 {
00171     REQUIRE(rs_is_stream_enabled(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\"")) == 0);
00172                                                                             
00173     REQUIRE(rs_is_stream_enabled(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\"")) == 0);
00174     REQUIRE(rs_is_stream_enabled(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\"")) == 0);
00175 }
00176 
00177 TEST_CASE( "rs_get_stream_intrinsics() validates input", "[offline] [validation]" )
00178 {
00179     rs_intrinsics intrin;
00180     rs_get_stream_intrinsics(nullptr,               RS_STREAM_DEPTH,    &intrin, require_error("null pointer passed for argument \"device\""));
00181                                                                         
00182     rs_get_stream_intrinsics(fake_object_pointer(), (rs_stream)-1,      &intrin, require_error("bad enum value for argument \"stream\""));
00183     rs_get_stream_intrinsics(fake_object_pointer(), RS_STREAM_COUNT,    &intrin, require_error("bad enum value for argument \"stream\""));
00184 
00185     rs_get_stream_intrinsics(fake_object_pointer(), RS_STREAM_DEPTH,    nullptr, require_error("null pointer passed for argument \"intrin\""));
00186 }
00187 
00188 TEST_CASE( "rs_get_stream_format() validates input", "[offline] [validation]" )
00189 {
00190     REQUIRE(rs_get_stream_format(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\"")) == RS_FORMAT_ANY);
00191                                                                             
00192     REQUIRE(rs_get_stream_format(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\"")) == RS_FORMAT_ANY);
00193     REQUIRE(rs_get_stream_format(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\"")) == RS_FORMAT_ANY);
00194 }
00195 
00196 TEST_CASE( "rs_get_stream_framerate() validates input", "[offline] [validation]" )
00197 {
00198     REQUIRE(rs_get_stream_framerate(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\"")) == 0);
00199                                                                                
00200     REQUIRE(rs_get_stream_framerate(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\"")) == 0);
00201     REQUIRE(rs_get_stream_framerate(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\"")) == 0);
00202 }
00203 
00204 TEST_CASE( "rs_start_device() validates input", "[offline] [validation]" )
00205 {
00206     rs_start_device(nullptr, require_error("null pointer passed for argument \"device\""));
00207 }
00208 
00209 TEST_CASE( "rs_stop_device() validates input", "[offline] [validation]" )
00210 {
00211     rs_stop_device(nullptr, require_error("null pointer passed for argument \"device\""));
00212 }
00213 
00214 TEST_CASE( "rs_is_device_streaming() validates input", "[offline] [validation]" )
00215 {
00216     REQUIRE(rs_is_device_streaming(nullptr, require_error("null pointer passed for argument \"device\"")) == 0);
00217 }
00218 
00219 TEST_CASE( "rs_set_device_option() validates input", "[offline] [validation]" )
00220 {
00221     rs_set_device_option(nullptr,               RS_OPTION_COLOR_GAIN, 100, require_error("null pointer passed for argument \"device\""));
00222 
00223     rs_set_device_option(fake_object_pointer(), (rs_option)-1,        100, require_error("bad enum value for argument \"option\""));
00224     rs_set_device_option(fake_object_pointer(), RS_OPTION_COUNT,      100, require_error("bad enum value for argument \"option\""));
00225 
00226     // NOTE: Currently no validation is done for valid option ranges at the API level, though specifying an invalid option may fail at the UVC level
00227     // todo - Add some basic validation for parameter sanity (gain/exposure cannot be negative, depth clamping must be in uint16_t range, etc...)
00228 }
00229 
00230 TEST_CASE( "rs_get_device_option() validates input", "[offline] [validation]" )
00231 {
00232     REQUIRE(rs_get_device_option(nullptr,               RS_OPTION_COLOR_GAIN, require_error("null pointer passed for argument \"device\"")) == 0);
00233 
00234     REQUIRE(rs_get_device_option(fake_object_pointer(), (rs_option)-1,        require_error("bad enum value for argument \"option\"")) == 0);
00235     REQUIRE(rs_get_device_option(fake_object_pointer(), RS_OPTION_COUNT,      require_error("bad enum value for argument \"option\"")) == 0);
00236 }
00237 
00238 TEST_CASE( "rs_wait_for_frames() validates input", "[offline] [validation]" )
00239 {
00240     rs_wait_for_frames(nullptr, require_error("null pointer passed for argument \"device\""));
00241 }
00242 
00243 TEST_CASE( "rs_get_frame_timestamp() validates input", "[offline] [validation]" )
00244 {
00245     REQUIRE(rs_get_frame_timestamp(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\"")) == 0);
00246                                                                               
00247     REQUIRE(rs_get_frame_timestamp(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\"")) == 0);
00248     REQUIRE(rs_get_frame_timestamp(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\"")) == 0);
00249 }
00250 
00251 TEST_CASE( "rs_get_frame_data() validates input", "[offline] [validation]" )
00252 {
00253     REQUIRE(rs_get_frame_data(nullptr,               RS_STREAM_DEPTH,    require_error("null pointer passed for argument \"device\"")) == nullptr);
00254                                                                          
00255     REQUIRE(rs_get_frame_data(fake_object_pointer(), (rs_stream)-1,      require_error("bad enum value for argument \"stream\"")) == nullptr);
00256     REQUIRE(rs_get_frame_data(fake_object_pointer(), RS_STREAM_COUNT,    require_error("bad enum value for argument \"stream\"")) == nullptr);
00257 }
00258 
00259 TEST_CASE( "rs_free_error() gracefully handles invalid input", "[offline] [validation]" )
00260 {
00261     // Nothing to assert in this case, but calling rs_free_error() with a null pointer should not crash the program
00262     rs_free_error(nullptr);
00263 }
00264 
00265 TEST_CASE( "rs_get_failed_function() gracefully handles invalid input", "[offline] [validation]" )
00266 {
00267     REQUIRE(rs_get_failed_function(nullptr) == nullptr);
00268 }
00269 
00270 TEST_CASE( "rs_get_failed_args() gracefully handles invalid input", "[offline] [validation]" )
00271 {
00272     REQUIRE(rs_get_failed_args(nullptr) == nullptr);
00273 }
00274 
00275 TEST_CASE( "rs_get_error_message() gracefully handles invalid input", "[offline] [validation]" )
00276 {
00277     REQUIRE(rs_get_error_message(nullptr) == nullptr);
00278 }
00279 
00280 TEST_CASE( "rs_stream_to_string() produces correct output", "[offline] [validation]" )
00281 {
00282     // Valid enum values should return the text that follows the type prefix
00283     REQUIRE(rs_stream_to_string(RS_STREAM_DEPTH) == std::string("DEPTH"));
00284     REQUIRE(rs_stream_to_string(RS_STREAM_COLOR) == std::string("COLOR"));
00285     REQUIRE(rs_stream_to_string(RS_STREAM_INFRARED) == std::string("INFRARED"));
00286     REQUIRE(rs_stream_to_string(RS_STREAM_INFRARED2) == std::string("INFRARED2"));
00287     REQUIRE(rs_stream_to_string(RS_STREAM_RECTIFIED_COLOR) == std::string("RECTIFIED_COLOR"));
00288     REQUIRE(rs_stream_to_string(RS_STREAM_COLOR_ALIGNED_TO_DEPTH) == std::string("COLOR_ALIGNED_TO_DEPTH"));
00289     REQUIRE(rs_stream_to_string(RS_STREAM_DEPTH_ALIGNED_TO_COLOR) == std::string("DEPTH_ALIGNED_TO_COLOR"));
00290     REQUIRE(rs_stream_to_string(RS_STREAM_DEPTH_ALIGNED_TO_RECTIFIED_COLOR) == std::string("DEPTH_ALIGNED_TO_RECTIFIED_COLOR"));
00291 
00292     // Invalid enum values should return nullptr
00293     REQUIRE(rs_stream_to_string((rs_stream)-1) == unknown);
00294     REQUIRE(rs_stream_to_string(RS_STREAM_COUNT) == unknown);
00295 }
00296 
00297 TEST_CASE( "rs_format_to_string() produces correct output", "[offline] [validation]" )
00298 {
00299     // Valid enum values should return the text that follows the type prefix
00300     REQUIRE(rs_format_to_string(RS_FORMAT_ANY) == std::string("ANY"));
00301     REQUIRE(rs_format_to_string(RS_FORMAT_Z16) == std::string("Z16"));
00302     REQUIRE(rs_format_to_string(RS_FORMAT_DISPARITY16) == std::string("DISPARITY16"));
00303     REQUIRE(rs_format_to_string(RS_FORMAT_YUYV) == std::string("YUYV"));
00304     REQUIRE(rs_format_to_string(RS_FORMAT_RGB8) == std::string("RGB8"));
00305     REQUIRE(rs_format_to_string(RS_FORMAT_BGR8) == std::string("BGR8"));
00306     REQUIRE(rs_format_to_string(RS_FORMAT_RGBA8) == std::string("RGBA8"));
00307     REQUIRE(rs_format_to_string(RS_FORMAT_BGRA8) == std::string("BGRA8"));
00308     REQUIRE(rs_format_to_string(RS_FORMAT_Y8) == std::string("Y8"));
00309     REQUIRE(rs_format_to_string(RS_FORMAT_Y16) == std::string("Y16"));
00310     REQUIRE(rs_format_to_string(RS_FORMAT_RAW10) == std::string("RAW10"));
00311 
00312     // Invalid enum values should return nullptr
00313     REQUIRE(rs_format_to_string((rs_format)-1) == unknown);
00314     REQUIRE(rs_format_to_string(RS_FORMAT_COUNT) == unknown);
00315 }
00316 
00317 TEST_CASE( "rs_preset_to_string() produces correct output", "[offline] [validation]" )
00318 {
00319     // Valid enum values should return the text that follows the type prefix
00320     REQUIRE(rs_preset_to_string(RS_PRESET_BEST_QUALITY) == std::string("BEST_QUALITY"));
00321     REQUIRE(rs_preset_to_string(RS_PRESET_LARGEST_IMAGE) == std::string("LARGEST_IMAGE"));
00322     REQUIRE(rs_preset_to_string(RS_PRESET_HIGHEST_FRAMERATE) == std::string("HIGHEST_FRAMERATE"));
00323 
00324     // Invalid enum values should return nullptr
00325     REQUIRE(rs_preset_to_string((rs_preset)-1) == unknown);
00326     REQUIRE(rs_preset_to_string(RS_PRESET_COUNT) == unknown);
00327 }
00328 
00329 TEST_CASE( "rs_distortion_to_string() produces correct output", "[offline] [validation]" )
00330 {
00331     // Valid enum values should return the text that follows the type prefix
00332     REQUIRE(rs_distortion_to_string(RS_DISTORTION_NONE) == std::string("NONE"));
00333     REQUIRE(rs_distortion_to_string(RS_DISTORTION_MODIFIED_BROWN_CONRADY) == std::string("MODIFIED_BROWN_CONRADY"));
00334     REQUIRE(rs_distortion_to_string(RS_DISTORTION_INVERSE_BROWN_CONRADY) == std::string("INVERSE_BROWN_CONRADY"));
00335 
00336     // Invalid enum values should return nullptr
00337     REQUIRE(rs_distortion_to_string((rs_distortion)-1) == unknown);
00338     REQUIRE(rs_distortion_to_string(RS_DISTORTION_COUNT) == unknown);
00339 }
00340 
00341 TEST_CASE( "rs_option_to_string() produces correct output", "[offline] [validation]" )
00342 {
00343     // Valid enum values should return the text that follows the type prefix
00344     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_BACKLIGHT_COMPENSATION) == std::string("COLOR_BACKLIGHT_COMPENSATION")); 
00345     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_BRIGHTNESS) == std::string("COLOR_BRIGHTNESS")); 
00346     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_CONTRAST) == std::string("COLOR_CONTRAST")); 
00347     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_EXPOSURE) == std::string("COLOR_EXPOSURE")); 
00348     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_GAIN) == std::string("COLOR_GAIN")); 
00349     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_GAMMA) == std::string("COLOR_GAMMA")); 
00350     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_HUE) == std::string("COLOR_HUE")); 
00351     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_SATURATION) == std::string("COLOR_SATURATION")); 
00352     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_SHARPNESS) == std::string("COLOR_SHARPNESS")); 
00353     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_WHITE_BALANCE) == std::string("COLOR_WHITE_BALANCE")); 
00354     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_ENABLE_AUTO_EXPOSURE) == std::string("COLOR_ENABLE_AUTO_EXPOSURE")); 
00355     REQUIRE(rs_option_to_string(RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE) == std::string("COLOR_ENABLE_AUTO_WHITE_BALANCE")); 
00356 
00357     REQUIRE(rs_option_to_string(RS_OPTION_F200_LASER_POWER) == std::string("F200_LASER_POWER")); 
00358     REQUIRE(rs_option_to_string(RS_OPTION_F200_ACCURACY) == std::string("F200_ACCURACY")); 
00359     REQUIRE(rs_option_to_string(RS_OPTION_F200_MOTION_RANGE) == std::string("F200_MOTION_RANGE")); 
00360     REQUIRE(rs_option_to_string(RS_OPTION_F200_FILTER_OPTION) == std::string("F200_FILTER_OPTION")); 
00361     REQUIRE(rs_option_to_string(RS_OPTION_F200_CONFIDENCE_THRESHOLD) == std::string("F200_CONFIDENCE_THRESHOLD")); 
00362     REQUIRE(rs_option_to_string(RS_OPTION_F200_DYNAMIC_FPS) == std::string("F200_DYNAMIC_FPS")); 
00363     
00364     REQUIRE(rs_option_to_string(RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED) == std::string("R200_LR_AUTO_EXPOSURE_ENABLED")); 
00365     REQUIRE(rs_option_to_string(RS_OPTION_R200_LR_GAIN) == std::string("R200_LR_GAIN")); 
00366     REQUIRE(rs_option_to_string(RS_OPTION_R200_LR_EXPOSURE) == std::string("R200_LR_EXPOSURE")); 
00367     REQUIRE(rs_option_to_string(RS_OPTION_R200_EMITTER_ENABLED) == std::string("R200_EMITTER_ENABLED"));
00368     REQUIRE(rs_option_to_string(RS_OPTION_R200_DEPTH_UNITS) == std::string("R200_DEPTH_UNITS")); 
00369     REQUIRE(rs_option_to_string(RS_OPTION_R200_DEPTH_CLAMP_MIN) == std::string("R200_DEPTH_CLAMP_MIN")); 
00370     REQUIRE(rs_option_to_string(RS_OPTION_R200_DEPTH_CLAMP_MAX) == std::string("R200_DEPTH_CLAMP_MAX")); 
00371     REQUIRE(rs_option_to_string(RS_OPTION_R200_DISPARITY_MULTIPLIER) == std::string("R200_DISPARITY_MULTIPLIER")); 
00372     REQUIRE(rs_option_to_string(RS_OPTION_R200_DISPARITY_SHIFT) == std::string("R200_DISPARITY_SHIFT")); 
00373 
00374     // Invalid enum values should return nullptr
00375     REQUIRE(rs_option_to_string((rs_option)-1) == unknown);
00376     REQUIRE(rs_option_to_string(RS_OPTION_COUNT) == unknown);
00377 }
00378 
00379 TEST_CASE( "rs_create_context() returns a valid context", "[offline] [validation]" )
00380 {
00381     safe_context ctx;
00382     REQUIRE(rs_get_device_count(ctx, require_no_error()) >= 0);
00383 }
00384 
00385 TEST_CASE( "rs_context has singleton semantics", "[offline] [validation]" )
00386 {
00387     safe_context ctx;
00388     safe_context second_ctx;
00389     REQUIRE(second_ctx == ctx);
00390 }
00391 
00392 TEST_CASE("rs API version verification", "[offline] [validation]")
00393 {
00394     safe_context ctx;
00395     std::cout << "Librealsense API version is " << RS_API_VERSION_STR << std::endl;
00396     std::cout << "Librealsense API version number is " << RS_API_VERSION << std::endl;
00397 
00398     std::string api_ver_str(RS_API_VERSION_STR);
00399     // API  version is within [10000..999999] range
00400     REQUIRE(RS_API_VERSION > 0);
00401     REQUIRE(RS_API_VERSION <= 999999);
00402     // Version string is in ["1.0.0".. "99.99.99"] range
00403     REQUIRE(api_ver_str.size() >= 5);
00404     REQUIRE(api_ver_str.size() <= 8);
00405 }
00406 
00407 #endif /* !defined(MAKEFILE) || ( defined(OFFLINE_TEST) ) */


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39