summaryrefslogtreecommitdiff
path: root/testsuite/backend/genesys/minigtest.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-31 17:00:20 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-31 17:00:20 +0200
commit3759ce55ba79b8d3b9d8ed247a252273ee7dade3 (patch)
treed69692a274dd1c7d0672e6bb7155a0fc106f9d49 /testsuite/backend/genesys/minigtest.h
parentc8bd2513ecba169cff44c09c8058c36987357b18 (diff)
parent1687222e1b9e74c89cafbb5910e72d8ec7bfd40f (diff)
Update upstream source from tag 'upstream/1.0.28'
Update to upstream version '1.0.28' with Debian dir ec5bb298266630fc3801ff6dc0c258f6df7ba979
Diffstat (limited to 'testsuite/backend/genesys/minigtest.h')
-rw-r--r--testsuite/backend/genesys/minigtest.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/testsuite/backend/genesys/minigtest.h b/testsuite/backend/genesys/minigtest.h
new file mode 100644
index 0000000..752efe1
--- /dev/null
+++ b/testsuite/backend/genesys/minigtest.h
@@ -0,0 +1,77 @@
+/* sane - Scanner Access Now Easy.
+
+ Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
+
+ This file is part of the SANE package.
+
+ This program 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 2 of the
+ License, or (at your option) any later version.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+*/
+
+#ifndef SANE_TESTSUITE_BACKEND_GENESYS_MINIGTEST_H
+#define SANE_TESTSUITE_BACKEND_GENESYS_MINIGTEST_H
+
+#include <cstdlib>
+#include <iostream>
+
+extern size_t s_num_successes;
+extern size_t s_num_failures;
+
+inline void print_location(std::ostream& out, const char* function, const char* path,
+ unsigned line)
+{
+ out << path << ":" << line << " in " << function;
+}
+
+template<class T, class U>
+void check_equal(const T& t, const U& u, const char* function, const char* path, unsigned line)
+{
+ if (t != u) {
+ s_num_failures++;
+ std::cerr << "FAILURE at ";
+ print_location(std::cerr, function, path, line);
+ std::cerr << " :\n" << t << " != " << u << "\n\n";
+ } else {
+ s_num_successes++;
+ std::cerr << "SUCCESS at ";
+ print_location(std::cerr, function, path, line);
+ std::cerr << "\n";
+ }
+}
+
+inline void check_true(bool x, const char* function, const char* path, unsigned line)
+{
+ if (x) {
+ s_num_successes++;
+ std::cerr << "SUCCESS at ";
+ } else {
+ s_num_failures++;
+ std::cerr << "FAILURE at ";
+ }
+ print_location(std::cerr, function, path, line);
+ std::cerr << "\n";
+}
+
+
+#define ASSERT_EQ(x, y) do { check_equal((x), (y), __func__, __FILE__, __LINE__); } \
+ while (false)
+#define ASSERT_TRUE(x) do { check_true(bool(x), __func__, __FILE__, __LINE__); } \
+ while (false)
+#define ASSERT_FALSE(x) do { !check_true(bool(x), __func__, __FILE__, __LINE__); } \
+ while (false)
+
+int finish_tests();
+
+#endif