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.

110 lines
3.3 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. SetLocaleTo_C_standard( ); // Switch the locale to standard C
  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( IO_ERROR ioe )
  53. {
  54. fprintf( stderr, "%s\n", TO_UTF8(ioe.errorText) );
  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. SetLocaleTo_Default( ); // revert to the current locale
  73. }
  74. //-----<dummy code>---------------------------------------------------
  75. // a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
  76. int BOARD::GetCopperLayerCount() const
  77. {
  78. return 0;
  79. }
  80. // a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
  81. wxString BOARD::GetLayerName( int aLayer ) const
  82. {
  83. return wxEmptyString;
  84. }
  85. //-----</dummy code>--------------------------------------------------
  86. //EOF