You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. // unit test the specctra.cpp file. You can use the beautifiers below to output
  25. // exactly what you read in but beautified and without #comments. This can
  26. // then be used along with program 'diff' to test the parsing and formatting
  27. // of every element. You may have to run the first output back through to
  28. // get two files that should match, the 2nd and 3rd outputs.
  29. #include <cstdarg>
  30. #include <cstdio>
  31. #include <specctra.h>
  32. #include <common.h>
  33. using namespace DSN;
  34. int main( int argc, char** argv )
  35. {
  36. // wxString filename( wxT("/tmp/fpcroute/Sample_1sided/demo_1sided.dsn") );
  37. // wxString filename( wxT("/tmp/testdesigns/test.dsn") );
  38. // wxString filename( wxT("/tmp/testdesigns/test.ses") );
  39. wxString filename( wxT("/tmp/specctra_big.dsn") );
  40. SPECCTRA_DB db;
  41. bool failed = false;
  42. LOCALE_IO toggle; // Temporary switch the locale to standard C to r/w floats
  43. if( argc == 2 )
  44. {
  45. filename = FROM_UTF8( argv[1] );
  46. }
  47. try
  48. {
  49. // db.LoadPCB( filename );
  50. db.LoadSESSION( filename );
  51. }
  52. catch( const IO_ERROR& ioe )
  53. {
  54. fprintf( stderr, "%s\n", TO_UTF8(ioe.What()) );
  55. failed = true;
  56. }
  57. if( !failed )
  58. fprintf( stderr, "loaded OK\n" );
  59. // export what we read in, making this test program basically a beautifier
  60. // hose the beautified DSN file to stdout. If an exception occurred,
  61. // we will be outputting only a portion of what we wanted to read in.
  62. db.SetFILE( stdout );
  63. #if 0
  64. // export a PCB
  65. DSN::PCB* pcb = db.GetPCB();
  66. pcb->Format( &db, 0 );
  67. #else
  68. // export a SESSION file.
  69. DSN::SESSION* ses = db.GetSESSION();
  70. ses->Format( &db, 0 );
  71. #endif
  72. }
  73. //-----<dummy code>---------------------------------------------------
  74. // a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
  75. int BOARD::GetCopperLayerCount() const
  76. {
  77. return 0;
  78. }
  79. // a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
  80. wxString BOARD::GetLayerName( LAYER_NUM aLayer ) const
  81. {
  82. return wxEmptyString;
  83. }
  84. //-----</dummy code>--------------------------------------------------
  85. //EOF