Commit Graph

122 Commits

Author SHA1 Message Date
John Beard edc73de023 Pcbnew: ignore start values in "first available" grid numbering
The using the "first available" numbering option, force an
artifical linear numbering scheme starting at '1'.

Start the pad name provider at the 0'th pad index.

Also adds a few related tests and adjusts tests affected by
this change to reflect that the offset still applies.

This can be expanded in future to be more general by skipping
pad (which would allow a custom start and numbering scheme
while still avoiding duplication), but for now,
this does what the UI says and avoids string changes in 5.1rc.

Fixes: lp:1814918
* https://bugs.launchpad.net/kicad/+bug/1814918

Fixes: lp:1814917
* https://bugs.launchpad.net/kicad/+bug/1814917
2019-02-08 12:15:02 +00:00
jean-pierre charras 507229809c Fix a compil issue in test_lib_table.cpp, with some boost versions. 2019-02-06 09:18:57 +01:00
John Beard 0c6ec7dbb3 LIB_TABLE_BASE: Const and unsigned fixes
* Make LIB_TABLE_BASE::GetCount() return unsigned. This is more
  consistent with the behaviour of STL containers (especially the
  boost::ptr_vector this is really accessing). Sadly
  wxGridTableBase() forces an int, so a cast is still required
  at the WX interface.
* Make LIB_TABLE_BASE::At() return a reference. First, this is more
  consistent with normal STL indexing operator[]'s, and secondly, it
  allows an idiomatic const index method (so you can access const
  LIB_TABLE_ROWs from a const LIB_TABLE_BASE).

The motivation is to allow use of this class and LIB_TABLE_ROW
in a test program, where the LIB_TABLE_BASE is const.
2019-02-05 08:49:52 -08:00
John Beard 84d79ec10d QA: LIB_TABLE tests
Some basic tests on LIB_TABLE and LIB_TABLE_ROW that demonstrate
the behaviour of fallbacks and various access methods.

Also add a few LIB_TABLE_BASE comments and changed some NULLs to
nullptr.
2019-02-04 19:44:54 -08:00
John Beard e6a6266f3d Build: libpolygon provides its own includes
Libpolygon can provide its own includes via target_include_dirs PUBLIC.
This means any linking targets do not need to specifiy them manually.

As common requires polygon, the polygon dep is also now no longer
required downstream of libcommon, as it's transisitvely implied
by libcommon's target_link_libraries.

This resolves a circular dependency previously detected and also
simplifies CMakeLists.
2019-02-04 19:29:31 -08:00
John Beard bb2ae8e13b Bitmaps: move bitmap defs to bitmaps library
The bitmap definitions (BITMAP_DEF and so on) do not
have any dependencies on other libs, including WX. This
means the bitmaps library can be isolated from the other
dependencies.

Common now depends on bitmaps, and libraries that depend
on common can pick it up from the common target_link_libraries,
as it is PUBLIC. This means a lot of targets no longer
need manual bitmap linkage.

This avoids a circular dependency that was previously reported
by static analysis.

Avoiding pulling in WX and other headers into the include
tree of each bitmap .cpp is a huge speed up (around 10x) in
compilation, and the generated static library is also 10x
smaller (20MB vs 200MB)

Add common as a link library to pnsrouter,connectivity.
THese library do still use common code (including bitmaps,
via base_screen.h) and this allows them to pick up the libcommon
includes correctly.
2019-02-04 19:29:31 -08:00
John Beard bb4d3faad7 QA: Add Distance, Collide, Collinear tests on SEG
SEG collisions and distances are a fundamental part of SHAPE collision testing
and are therefore critical for DRC correctness.

Also a few Collinear tests.
2019-02-03 06:57:37 +01:00
John Beard 0415c89c5b Fix broken GetReferencePrefix function
This function was incorrectly processing refdeses like "U1000".

Change the algorithm to a simpler STL-compatible one and
update the tests.

Fixes: lp:1813669
* https://bugs.launchpad.net/kicad/+bug/1813669
2019-01-30 15:41:36 -08:00
John Beard 88f9f6f072 Break out ref-des-centric functions to own header
This breaks the following functions out to a general-purposed refdes utils
header:

* MODULE::GetReferencePrefix()
* kicad_string.h RefDesStringCompare()

This acheives:

* Slimming of MODULE interface
* Placement of refdes code in common rather than pcbnew
** Testing of this code in qa_common
* Tighter and smaller includes for code that only needed refdes functions

Note: there are failing tests commited (as expected failures). These
are the cause of lp:1813669 and will be fixed as a follow-up commit.
2019-01-30 15:41:36 -08:00
John Beard dc20521cb9 Break out getTrailingInt from MODULE
This is not logic specific to MODULE. Breaking it out to
kicad_string.h acheives:

* Slimming of the MODULE interface
* Enables reuse of the function
* Enables testing of the function

Also add a test under qa_common for this function.
2019-01-30 15:41:36 -08:00
John Beard 453a91f661 Pcbnew: arrays skip existing names
The current module cannot be queried for existing pads as we
add them (because we never commit, until we finish the whole array).

Instead, pre-gather the names and check as we add, skipping any existing
names.

Note: this will not prevent arrays becoming "mis-ordered", but there
is not a lot we can do to prevent all possible errors.

Fixes: 1808706
* https://bugs.launchpad.net/kicad/+bug/1808706

The same principle could be used to skip existing ref-des'es on PCBs.
2019-01-30 15:41:35 -08:00
John Beard 5504981d00 Separate ARRAY_OPTIONS to own class in common
The geometry and numbering logic is separate to the dialog, and
can be separated for clearer logic and better testability.

Moreover, refactor it to avoid any dependency on pcbnew
classes, so it can be move to common for potential re-use in
eeschema and friends in future.

Also convert all wxPoint logic in these classes to VECTOR2I and
fix some function visibilities.

Add some unit tests of the ARRAY_OPTIONS geometry and numbering.
2019-01-30 15:41:35 -08:00
Jeff Young ca0164aa07 Unify library browser terminology.
Fixes: lp:1813882
* https://bugs.launchpad.net/kicad/+bug/1813882
2019-01-30 19:52:15 +00:00
John Beard 9a41fd060b QA: Account for eeschema tests unit rounding 2019-01-30 11:55:11 +01:00
John Beard 8e75f6029c QA: Mark failing SHAPE_POLY_SET tests as expected failures
This allows the tests to remain sensitive to other errors.

When SHAPE_POLY_SET is fixed, these expected failures should be
removed.
2019-01-30 11:55:10 +01:00
John Beard 33bc74a4a2 QA: Tidy qa_utils headers
Move into own include directory for clarity. Also allows qa_utils
to use its own private headers in qa/qa_utils without exposing them
through the target_include_directories directive.
2019-01-29 18:16:00 -05:00
John Beard 47ec2fd5ba QA: Add some tests on SHAPE_POLY_SET::Distance
These tests pick up the bug fixed in: 90178eb681
(as it is already fixed there is no failure).
2019-01-29 18:12:06 -05:00
John Beard 55fcbddde8 QA: Fix faulty test of SHAPE_POLY_SET Collision
This test assumed points on a edge are counted as colliding.
This is not true: points on an edge are NOT counted at inside
the poly_set.

THe test does still consider points on a *hole* edge as collisions.
The API to SHAPE_POLY_SET is unclear on if this is correct.
2019-01-29 18:06:16 -05:00
John Beard 9bd7ea815c QA: Centralise BOARD reading functions in pcbnew_utils
Several pcbnew_tools utilities read a file from the command line.
Instead of replicating this code, centralise the code in
qa_pcbnew_utils, which allows simpler reuse.

THe utilities are:

* polygon_triangulation
* polygon_generator
* drc_tool

pcb_parser keeps its own function, as that is the focus of the tool,
and its likely to have its own instrumention.

This also adds the ability to read from stdin for the above tools,
which means fuzz testers could theoretically work with them, and it
also can make life easier if you can pipe a board to the executable
directly.
2019-01-29 08:16:02 -05:00
John Beard adddc41bc5 QA: Reinstate polygon_triangulation utility
This utility has been disabled since the eeschema GAL merge. It
can be reinstated as part of the qa_pcbnew_tools framework.
2019-01-29 08:15:51 -05:00
John Beard 11745f8f44 QA: Move contents qa_shape_poly_set_refactor to qa_common
The "refactor" element of qa_shape_poly_set_refactor has been
previously removed, so these tests are now just regular tests on
libcommon classes. These can therefore be moved to qa_common
and the qa_shape_poly_set_refactor unit test suit can finally be
totally removed.
2019-01-29 08:15:44 -05:00
John Beard e4b4230bcf QA: Put UTILITY_PROGRAM in KI_TEST
Also expand some documentation of some other KI_TEST functions.
2019-01-29 08:15:37 -05:00
John Beard b690658972 QA: Add coroutine unit test
This adds a simple unit test to qa_common to check coroutines
produce expected events in the right order.

This is an automated analogue to the user-facing tool in
qa/common_tools.
2019-01-24 13:01:44 -05:00
John Beard 6729842441 QA: Reinstate polygon_generator as a sub-util of qa_pcbnew_tools
This program has been disabled for some time, but it's not
broken (even if the CMake was!).

Merging into the pcbnew_tools QA program reduces the CMake burden
and puts this tool in the same place as the others.
2019-01-24 13:01:44 -05:00
jean-pierre charras ebdc383cc3 QA test: add missing boost library (boost system).
This missing lib created link issues on some systems.
2019-01-24 09:03:58 +01:00
John Beard e8afb14046 QA: Move PCB parse util to combined tools exec
This means all the current Pcbnew utilities are all in a single
executable.

The tool is now run by:

$ qa/pcbnew_tools/qa_pcbnew_tools pcb_parser <same arguments as before>
2019-01-23 13:27:52 -05:00
John Beard d7563c55c4 QA: Pcbnew utility tools: DRC tool
Add a tool that allows a user to run DRC functions
on a given KiCad PCB file.

The first available functions are the courtyard functions.

Also move most of the utility program logic into qa_util for
better reusability.
2019-01-23 13:27:52 -05:00
John Beard 8297ab24e4 DRC: Break out courtyard overlap function
Introduce the concept of a DRC_PROVIDER which allows
to separate the various DRC functions to their own
areas. This allows, amongst other things, a slimmer core
DRC class, and allows DRC functions to be separately testable.

The courtyard DRCs (overlap, missing and malformed)
are the first victims, so instrumentation can be added to this function.

Add some unit tests on this DRC function, as well a few re-usable PCB-based
utility functions in a library (qa_pcbnew_utils) that could be shared between
unit tests and other utilities.
2019-01-23 13:27:52 -05:00
John Beard bb2e402bc7 QA: Move io_benchmark into common_tools 2019-01-22 09:04:38 -05:00
John Beard 267e17d539 QA: Add a generic utility tool executable.
The intention here is to make it possible to wrap up many of the
KiCad utility tools into a single executable. This reduces link times
as well as the duplication of CMake files needed to build very
similar tools.

This particular tool should be suitable for any code in common,
code in pcbnew and other end-executables probalby will need an
analagous version linked to the relevant kiface.

The first tool is the coroutine_example.cpp test case, which
can be useful when learning, debugging or porting the coroutine
infrastructure.
2019-01-22 09:04:38 -05:00
John Beard f5144eb5cf Revert "Try to fix a compil issue in qa test"
This reverts commit decc7ed888.

This compilation options (-fpermissive) is no longer needed,
as the code that caused the warnings on GCC <7 is no longer
present.

The reason this error was GCC bug #56480 [1], which disallowed
the following (valid, in C++11) syntax:

template<> struct namespace_a::namespace_b::a_struct<TYPE>
{...}

And instead insisted on:

namespace namespace_a {
namespace namespace_b {
    template<> struct a_struct<TYPE>
    {...}
}
}

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
2019-01-12 07:53:56 +01:00
John Beard 97a37a74f8 QA: Use free operator<< for Boost test logging
An unhappy conjunction of GCC bug #56480 [1] and Boost having
different namespaces for the print_log_value make it quite
ugly to support this method.

For the limited purposes of the unit tests, a free function in
the unit_test_utils header (in the absence of any implementation
in the main libraries) will do, even if it is a little intrusive.

From Boost 1.64 onwards, the customisation point boost_test_print_type
is avaiable, and anyt print functions should be transitioned over to
that method when the minimum Boost version is 1.64 or higher.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
2019-01-12 07:53:56 +01:00
jean-pierre charras decc7ed888 Try to fix a compil issue in qa test 2019-01-11 18:13:58 +01:00
jean-pierre charras bac31d0911 Revert "qa test: fix a compil issue by modifying the way BOOST_PRINT namespace is used in geometry.h"
This reverts commit bd4222cc84.

the commit bd4222cc did not fix compil issues with some compilers
2019-01-11 16:53:16 +01:00
jean-pierre charras bd4222cc84 qa test: fix a compil issue by modifying the way BOOST_PRINT namespace is used in geometry.h 2019-01-11 10:58:38 +01:00
John Beard d6f4f3aca0 Geom: Account for quadrant points in arc bbox calc
This means arcs that pass though quadrant points (multiple of
0, 90, 180, 270 degrees) include these points in the bbox.
2019-01-10 07:52:25 -05:00
John Beard dc71a73178 QA: Add unit test of SHAPE_ARC
Test a few "centre-point-angle" cases and add some
generic geom code for testing vectors and boxes are within
tolerance (since rounding often creeps in).

Much of the arc-checking code will be useful to other
construction methods (e.g. point-point-point).

There are expected failures for the bbox code when
the arc passes though, but does not end on, a quadrant point
(0, 90, 180, 270). This is due to a defective
implementation of SHAPE_ARC::BBox() that does not take
into account the quadrant points. This will be fixed
as a follow-up.
2019-01-10 07:52:25 -05:00
Seth Hillbrand da295a355f qa: Moving eeschema qa to main qa folder 2019-01-09 21:43:23 -08:00
John Beard 658cc8fd96 Wildcards: unify handling of all files wildcards
Use the AddFileExtListToFilter() to also generate the
wildcard for "all files". This is because:

* Users can use AddFileExtListToFilter for the all files WC
  with the same interface as for any other extensions.
* Users do not need to worry about wxGetTranslation, as the
  _() is applied in the same way as the other *Wildcard() helpers,
  and it is a function just like the others, so it is consistent
* There is a testable interface to document the expected result.
  The test is added.
2019-01-09 08:57:42 -05:00
John Beard dd313d4d47 Wildcards: use vectors instead of varargs + tests
Varargs make it very hard to pass strings in flexibly
when they (and the number of them) are not known
at compile time.

For example, this allows up to now amalgamate the "single
ext" and "multiple ext" unit tests.
2019-01-09 08:57:35 -05:00
John Beard f86d953c80 QA: unit tests for file ext filters
This adds a unit test for the recent AddFileExtListToFilter
to demonstrate how to use it and the expected output.

The unit tests are a bit clunky, as the vararg approach cannot
work winth strings passed at runtime.
2019-01-09 08:57:29 -05:00
Seth Hillbrand 90ad240660 units: Move common units and add tests
Centralizing duplicate code from Eeschema and pcbnew and adding unit
tests
2019-01-08 09:29:32 -08:00
jean-pierre charras 419718b596 Remove a useless qa test.
It was added when refactoring the SHAPE_POLY_SET class, ande replace any use of CPolyLine class inside Kicad code.
the CPolyLine related code is now not used.
So this test nowadays makes no longer sense.
2019-01-07 20:24:11 +01:00
John Beard 1ae6fc78a6 QA: Add pcbnew unit tests CMake subdir
Also modify the linkage of kiface objects, as this is not
supported by older CMake versions.

This was accidentally removed with the reversion of the application
of the wrong patch (8f11a2133).

QA: fix object files
2019-01-07 15:14:37 +01:00
John Beard 2d6f8a97b0 QA: Add some more Boost version guards
Some functions aren't defined on Boost < 1.59, which is
sadly inclusive of the Ubuntu LTSs.

Make some guards so you can still use these on the newer
Boosts with some useful fallback where possible.
2019-01-06 16:18:13 -08:00
Seth Hillbrand 8f11a2133e Revert "QA: Add a generic utility tool executable."
This reverts commit 502306314e.
2019-01-06 16:17:44 -08:00
John Beard ec91329da0 Pcbnew: Array tool should not number NPTHs
Devolve the logic as to whether a pad should be numbered or not
to a pad utility function. Add a very simplistic test for this
function (demonstrating how to test BOARD_ITEMs in general).

Fixes: lp:1804787
* https://bugs.launchpad.net/kicad/+bug/1804787
2019-01-06 07:55:49 -08:00
John Beard 81bac449d3 QA: Add unit tests on the Pcbnew library
This now allows code under /pcbnew to be tested.

A first test of the GRAPHICS_IMPORT_MGR is added.
2019-01-06 07:55:36 -08:00
John Beard 502306314e QA: Add a generic utility tool executable.
The intention here is to make it possible to wrap up many of the
KiCad utility tools into a single executable. This reduces link times
as well as the duplication of CMake files needed to build very
similar tools.

This particular tool should be suitable for any code in common,
code in pcbnew and other end-executables probalby will need an
analagous version linked to the relevant kiface.

The first tool is the coroutine_example.cpp test case, which
can be useful when learning, debugging or porting the coroutine
infrastructure.
2019-01-06 07:51:23 -08:00
John Beard 157519d722 Libeval: leading + is a sign, not an operator
Due to (presumably) a different lemon version,
there are some formatting changes in the grammar,
and some manual debug left in has been removed.
2018-12-03 08:39:30 +01:00