20#include <boost/test/unit_test.hpp> 
   24#include <wx/sstream.h> 
   33    os << 
"TABLE[ " << std::endl;
 
   34    for( 
size_t i = 0; i < aTable.size(); ++i )
 
   36        const auto& row = aTable[i];
 
   37        os << 
"  Row " << i << 
" [ ";
 
   38        for( 
size_t j = 0; j < row.size(); ++j )
 
   41            if( j < row.size() - 1 )
 
   44        os << 
"] " << std::endl;
 
   46    os << 
" ]" << std::endl;
 
 
   51static bool TableDataEqual( 
const std::vector<std::vector<wxString>>& aExpected,
 
   52                            const std::vector<std::vector<wxString>>& aActual )
 
   54    if( aExpected.size() != aActual.size() )
 
   56        BOOST_TEST_MESSAGE( 
"Row count mismatch: " << aExpected.size() << 
" != " << aActual.size() );
 
   60    for( 
size_t i = 0; i < aExpected.size(); ++i )
 
   62        BOOST_TEST_INFO_SCOPE( 
"Row " << i );
 
   63        if( aExpected[i].size() != aActual[i].size() )
 
   66        for( 
size_t j = 0; j < aExpected[i].size(); ++j )
 
   68            if( aExpected[i][j] != aActual[i][j] )
 
 
   83    std::vector<std::vector<wxString>> 
m_rows;
 
 
   91    static const std::vector<CsvRoundTripCase> testCases = {
 
   93            "Basic CSV, Double Quoted, Backslash escaped",
 
   95                { 
"Head 1", 
"Head 2", 
"Head, \"3\"" },
 
   96                { 
"Row 1 Col 1", 
"Row 1 Col 2", 
"Row 1 Col 3" }
 
   98            "\"Head 1\",\"Head 2\",\"Head, \"\"3\"\"\"\n" 
   99            "\"Row 1 Col 1\",\"Row 1 Col 2\",\"Row 1 Col 3\"\n",
 
  104    for( 
const auto& testCase : testCases )
 
  106        BOOST_TEST_INFO_SCOPE( testCase.m_name );
 
  108        wxStringOutputStream os;
 
  114        std::vector<std::vector<wxString>> readRows;
 
 
  134    static const std::vector<CsvDecodeCase> testCases = {
 
  136            "Basic TSV, Double Quoted",
 
  137            "\"Head 1\"\t\"Head 2\"\t\"Head, 3\"\n" 
  138            "\"Row 1 Col 1\"\t\"Row 1 Col 2\"\t\"Row 1 Col 3\"\n",
 
  140                { 
"Head 1", 
"Head 2", 
"Head, 3" },
 
  141                { 
"Row 1 Col 1", 
"Row 1 Col 2", 
"Row 1 Col 3" }
 
  147    for( 
const auto& testCase : testCases )
 
  149        BOOST_TEST_INFO_SCOPE( testCase.m_name );
 
  151        std::vector<std::vector<wxString>> readRows;
 
 
void WriteLines(const std::vector< std::vector< wxString > > &aRows)
Write a vector of rows to the stream.
 
bool AutoDecodeCSV(const wxString &aInput, std::vector< std::vector< wxString > > &aData)
Try to guess the format of a T/CSV file and decode it into aData.
 
std::vector< std::vector< wxString > > m_expectedRows
 
std::vector< std::vector< wxString > > m_rows
 
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
 
BOOST_AUTO_TEST_CASE(BasicRoundTrips)
 
static bool TableDataEqual(const std::vector< std::vector< wxString > > &aExpected, const std::vector< std::vector< wxString > > &aActual)
 
std::ostream & boost_test_print_type(std::ostream &os, const std::vector< std::vector< T > > &aTable)
Define a stream function for logging this type.
 
BOOST_AUTO_TEST_SUITE_END()
 
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))
 
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
 
wxString result
Test unit parsing edge cases and error handling.
 
BOOST_CHECK_EQUAL(result, "25.4")