*/
"""
-guard_head = """
-#ifndef INCLUDED_PMT_UNV_INT_H
-#define INCLUDED_PMT_UNV_INT_H
-"""
-
guard_tail = """
#endif
"""
"""
+qa_includes = """
+#include <qa_pmt_unv.h>
+#include <cppunit/TestAssert.h>
+#include <pmt.h>
+#include <stdio.h>
+
+"""
+
# set srcdir to the directory that contains Makefile.am
try:
return open(os.path.join (srcdir, name), mode)
+def guard_name(filename):
+ return 'INCLUDED_' + re.sub('\.', '_', filename.upper())
+
+def guard_head(filename):
+ guard = guard_name(filename)
+ return """
+#ifndef %s
+#define %s
+""" % (guard, guard)
+
+
def do_substitution (d, input, out_file):
def repl (match_obj):
key = match_obj.group (1)
def generate_h():
template = open_src('unv_template.h.t', 'r').read()
- output = open('pmt_unv_int.h', 'w')
+ output_filename = 'pmt_unv_int.h'
+ output = open(output_filename, 'w')
output.write(header)
- output.write(guard_head)
+ output.write(guard_head(output_filename))
for tag, typ in unv_types:
d = { 'TAG' : tag, 'TYPE' : typ }
do_substitution(d, template, output)
output.write(guard_tail)
-
def generate_cc():
template = open_src('unv_template.cc.t', 'r').read()
output = open('pmt_unv.cc', 'w')
do_substitution(d, template, output)
+def generate_qa_h():
+ output_filename = 'qa_pmt_unv.h'
+ output = open(output_filename, 'w')
+ output.write(header)
+ output.write(guard_head(output_filename))
+
+ output.write('''
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_pmt_unv : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_pmt_unv);
+''')
+ for tag, typ in unv_types:
+ output.write(' CPPUNIT_TEST(test_%svector);\n' % (tag,))
+ output.write('''\
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+''')
+ for tag, typ in unv_types:
+ output.write(' void test_%svector();\n' % (tag,))
+ output.write('};\n')
+ output.write(guard_tail)
+
+def generate_qa_cc():
+ template = open_src('unv_qa_template.cc.t', 'r').read()
+ output = open('qa_pmt_unv.cc', 'w')
+ output.write(header)
+ output.write(qa_includes)
+ for tag, typ in unv_types:
+ d = { 'TAG' : tag, 'TYPE' : typ }
+ do_substitution(d, template, output)
+
+
def main():
generate_h()
generate_cc()
+ generate_qa_h()
+ generate_qa_cc()
if __name__ == '__main__':
main()