2 * Name : test_xml_generator
3 * Author : Chris Koeritz
4 * Purpose: Checks out whether the XML writer seems to be functional.
6 * Copyright (c) 2007-$now By Author. This program is free software; you can *
7 * redistribute it and/or modify it under the terms of the GNU General Public *
8 * License as published by the Free Software Foundation; either version 2 of *
9 * the License or (at your option) any later version. This is online at: *
10 * http://www.fsf.org/copyleft/gpl.html *
13 #include <application/hoople_main.h>
14 #include <basis/functions.h>
15 #include <basis/guards.h>
16 #include <basis/astring.h>
17 #include <loggers/program_wide_logger.h>
18 #include <structures/static_memory_gremlin.h>
19 #include <structures/string_table.h>
20 #include <textual/xml_generator.h>
21 #include <unit_test/unit_base.h>
23 using namespace application;
24 using namespace basis;
25 //using namespace filesystem;
26 using namespace loggers;
27 using namespace mathematics;
28 using namespace structures;
29 using namespace textual;
30 using namespace timely;
31 using namespace unit_test;
33 #define LOG(s) EMERGENCY_LOG(program_wide_logger::get(), s)
35 class test_xml_generator : public virtual unit_base, virtual public application_shell
38 test_xml_generator() {}
39 DEFINE_CLASS_NAME("test_xml_generator");
43 #define OPERATE_XML(func, args, test_name) { \
44 outcome ret = ted.func args; \
45 ASSERT_EQUAL(ret.value(), xml_generator::OKAY, \
46 astring(test_name) + astring(": failed to ") + #func); \
49 int test_xml_generator::execute()
53 #define TEST "boilerplate"
56 attribs.add("bluebird", "petunia chowder");
57 OPERATE_XML(add_header, ("glommage", attribs), TEST);
59 OPERATE_XML(open_tag, ("Recipe"), TEST);
61 OPERATE_XML(open_tag, ("Name"), TEST);
62 OPERATE_XML(add_content, ("Lime Jello Marshmallow Cottage Cheese Surprise"),
64 OPERATE_XML(close_tag, ("Name"), TEST);
66 OPERATE_XML(open_tag, ("Description"), TEST);
67 OPERATE_XML(add_content, ("My grandma's favorite (may she rest in peace)."),
69 OPERATE_XML(close_tag, ("Description"), TEST);
72 #define TEST "stirring ingredients"
73 OPERATE_XML(open_tag, ("Ingredients"), TEST);
77 OPERATE_XML(open_tag, ("Ingredient"), TEST);
80 attribs.add("unit", "box");
81 OPERATE_XML(open_tag, ("Qty", attribs), TEST);
82 OPERATE_XML(add_content, ("1"), TEST);
83 OPERATE_XML(close_tag, ("Qty"), TEST);
85 OPERATE_XML(open_tag, ("Item"), TEST);
86 OPERATE_XML(add_content, ("lime gelatin"), TEST);
87 OPERATE_XML(close_tag, ("Item"), TEST);
89 OPERATE_XML(close_tag, ("Ingredient"), TEST);
93 OPERATE_XML(open_tag, ("Ingredient"), TEST);
96 attribs.add("unit", "g");
97 OPERATE_XML(open_tag, ("Qty", attribs), TEST);
98 OPERATE_XML(add_content, ("500"), TEST);
99 OPERATE_XML(close_tag, ("Qty"), TEST);
101 OPERATE_XML(open_tag, ("Item"), TEST);
102 OPERATE_XML(add_content, ("multicolored tiny marshmallows"), TEST);
103 OPERATE_XML(close_tag, ("Item"), TEST);
105 OPERATE_XML(close_tag, ("Ingredient"), TEST);
110 #define TEST "closing the bowl"
112 OPERATE_XML(close_tag, ("Ingredients"), TEST);
114 astring generated = ted.generate();
115 LOG(astring("XML generated is as follows:"));
118 return final_report();
121 HOOPLE_MAIN(test_xml_generator, )