aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-16 16:25:20 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit9d958b9db93e2009f403ad81fc7846036914f8fe (patch)
treebe210d70f13488710a445bf7a398167239d13fa2 /tests
parent43dca1cd95610a2c736e53160ecdbfb04f7a2c1e (diff)
Remove events.c, part 2
New event parsing, done at the last minute in image-hdf5.c
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt36
-rw-r--r--tests/evparse1.c73
-rw-r--r--tests/evparse2.c65
-rw-r--r--tests/evparse3.c58
-rw-r--r--tests/evparse4.c68
-rw-r--r--tests/evparse5.c64
-rw-r--r--tests/evparse6.c59
-rw-r--r--tests/evparse7.c57
8 files changed, 480 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f8de368c..78d39115 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -101,3 +101,39 @@ add_test(cellcompare_check cellcompare_check)
add_executable(polarisation_check polarisation_check.c)
target_include_directories(polarisation_check PRIVATE ${COMMON_INCLUDES})
target_link_libraries(polarisation_check ${COMMON_LIBRARIES})
+add_test(polarisation_check polarisation_check)
+
+add_executable(evparse1 evparse1.c)
+target_include_directories(evparse1 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse1 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse1 evparse1)
+
+add_executable(evparse2 evparse2.c)
+target_include_directories(evparse2 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse2 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse2 evparse2)
+
+add_executable(evparse3 evparse3.c)
+target_include_directories(evparse3 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse3 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse3 evparse3)
+
+add_executable(evparse4 evparse4.c)
+target_include_directories(evparse4 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse4 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse4 evparse4)
+
+add_executable(evparse5 evparse5.c)
+target_include_directories(evparse5 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse5 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse5 evparse5)
+
+add_executable(evparse6 evparse6.c)
+target_include_directories(evparse6 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse6 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse6 evparse6)
+
+add_executable(evparse7 evparse7.c)
+target_include_directories(evparse7 PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(evparse7 ${COMMON_LIBRARIES} -lhdf5)
+add_test(evparse7 evparse7)
diff --git a/tests/evparse1.c b/tests/evparse1.c
new file mode 100644
index 00000000..ad037841
--- /dev/null
+++ b/tests/evparse1.c
@@ -0,0 +1,73 @@
+/*
+ * evparse1.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ char **plvals;
+ int n_plvals;
+ int r = 0;
+
+ plvals = read_path_parts("cc/data123/bb//234/59", &n_plvals);
+
+ if ( plvals == NULL ) {
+ printf("read_path_parts failed\n");
+ r++;
+ }
+
+ if ( n_plvals != 3 ) {
+ printf("Wrong number of path parts\n");
+ r++;
+ }
+
+ if ( plvals == NULL ) return r;
+
+ if ( strcmp(plvals[0], "cc") != 0 ) {
+ printf("First path part is wrong\n");
+ r++;
+ }
+ if ( strcmp(plvals[1], "data123") != 0 ) {
+ printf("Second path part is wrong\n");
+ r++;
+ }
+ if ( strcmp(plvals[2], "bb") != 0 ) {
+ printf("Third path part is wrong\n");
+ r++;
+ }
+
+ return r;
+}
diff --git a/tests/evparse2.c b/tests/evparse2.c
new file mode 100644
index 00000000..1499b13b
--- /dev/null
+++ b/tests/evparse2.c
@@ -0,0 +1,65 @@
+/*
+ * evparse2.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ char **plvals;
+ int n_plvals;
+ int r = 0;
+
+ plvals = read_path_parts("bb//234/59", &n_plvals);
+
+ if ( plvals == NULL ) {
+ printf("read_path_parts failed\n");
+ r++;
+ }
+
+ if ( n_plvals != 1 ) {
+ printf("Wrong number of path parts\n");
+ r++;
+ }
+
+ if ( plvals == NULL ) return r;
+
+ if ( strcmp(plvals[0], "bb") != 0 ) {
+ printf("First path part is wrong\n");
+ r++;
+ }
+
+ return r;
+}
diff --git a/tests/evparse3.c b/tests/evparse3.c
new file mode 100644
index 00000000..ef6733d0
--- /dev/null
+++ b/tests/evparse3.c
@@ -0,0 +1,58 @@
+/*
+ * evparse3.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ char **plvals;
+ int n_plvals;
+ int r = 0;
+
+ plvals = read_path_parts("//234/59", &n_plvals);
+
+ if ( plvals == NULL ) {
+ printf("read_path_parts failed\n");
+ r++;
+ }
+
+ if ( n_plvals != 0 ) {
+ printf("Wrong number of path parts\n");
+ r++;
+ }
+
+ return r;
+}
diff --git a/tests/evparse4.c b/tests/evparse4.c
new file mode 100644
index 00000000..ca28fa24
--- /dev/null
+++ b/tests/evparse4.c
@@ -0,0 +1,68 @@
+/*
+ * evparse4.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ int *dvals;
+ int n_dvals = 99;
+ int r = 0;
+
+ dvals = read_dim_parts("cc/data123/bb//234/59", &n_dvals);
+
+ if ( n_dvals != 2 ) {
+ printf("Wrong number of dimension parts\n");
+ r++;
+ }
+
+ if ( dvals == NULL ) {
+ printf("read_dim_parts failed\n");
+ return 1;
+ }
+
+ if ( dvals[0] != 234 ) {
+ printf("First dimension part is wrong\n");
+ r++;
+ }
+ if ( dvals[1] != 59 ) {
+ printf("Second dimension part is wrong "
+ "(%i, should be %i)\n", dvals[1], 59);
+ r++;
+ }
+
+ return r;
+}
diff --git a/tests/evparse5.c b/tests/evparse5.c
new file mode 100644
index 00000000..ed0d9b85
--- /dev/null
+++ b/tests/evparse5.c
@@ -0,0 +1,64 @@
+/*
+ * evparse5.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ int *dvals;
+ int n_dvals = 99;
+ int r = 0;
+
+ dvals = read_dim_parts("cc/data123/bb//59", &n_dvals);
+
+ if ( n_dvals != 1 ) {
+ printf("Wrong number of dimension parts\n");
+ r++;
+ }
+
+ if ( dvals == NULL ) {
+ printf("read_dim_parts failed\n");
+ return 1;
+ }
+
+ if ( dvals[0] != 59 ) {
+ printf("First dimension part is wrong "
+ "(%i, should be %i)\n", dvals[0], 59);
+ r++;
+ }
+
+ return r;
+}
diff --git a/tests/evparse6.c b/tests/evparse6.c
new file mode 100644
index 00000000..235c6204
--- /dev/null
+++ b/tests/evparse6.c
@@ -0,0 +1,59 @@
+/*
+ * evparse6.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ int *dvals;
+ int n_dvals = 99;
+ int r = 0;
+
+ dvals = read_dim_parts("cc/data123/bb//", &n_dvals);
+
+ if ( n_dvals != 0 ) {
+ printf("Wrong number of dimension parts (got %i)\n",
+ n_dvals);
+ r++;
+ }
+
+ if ( dvals == NULL ) {
+ printf("read_dim_parts failed\n");
+ return 1;
+ }
+
+ return r;
+}
diff --git a/tests/evparse7.c b/tests/evparse7.c
new file mode 100644
index 00000000..7e7ff104
--- /dev/null
+++ b/tests/evparse7.c
@@ -0,0 +1,57 @@
+/*
+ * evparse7.c
+ *
+ * Check that event string parsing works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "../libcrystfel/src/image-hdf5.c"
+
+int main(int argc, char *argv[])
+{
+ char *subs;
+
+ subs = substitute_path("cc/data123/bb//234/59",
+ "/data/%/test/%/%");
+
+ if ( subs == NULL ) {
+ printf("substitute_path() failed\n");
+ return 1;
+ }
+
+ if ( strcmp(subs, "/data/cc/test/data123/bb") != 0 ) {
+ printf("Wrong substitution: got '%s'\n", subs);
+ return 1;
+ }
+
+ return 0;
+}