From 510e4752fd7401a614fdaee2b65e89d19f6fdd98 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 23 Nov 2019 14:02:59 +0100 Subject: [PATCH] using parametrized tests for better coverage --- .../tests/reference/Geom/clean_stencil=1.geom | 25 ++++++ .../tests/reference/Geom/clean_stencil=2.geom | 25 ++++++ .../tests/reference/Geom/clean_stencil=3.geom | 25 ++++++ .../tests/reference/Geom/clean_stencil=4.geom | 25 ++++++ .../mirror_directions=x-y-z_reflect=True.geom | 85 +++++++++++++++++++ ...=> mirror_directions=x_reflect=False.geom} | 14 +-- .../mirror_directions=y-z_reflect=False.geom | 53 ++++++++++++ ...mirror_directions=z-x-y_reflect=False.geom | 53 ++++++++++++ python/tests/test_Geom.py | 21 ++++- 9 files changed, 311 insertions(+), 15 deletions(-) create mode 100644 python/tests/reference/Geom/clean_stencil=1.geom create mode 100644 python/tests/reference/Geom/clean_stencil=2.geom create mode 100644 python/tests/reference/Geom/clean_stencil=3.geom create mode 100644 python/tests/reference/Geom/clean_stencil=4.geom create mode 100644 python/tests/reference/Geom/mirror_directions=x-y-z_reflect=True.geom rename python/tests/reference/Geom/{mirror.geom => mirror_directions=x_reflect=False.geom} (65%) create mode 100644 python/tests/reference/Geom/mirror_directions=y-z_reflect=False.geom create mode 100644 python/tests/reference/Geom/mirror_directions=z-x-y_reflect=False.geom diff --git a/python/tests/reference/Geom/clean_stencil=1.geom b/python/tests/reference/Geom/clean_stencil=1.geom new file mode 100644 index 000000000..2fe5314fe --- /dev/null +++ b/python/tests/reference/Geom/clean_stencil=1.geom @@ -0,0 +1,25 @@ +4 header +grid a 8 b 5 c 4 +size x 8e-06 y 5e-06 z 4e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 + 1 1 2 22 2 2 1 21 + 1 1 6 26 2 2 5 25 + 1 1 10 30 2 2 9 29 + 1 1 14 34 2 2 13 33 + 1 1 18 38 2 2 17 37 + 1 1 3 23 2 2 2 22 + 1 1 7 27 2 2 6 26 + 1 1 11 31 2 2 10 30 + 1 1 15 35 2 2 14 34 + 1 1 19 39 2 2 18 38 + 1 1 4 24 2 2 3 23 + 1 1 8 28 2 2 7 27 + 1 1 12 32 2 2 11 31 + 1 1 16 36 2 2 15 35 + 1 1 20 40 2 2 19 39 + 1 1 5 25 2 2 4 24 + 1 1 9 29 2 2 8 28 + 1 1 13 33 2 2 12 32 + 1 1 17 37 2 2 16 36 + 1 1 21 41 2 2 20 40 diff --git a/python/tests/reference/Geom/clean_stencil=2.geom b/python/tests/reference/Geom/clean_stencil=2.geom new file mode 100644 index 000000000..f074fea56 --- /dev/null +++ b/python/tests/reference/Geom/clean_stencil=2.geom @@ -0,0 +1,25 @@ +4 header +grid a 8 b 5 c 4 +size x 8e-06 y 5e-06 z 4e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 + 1 1 1 2 2 2 1 1 + 1 1 1 2 2 2 2 1 + 1 1 1 6 2 2 2 5 + 1 1 1 10 2 2 2 9 + 1 1 1 14 2 2 2 13 + 1 1 1 2 2 2 2 1 + 1 1 1 2 2 2 2 1 + 1 1 1 6 2 2 2 5 + 1 1 1 10 2 2 2 9 + 1 1 1 14 2 2 2 13 + 1 1 1 3 2 2 2 2 + 1 1 1 3 2 2 2 2 + 1 1 1 7 2 2 2 6 + 1 1 1 11 2 2 2 10 + 1 1 1 15 2 2 2 14 + 1 1 1 4 2 2 2 3 + 1 1 1 4 2 2 2 3 + 1 1 1 8 2 2 2 7 + 1 1 1 12 2 2 2 11 + 1 1 1 16 2 2 2 15 diff --git a/python/tests/reference/Geom/clean_stencil=3.geom b/python/tests/reference/Geom/clean_stencil=3.geom new file mode 100644 index 000000000..63e1dce5a --- /dev/null +++ b/python/tests/reference/Geom/clean_stencil=3.geom @@ -0,0 +1,25 @@ +4 header +grid a 8 b 5 c 4 +size x 8e-06 y 5e-06 z 4e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 + 1 1 1 2 2 2 2 21 + 1 1 1 2 2 2 2 21 + 1 1 1 2 2 2 2 25 + 1 1 1 2 2 2 2 29 + 1 1 1 2 2 2 2 37 + 1 1 1 2 2 2 2 21 + 1 1 1 2 2 2 2 21 + 1 1 1 2 2 2 2 25 + 1 1 1 2 2 2 2 29 + 1 1 1 2 2 2 2 37 + 1 1 1 2 2 2 2 22 + 1 1 1 2 2 2 2 22 + 1 1 1 2 2 2 2 26 + 1 1 1 2 2 2 2 30 + 1 1 1 2 2 2 2 38 + 1 1 1 2 2 2 2 24 + 1 1 1 2 2 2 2 24 + 1 1 1 2 2 2 2 28 + 1 1 1 2 2 2 2 32 + 1 1 1 2 2 2 2 40 diff --git a/python/tests/reference/Geom/clean_stencil=4.geom b/python/tests/reference/Geom/clean_stencil=4.geom new file mode 100644 index 000000000..eef322d3f --- /dev/null +++ b/python/tests/reference/Geom/clean_stencil=4.geom @@ -0,0 +1,25 @@ +4 header +grid a 8 b 5 c 4 +size x 8e-06 y 5e-06 z 4e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 +1 1 1 2 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 2 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 +1 1 1 1 2 2 2 2 diff --git a/python/tests/reference/Geom/mirror_directions=x-y-z_reflect=True.geom b/python/tests/reference/Geom/mirror_directions=x-y-z_reflect=True.geom new file mode 100644 index 000000000..77ff709d7 --- /dev/null +++ b/python/tests/reference/Geom/mirror_directions=x-y-z_reflect=True.geom @@ -0,0 +1,85 @@ +4 header +grid a 16 b 10 c 8 +size x 1.6e-05 y 1e-05 z 8e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 + 1 1 2 22 2 2 1 21 21 1 2 2 22 2 1 1 + 1 1 6 26 2 2 5 25 25 5 2 2 26 6 1 1 + 1 1 10 30 2 2 9 29 29 9 2 2 30 10 1 1 + 1 1 14 34 2 2 13 33 33 13 2 2 34 14 1 1 + 1 1 18 38 2 2 17 37 37 17 2 2 38 18 1 1 + 1 1 18 38 2 2 17 37 37 17 2 2 38 18 1 1 + 1 1 14 34 2 2 13 33 33 13 2 2 34 14 1 1 + 1 1 10 30 2 2 9 29 29 9 2 2 30 10 1 1 + 1 1 6 26 2 2 5 25 25 5 2 2 26 6 1 1 + 1 1 2 22 2 2 1 21 21 1 2 2 22 2 1 1 + 1 1 3 23 2 2 2 22 22 2 2 2 23 3 1 1 + 1 1 7 27 2 2 6 26 26 6 2 2 27 7 1 1 + 1 1 11 31 2 2 10 30 30 10 2 2 31 11 1 1 + 1 1 15 35 2 2 14 34 34 14 2 2 35 15 1 1 + 1 1 19 39 2 2 18 38 38 18 2 2 39 19 1 1 + 1 1 19 39 2 2 18 38 38 18 2 2 39 19 1 1 + 1 1 15 35 2 2 14 34 34 14 2 2 35 15 1 1 + 1 1 11 31 2 2 10 30 30 10 2 2 31 11 1 1 + 1 1 7 27 2 2 6 26 26 6 2 2 27 7 1 1 + 1 1 3 23 2 2 2 22 22 2 2 2 23 3 1 1 + 1 1 4 24 2 2 3 23 23 3 2 2 24 4 1 1 + 1 1 8 28 2 2 7 27 27 7 2 2 28 8 1 1 + 1 1 12 32 2 2 11 31 31 11 2 2 32 12 1 1 + 1 1 16 36 2 2 15 35 35 15 2 2 36 16 1 1 + 1 1 20 40 2 2 19 39 39 19 2 2 40 20 1 1 + 1 1 20 40 2 2 19 39 39 19 2 2 40 20 1 1 + 1 1 16 36 2 2 15 35 35 15 2 2 36 16 1 1 + 1 1 12 32 2 2 11 31 31 11 2 2 32 12 1 1 + 1 1 8 28 2 2 7 27 27 7 2 2 28 8 1 1 + 1 1 4 24 2 2 3 23 23 3 2 2 24 4 1 1 + 1 1 5 25 2 2 4 24 24 4 2 2 25 5 1 1 + 1 1 9 29 2 2 8 28 28 8 2 2 29 9 1 1 + 1 1 13 33 2 2 12 32 32 12 2 2 33 13 1 1 + 1 1 17 37 2 2 16 36 36 16 2 2 37 17 1 1 + 1 1 21 41 2 2 20 40 40 20 2 2 41 21 1 1 + 1 1 21 41 2 2 20 40 40 20 2 2 41 21 1 1 + 1 1 17 37 2 2 16 36 36 16 2 2 37 17 1 1 + 1 1 13 33 2 2 12 32 32 12 2 2 33 13 1 1 + 1 1 9 29 2 2 8 28 28 8 2 2 29 9 1 1 + 1 1 5 25 2 2 4 24 24 4 2 2 25 5 1 1 + 1 1 5 25 2 2 4 24 24 4 2 2 25 5 1 1 + 1 1 9 29 2 2 8 28 28 8 2 2 29 9 1 1 + 1 1 13 33 2 2 12 32 32 12 2 2 33 13 1 1 + 1 1 17 37 2 2 16 36 36 16 2 2 37 17 1 1 + 1 1 21 41 2 2 20 40 40 20 2 2 41 21 1 1 + 1 1 21 41 2 2 20 40 40 20 2 2 41 21 1 1 + 1 1 17 37 2 2 16 36 36 16 2 2 37 17 1 1 + 1 1 13 33 2 2 12 32 32 12 2 2 33 13 1 1 + 1 1 9 29 2 2 8 28 28 8 2 2 29 9 1 1 + 1 1 5 25 2 2 4 24 24 4 2 2 25 5 1 1 + 1 1 4 24 2 2 3 23 23 3 2 2 24 4 1 1 + 1 1 8 28 2 2 7 27 27 7 2 2 28 8 1 1 + 1 1 12 32 2 2 11 31 31 11 2 2 32 12 1 1 + 1 1 16 36 2 2 15 35 35 15 2 2 36 16 1 1 + 1 1 20 40 2 2 19 39 39 19 2 2 40 20 1 1 + 1 1 20 40 2 2 19 39 39 19 2 2 40 20 1 1 + 1 1 16 36 2 2 15 35 35 15 2 2 36 16 1 1 + 1 1 12 32 2 2 11 31 31 11 2 2 32 12 1 1 + 1 1 8 28 2 2 7 27 27 7 2 2 28 8 1 1 + 1 1 4 24 2 2 3 23 23 3 2 2 24 4 1 1 + 1 1 3 23 2 2 2 22 22 2 2 2 23 3 1 1 + 1 1 7 27 2 2 6 26 26 6 2 2 27 7 1 1 + 1 1 11 31 2 2 10 30 30 10 2 2 31 11 1 1 + 1 1 15 35 2 2 14 34 34 14 2 2 35 15 1 1 + 1 1 19 39 2 2 18 38 38 18 2 2 39 19 1 1 + 1 1 19 39 2 2 18 38 38 18 2 2 39 19 1 1 + 1 1 15 35 2 2 14 34 34 14 2 2 35 15 1 1 + 1 1 11 31 2 2 10 30 30 10 2 2 31 11 1 1 + 1 1 7 27 2 2 6 26 26 6 2 2 27 7 1 1 + 1 1 3 23 2 2 2 22 22 2 2 2 23 3 1 1 + 1 1 2 22 2 2 1 21 21 1 2 2 22 2 1 1 + 1 1 6 26 2 2 5 25 25 5 2 2 26 6 1 1 + 1 1 10 30 2 2 9 29 29 9 2 2 30 10 1 1 + 1 1 14 34 2 2 13 33 33 13 2 2 34 14 1 1 + 1 1 18 38 2 2 17 37 37 17 2 2 38 18 1 1 + 1 1 18 38 2 2 17 37 37 17 2 2 38 18 1 1 + 1 1 14 34 2 2 13 33 33 13 2 2 34 14 1 1 + 1 1 10 30 2 2 9 29 29 9 2 2 30 10 1 1 + 1 1 6 26 2 2 5 25 25 5 2 2 26 6 1 1 + 1 1 2 22 2 2 1 21 21 1 2 2 22 2 1 1 diff --git a/python/tests/reference/Geom/mirror.geom b/python/tests/reference/Geom/mirror_directions=x_reflect=False.geom similarity index 65% rename from python/tests/reference/Geom/mirror.geom rename to python/tests/reference/Geom/mirror_directions=x_reflect=False.geom index 1bc4c8640..afb3bb5f8 100644 --- a/python/tests/reference/Geom/mirror.geom +++ b/python/tests/reference/Geom/mirror_directions=x_reflect=False.geom @@ -1,6 +1,6 @@ 4 header -grid a 14 b 5 c 6 -size x 1.4e-05 y 5e-06 z 6e-06 +grid a 14 b 5 c 4 +size x 1.4e-05 y 5e-06 z 4e-06 origin x 0.0 y 0.0 z 0.0 homogenization 1 1 1 2 22 2 2 1 21 1 2 2 22 2 1 @@ -23,13 +23,3 @@ homogenization 1 1 1 13 33 2 2 12 32 12 2 2 33 13 1 1 1 17 37 2 2 16 36 16 2 2 37 17 1 1 1 21 41 2 2 20 40 20 2 2 41 21 1 - 1 1 4 24 2 2 3 23 3 2 2 24 4 1 - 1 1 8 28 2 2 7 27 7 2 2 28 8 1 - 1 1 12 32 2 2 11 31 11 2 2 32 12 1 - 1 1 16 36 2 2 15 35 15 2 2 36 16 1 - 1 1 20 40 2 2 19 39 19 2 2 40 20 1 - 1 1 3 23 2 2 2 22 2 2 2 23 3 1 - 1 1 7 27 2 2 6 26 6 2 2 27 7 1 - 1 1 11 31 2 2 10 30 10 2 2 31 11 1 - 1 1 15 35 2 2 14 34 14 2 2 35 15 1 - 1 1 19 39 2 2 18 38 18 2 2 39 19 1 diff --git a/python/tests/reference/Geom/mirror_directions=y-z_reflect=False.geom b/python/tests/reference/Geom/mirror_directions=y-z_reflect=False.geom new file mode 100644 index 000000000..37d8ae18e --- /dev/null +++ b/python/tests/reference/Geom/mirror_directions=y-z_reflect=False.geom @@ -0,0 +1,53 @@ +4 header +grid a 8 b 8 c 6 +size x 8e-06 y 8.000000000000001e-06 z 6e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 + 1 1 2 22 2 2 1 21 + 1 1 6 26 2 2 5 25 + 1 1 10 30 2 2 9 29 + 1 1 14 34 2 2 13 33 + 1 1 18 38 2 2 17 37 + 1 1 14 34 2 2 13 33 + 1 1 10 30 2 2 9 29 + 1 1 6 26 2 2 5 25 + 1 1 3 23 2 2 2 22 + 1 1 7 27 2 2 6 26 + 1 1 11 31 2 2 10 30 + 1 1 15 35 2 2 14 34 + 1 1 19 39 2 2 18 38 + 1 1 15 35 2 2 14 34 + 1 1 11 31 2 2 10 30 + 1 1 7 27 2 2 6 26 + 1 1 4 24 2 2 3 23 + 1 1 8 28 2 2 7 27 + 1 1 12 32 2 2 11 31 + 1 1 16 36 2 2 15 35 + 1 1 20 40 2 2 19 39 + 1 1 16 36 2 2 15 35 + 1 1 12 32 2 2 11 31 + 1 1 8 28 2 2 7 27 + 1 1 5 25 2 2 4 24 + 1 1 9 29 2 2 8 28 + 1 1 13 33 2 2 12 32 + 1 1 17 37 2 2 16 36 + 1 1 21 41 2 2 20 40 + 1 1 17 37 2 2 16 36 + 1 1 13 33 2 2 12 32 + 1 1 9 29 2 2 8 28 + 1 1 4 24 2 2 3 23 + 1 1 8 28 2 2 7 27 + 1 1 12 32 2 2 11 31 + 1 1 16 36 2 2 15 35 + 1 1 20 40 2 2 19 39 + 1 1 16 36 2 2 15 35 + 1 1 12 32 2 2 11 31 + 1 1 8 28 2 2 7 27 + 1 1 3 23 2 2 2 22 + 1 1 7 27 2 2 6 26 + 1 1 11 31 2 2 10 30 + 1 1 15 35 2 2 14 34 + 1 1 19 39 2 2 18 38 + 1 1 15 35 2 2 14 34 + 1 1 11 31 2 2 10 30 + 1 1 7 27 2 2 6 26 diff --git a/python/tests/reference/Geom/mirror_directions=z-x-y_reflect=False.geom b/python/tests/reference/Geom/mirror_directions=z-x-y_reflect=False.geom new file mode 100644 index 000000000..5d7c23eb0 --- /dev/null +++ b/python/tests/reference/Geom/mirror_directions=z-x-y_reflect=False.geom @@ -0,0 +1,53 @@ +4 header +grid a 14 b 8 c 6 +size x 1.4e-05 y 8.000000000000001e-06 z 6e-06 +origin x 0.0 y 0.0 z 0.0 +homogenization 1 + 1 1 2 22 2 2 1 21 1 2 2 22 2 1 + 1 1 6 26 2 2 5 25 5 2 2 26 6 1 + 1 1 10 30 2 2 9 29 9 2 2 30 10 1 + 1 1 14 34 2 2 13 33 13 2 2 34 14 1 + 1 1 18 38 2 2 17 37 17 2 2 38 18 1 + 1 1 14 34 2 2 13 33 13 2 2 34 14 1 + 1 1 10 30 2 2 9 29 9 2 2 30 10 1 + 1 1 6 26 2 2 5 25 5 2 2 26 6 1 + 1 1 3 23 2 2 2 22 2 2 2 23 3 1 + 1 1 7 27 2 2 6 26 6 2 2 27 7 1 + 1 1 11 31 2 2 10 30 10 2 2 31 11 1 + 1 1 15 35 2 2 14 34 14 2 2 35 15 1 + 1 1 19 39 2 2 18 38 18 2 2 39 19 1 + 1 1 15 35 2 2 14 34 14 2 2 35 15 1 + 1 1 11 31 2 2 10 30 10 2 2 31 11 1 + 1 1 7 27 2 2 6 26 6 2 2 27 7 1 + 1 1 4 24 2 2 3 23 3 2 2 24 4 1 + 1 1 8 28 2 2 7 27 7 2 2 28 8 1 + 1 1 12 32 2 2 11 31 11 2 2 32 12 1 + 1 1 16 36 2 2 15 35 15 2 2 36 16 1 + 1 1 20 40 2 2 19 39 19 2 2 40 20 1 + 1 1 16 36 2 2 15 35 15 2 2 36 16 1 + 1 1 12 32 2 2 11 31 11 2 2 32 12 1 + 1 1 8 28 2 2 7 27 7 2 2 28 8 1 + 1 1 5 25 2 2 4 24 4 2 2 25 5 1 + 1 1 9 29 2 2 8 28 8 2 2 29 9 1 + 1 1 13 33 2 2 12 32 12 2 2 33 13 1 + 1 1 17 37 2 2 16 36 16 2 2 37 17 1 + 1 1 21 41 2 2 20 40 20 2 2 41 21 1 + 1 1 17 37 2 2 16 36 16 2 2 37 17 1 + 1 1 13 33 2 2 12 32 12 2 2 33 13 1 + 1 1 9 29 2 2 8 28 8 2 2 29 9 1 + 1 1 4 24 2 2 3 23 3 2 2 24 4 1 + 1 1 8 28 2 2 7 27 7 2 2 28 8 1 + 1 1 12 32 2 2 11 31 11 2 2 32 12 1 + 1 1 16 36 2 2 15 35 15 2 2 36 16 1 + 1 1 20 40 2 2 19 39 19 2 2 40 20 1 + 1 1 16 36 2 2 15 35 15 2 2 36 16 1 + 1 1 12 32 2 2 11 31 11 2 2 32 12 1 + 1 1 8 28 2 2 7 27 7 2 2 28 8 1 + 1 1 3 23 2 2 2 22 2 2 2 23 3 1 + 1 1 7 27 2 2 6 26 6 2 2 27 7 1 + 1 1 11 31 2 2 10 30 10 2 2 31 11 1 + 1 1 15 35 2 2 14 34 14 2 2 35 15 1 + 1 1 19 39 2 2 18 38 18 2 2 39 19 1 + 1 1 15 35 2 2 14 34 14 2 2 35 15 1 + 1 1 11 31 2 2 10 30 10 2 2 31 11 1 + 1 1 7 27 2 2 6 26 6 2 2 27 7 1 diff --git a/python/tests/test_Geom.py b/python/tests/test_Geom.py index 3c15d704e..8171a9922 100644 --- a/python/tests/test_Geom.py +++ b/python/tests/test_Geom.py @@ -51,9 +51,24 @@ class TestGeom: new = Geom.from_file(f) assert geom_equal(new,default) - def test_mirror(self,default,update,reference_dir): + @pytest.mark.parametrize('directions,reflect',[ + (['x'], False), + (['x','y','z'],True), + (['z','x','y'],False), + (['y','z'], False)]) + def test_mirror(self,default,update,reference_dir,directions,reflect): modified = copy.deepcopy(default) - modified.mirror(['x','z']) - reference = os.path.join(reference_dir,'mirror.geom') + modified.mirror(directions,reflect) + tag = 'directions={}_reflect={}'.format('-'.join(directions),reflect) + reference = os.path.join(reference_dir,'mirror_{}.geom'.format(tag)) + if update: modified.to_file(reference) + assert geom_equal(modified,Geom.from_file(reference)) + + @pytest.mark.parametrize('stencil',[(1),(2),(3),(4)]) + def test_clean(self,default,update,reference_dir,stencil): + modified = copy.deepcopy(default) + modified.clean(stencil) + tag = 'stencil={}'.format(stencil) + reference = os.path.join(reference_dir,'clean_{}.geom'.format(tag)) if update: modified.to_file(reference) assert geom_equal(modified,Geom.from_file(reference))