Skip to content

Commit

Permalink
Port more tests to Google Test
Browse files Browse the repository at this point in the history
Port all of the arrows/core tests and a chunk of the arrows/vxl tests to
Google Test (tidying them up a bit as we go). This should take care of
all the tests that take arguments except for arrows/matlab.
  • Loading branch information
mwoehlke-kitware committed Sep 14, 2017
1 parent efdc047 commit c795139
Show file tree
Hide file tree
Showing 22 changed files with 881 additions and 981 deletions.
22 changes: 11 additions & 11 deletions arrows/core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ set( test_libraries kwiver_algo_core vital vital_vpm vital_video_metadata)
##############################
# Algorithms core plugin tests
##############################
kwiver_discover_tests(core_triangulate_landmarks test_libraries test_triangulate_landmarks.cxx)
kwiver_discover_tests(core_epipolar_geometry test_libraries test_epipolar_geometry.cxx)
kwiver_discover_tests(core_feature_descriptor_io test_libraries test_feature_descriptor_io.cxx)
kwiver_discover_tests(core_interpolate_camera test_libraries test_interpolate_camera.cxx)
kwiver_discover_tests(core_detected_object_io test_libraries test_detected_object_io.cxx)
kwiver_discover_tests(core_dynamic_configuration test_libraries test_dynamic_config.cxx)
kwiver_discover_tests(core_track_set_impl test_libraries test_track_set_impl.cxx)
kwiver_discover_tests(core_video_input_image_list test_libraries test_video_input_image_list.cxx "${kwiver_test_data_directory}" )
kwiver_discover_tests(core_video_input_pos test_libraries test_video_input_pos.cxx "${kwiver_test_data_directory}" )
kwiver_discover_tests(core_video_input_split test_libraries test_video_input_split.cxx "${kwiver_test_data_directory}" )
kwiver_discover_tests(core_video_input_filter test_libraries test_video_input_filter.cxx "${kwiver_test_data_directory}" )
kwiver_discover_gtests(core detected_object_io LIBRARIES ${test_libraries})
kwiver_discover_gtests(core dynamic_configuration LIBRARIES ${test_libraries})
kwiver_discover_gtests(core epipolar_geometry LIBRARIES ${test_libraries})
kwiver_discover_gtests(core feature_descriptor_io LIBRARIES ${test_libraries})
kwiver_discover_gtests(core interpolate_camera LIBRARIES ${test_libraries})
kwiver_discover_gtests(core track_set_impl LIBRARIES ${test_libraries})
kwiver_discover_gtests(core triangulate_landmarks LIBRARIES ${test_libraries})
kwiver_discover_gtests(core video_input_filter LIBRARIES ${test_libraries} ARGUMENTS "${kwiver_test_data_directory}")
kwiver_discover_gtests(core video_input_image_list LIBRARIES ${test_libraries} ARGUMENTS "${kwiver_test_data_directory}")
kwiver_discover_gtests(core video_input_pos LIBRARIES ${test_libraries} ARGUMENTS "${kwiver_test_data_directory}")
kwiver_discover_gtests(core video_input_split LIBRARIES ${test_libraries} ARGUMENTS "${kwiver_test_data_directory}")
54 changes: 20 additions & 34 deletions arrows/core/tests/test_detected_object_io.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*ckwg +29
* Copyright 2016 by Kitware, Inc.
* Copyright 2016-2017 by Kitware, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -33,36 +33,29 @@
* \brief test detected object io
*/

#include <test_common.h>

#include <arrows/core/detected_object_set_input_csv.h>
#include <arrows/core/detected_object_set_output_csv.h>

#include <gtest/gtest.h>

#include <iostream>
#include <sstream>
#include <memory>
#include <string>

#define TEST_ARGS ()

DECLARE_TEST_MAP();
namespace algo = kwiver::vital::algo;
namespace kac = kwiver::arrows::core;

int
main(int argc, char* argv[])
// ----------------------------------------------------------------------------
int main(int argc, char** argv)
{
CHECK_ARGS(1);

testname_t const testname = argv[1];

RUN_TEST(testname);
::testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS();
}

namespace algo = kwiver::vital::algo;
namespace kac = kwiver::arrows::core;

namespace {

// ------------------------------------------------------------------
// ----------------------------------------------------------------------------
kwiver::vital::detected_object_type_sptr
create_dot( const char* n[], const double s[] )
{
Expand All @@ -78,8 +71,7 @@ create_dot( const char* n[], const double s[] )
return std::make_shared< kwiver::vital::detected_object_type >( names, scores );
}


// ------------------------------------------------------------------
// ----------------------------------------------------------------------------
kwiver::vital::detected_object_set_sptr
make_dos()
{
Expand Down Expand Up @@ -118,9 +110,8 @@ make_dos()

} // end namespace


// ------------------------------------------------------------------
IMPLEMENT_TEST(stream_io)
// ----------------------------------------------------------------------------
TEST(detected_object_io, stream_io)
{

kac::detected_object_set_input_csv reader;
Expand All @@ -129,7 +120,6 @@ IMPLEMENT_TEST(stream_io)
// Create some detections.
auto dos = make_dos();


// setup stream
std::stringstream str;
writer.use_stream( &str );
Expand All @@ -144,18 +134,14 @@ IMPLEMENT_TEST(stream_io)
reader.use_stream( &str );
kwiver::vital::detected_object_set_sptr idos;
std::string name;
bool result = reader.read_set( idos, name );
TEST_EQUAL( "Reading the first set", result, true );
TEST_EQUAL( "Reading first name", name, "image_name_1" );

TEST_EQUAL( "Testing end of stream api", reader.at_eof(), false );
EXPECT_TRUE( reader.read_set( idos, name ) );
EXPECT_EQ( "image_name_1" , name );

result = reader.read_set( idos, name );
TEST_EQUAL( "Reading the second set", result, true );
TEST_EQUAL( "Reading first name", name, "image_name_2" );
EXPECT_EQ( false , reader.at_eof() );

result = reader.read_set( idos, name );
TEST_EQUAL( "Testing end of stream on read", result, false );
EXPECT_TRUE( reader.read_set( idos, name ) );
EXPECT_EQ( "image_name_2", name );

TEST_EQUAL( "Testing end of stream api", reader.at_eof(), true );
EXPECT_FALSE( reader.read_set( idos, name ) );
EXPECT_TRUE( reader.at_eof() );
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,39 @@
* \brief test dynamic configuration
*/

#include <test_common.h>
#include <vital/plugin_loader/plugin_manager.h>

#include <arrows/core/dynamic_config_none.h>

#include <vital/plugin_loader/plugin_manager.h>

#define TEST_ARGS ()
#include <gtest/gtest.h>

DECLARE_TEST_MAP();
namespace algo = kwiver::vital::algo;
namespace kac = kwiver::arrows::core;

int
main(int argc, char* argv[])
// ----------------------------------------------------------------------------
int main(int argc, char** argv)
{
CHECK_ARGS(1);

testname_t const testname = argv[1];

RUN_TEST(testname);
::testing::InitGoogleTest( &argc, argv );
return RUN_ALL_TESTS();
}

namespace algo = kwiver::vital::algo;
namespace kac = kwiver::arrows::core;

// ------------------------------------------------------------------
IMPLEMENT_TEST(test_api)
// ----------------------------------------------------------------------------
TEST(dynamic_configuration, test_api)
{
kac::dynamic_config_none dcn;

auto cfg = kwiver::vital::config_block::empty_config();

TEST_EQUAL( "check_configuration return", dcn.check_configuration( cfg ), true );
EXPECT_TRUE( dcn.check_configuration( cfg ) );

cfg = dcn.get_dynamic_configuration();
const auto values = cfg->available_values();
TEST_EQUAL( "empty config", values.size(), 0 );
EXPECT_EQ( 0, values.size() );
}


// ------------------------------------------------------------------
IMPLEMENT_TEST(test_loading)
// ----------------------------------------------------------------------------
TEST(dynamic_configuration, test_loading)
{
kwiver::vital::plugin_manager::instance().load_all_plugins();

Expand All @@ -83,19 +76,10 @@ IMPLEMENT_TEST(test_loading)
algo::dynamic_configuration_sptr dcs;

// Check config so it will give run-time diagnostic if any config problems are found
if ( ! algo::dynamic_configuration::check_nested_algo_configuration( "dyn_cfg", cfg ) )
{
TEST_ERROR( "Configuration check failed." );
}
EXPECT_TRUE( algo::dynamic_configuration::check_nested_algo_configuration( "dyn_cfg", cfg ) );

// Instantiate the configured algorithm
algo::dynamic_configuration::set_nested_algo_configuration( "dyn_cfg", cfg, dcs );
if ( ! dcs )
{
TEST_ERROR( "Unable to create algorithm" );
}
else
{
TEST_EQUAL( "algorithm name", dcs->impl_name(), "none" );
}
ASSERT_NE( nullptr, dcs ) << "Failed to create algorithm";
EXPECT_EQ( "none", dcs->impl_name() );
}
Loading

0 comments on commit c795139

Please sign in to comment.