Fix import graphics routines and tests

The returns of KiCad file extensions on GTK contain basic regex matching
case-insensitive file extensions.  We need to match these in the
provider and tests
This commit is contained in:
Seth Hillbrand 2019-06-16 06:58:21 -07:00
parent 66e8795656
commit 1956c074ba
2 changed files with 16 additions and 3 deletions

View File

@ -27,6 +27,7 @@
#include "dxf_import_plugin.h"
#include "svg_import_plugin.h"
#include <wx/regex.h>
GRAPHICS_IMPORT_MGR::GRAPHICS_IMPORT_MGR( const TYPE_LIST& aBlacklist )
{
@ -71,10 +72,12 @@ std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> GRAPHICS_IMPORT_MGR::GetPluginByExt(
for( const auto& fileExt : fileExtensions )
{
if( aExtension.IsSameAs( fileExt, false ) )
wxRegEx extensions( fileExt, wxRE_BASIC );
if( extensions.Matches( aExtension ) )
return plugin;
}
}
return {};
}
}

View File

@ -29,6 +29,8 @@
#include <import_gfx/graphics_import_mgr.h>
#include <import_gfx/graphics_import_plugin.h>
#include <regex>
/**
* Declares a struct as the Boost test fixture.
*/
@ -38,7 +40,15 @@ static bool pluginHandlesExt( const GRAPHICS_IMPORT_PLUGIN& aPlugin, const std::
{
const auto exts = aPlugin.GetFileExtensions();
return std::find( exts.begin(), exts.end(), wxString( aExt ) ) != exts.end();
for( auto ext : exts )
{
std::regex ext_reg( ext.ToStdString() );
if( std::regex_match( aExt, ext_reg ) )
return true;
}
return false;
}
struct TYPE_TO_EXTS