aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sdp/ao_assertions.d
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sdp/ao_assertions.d')
-rw-r--r--lib/sdp/ao_assertions.d222
1 files changed, 222 insertions, 0 deletions
diff --git a/lib/sdp/ao_assertions.d b/lib/sdp/ao_assertions.d
new file mode 100644
index 0000000..7cd1713
--- /dev/null
+++ b/lib/sdp/ao_assertions.d
@@ -0,0 +1,222 @@
+/*
+#+OPTIONS: ^:nil _:nil#+OPTIONS: ^:nil _:nil
+* sisu_assertions.d
+*/
+mixin template AssertionsOnMarkupDocumentStructure() {
+ auto assertions_doc_structure(string[string] object, uint[string] lv) {
+ if (lv["h3"] > 0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] > 0);
+ assert(lv["h3"] > 0);
+ } else if (lv["h2"] > 0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] > 0);
+ assert(lv["h3"] == 0);
+ } else if (lv["h1"] > 0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ } else if (lv["h0"] > 0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] == 0);
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ } else {
+ assert(lv["h0"] == 0);
+ assert(lv["h1"] == 0);
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ }
+ if (lv["h7"] > 0) {
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] > 0);
+ assert(lv["h7"] > 0);
+ } else if (lv["h6"] > 0) {
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] > 0);
+ assert(lv["h7"] == 0);
+ } else if (lv["h5"] > 0) {
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ } else if (lv["h4"] > 0) {
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] == 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ } else {
+ assert(lv["h4"] == 0);
+ assert(lv["h5"] == 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ }
+ if (lv["h0"] == 0) {
+ assert(lv["h0"] == 0);
+ assert(lv["h1"] == 0);
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ assert(lv["h4"] == 0);
+ assert(lv["h5"] == 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ }
+ if (lv["h1"] == 0) {
+ assert(lv["h1"] == 0);
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ }
+ if (lv["h2"] == 0) {
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ }
+ if (lv["h3"] == 0) {
+ assert(lv["h3"] == 0);
+ }
+ if (lv["h4"] == 0) {
+ assert(lv["h4"] == 0);
+ assert(lv["h5"] == 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ }
+ if (lv["h5"] == 0) {
+ assert(lv["h5"] == 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ }
+ if (lv["h6"] == 0) {
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ }
+ if (lv["h6"] == 0) {
+ assert(lv["h7"] == 0);
+ }
+ switch (to!string(object["lev"])) {
+ case "A":
+ if (lv["h0"]==0) {
+ assert(lv["h0"] == 0);
+ assert(lv["h1"] == 0);
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ assert(lv["h4"] == 0);
+ assert(lv["h5"] == 0);
+ assert(lv["h6"] == 0);
+ assert(lv["h7"] == 0);
+ } else { // (lv["h0"] >0)
+ assert(lv["h0"] == 0,"error should not enter level A a second time");
+ }
+ break;
+ case "B":
+ if (lv["h1"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] == 0); //
+ assert(lv["h2"] == 0);
+ assert(lv["h3"] == 0);
+ } else { // (lv["h1"] >0)
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0); //
+ }
+ break;
+ case "C":
+ if (lv["h2"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] == 0); //
+ assert(lv["h3"] == 0);
+ } else { // (lv["h2"] > 0)
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] > 0); //
+ }
+ break;
+ case "D":
+ if (lv["h3"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] > 0);
+ assert(lv["h3"] == 0); //
+ } else { // (lv["h3"] >0)
+ assert(lv["h0"] > 0);
+ assert(lv["h1"] > 0);
+ assert(lv["h2"] > 0);
+ assert(lv["h3"] > 0);
+ }
+ break;
+ case "1":
+ if (lv["h4"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] == 0); //
+ } else { // (lv["h4"] >0)
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0); //
+ }
+ break;
+ case "2":
+ if (lv["h5"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] == 0); //
+ } else { // (lv["h5"] >0)
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0); //
+ }
+ break;
+ case "3":
+ if (lv["h6"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] == 0); //
+ } else { // (lv["h6"] >0)
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] > 0); //
+ }
+ break;
+ case "4":
+ if (lv["h7"]==0) {
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] > 0);
+ assert(lv["h7"] == 0); //
+ } else { // (lv["h7"] >0)
+ assert(lv["h0"] > 0);
+ assert(lv["h4"] > 0);
+ assert(lv["h5"] > 0);
+ assert(lv["h6"] > 0);
+ assert(lv["h7"] > 0); //
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+mixin template AssertionsOnBlocks() {
+ auto assertions_flag_types_block_status_none_or_closed(int[string] flag_type) {
+ assert(
+ (flag_type["code"] == 0) || (flag_type["code"] == 2),
+ "code block status: none or closed");
+ assert(
+ (flag_type["poem"] == 0) || (flag_type["poem"] == 2),
+ "poem status: none or closed");
+ assert(
+ (flag_type["table"] == 0) || (flag_type["table"] == 2),
+ "table status: none or closed");
+ assert(
+ (flag_type["group"] == 0) || (flag_type["group"] == 2),
+ "group block status: none or closed");
+ assert(
+ (flag_type["block"] == 0) || (flag_type["block"] == 2),
+ "block status: none or closed");
+ }
+}
+