aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QTC.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2008-04-29 14:55:25 +0200
committerJay Berkenbilt <ejb@ql.org>2008-04-29 14:55:25 +0200
commit9a0b88bf7777c153dc46ace22db74ef24d51583a (patch)
treef567ac1cf2bf5071a611eb49323a935b6ac938ff /libqpdf/QTC.cc
downloadqpdf-9a0b88bf7777c153dc46ace22db74ef24d51583a.tar.zst
update release date to actual daterelease-qpdf-2.0
git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QTC.cc')
-rw-r--r--libqpdf/QTC.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/libqpdf/QTC.cc b/libqpdf/QTC.cc
new file mode 100644
index 00000000..b8328b2e
--- /dev/null
+++ b/libqpdf/QTC.cc
@@ -0,0 +1,46 @@
+
+#include <qpdf/QTC.hh>
+
+#include <set>
+#include <stdio.h>
+#include <qpdf/QUtil.hh>
+
+static bool tc_active(char const* const scope)
+{
+ std::string value;
+ return (QUtil::get_env("TC_SCOPE", &value) && (value == scope));
+}
+
+void QTC::TC(char const* const scope, char const* const ccase, int n)
+{
+ static std::set<std::pair<std::string, int> > cache;
+
+ if (! tc_active(scope))
+ {
+ return;
+ }
+
+ std::string filename;
+#ifdef _WIN32
+# define TC_ENV "TC_WIN_FILENAME"
+#else
+# define TC_ENV "TC_FILENAME"
+#endif
+ if (! QUtil::get_env(TC_ENV, &filename))
+ {
+ return;
+ }
+#undef TC_ENV
+
+ if (cache.count(std::make_pair(ccase, n)))
+ {
+ return;
+ }
+ cache.insert(std::make_pair(ccase, n));
+
+ FILE* tc =
+ QUtil::fopen_wrapper("open test coverage file (" + filename + ")",
+ fopen(filename.c_str(), "ab"));
+ fprintf(tc, "%s %d\n", ccase, n);
+ fclose(tc);
+}