You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

402 lines
23 KiB

2 years ago
  1. /*****************************************************************************
  2. *
  3. * CLIPP - command line interfaces for modern C++
  4. *
  5. * released under MIT license
  6. *
  7. * (c) 2017-2018 André Müller; foss@andremueller-online.de
  8. *
  9. * Tests: "missing" detection for required parameters
  10. * 'if_missing' error handler should be called:
  11. * - for required parameters only
  12. * - if required parameter is not matched but reachable
  13. * in terms of the previously matched parameters
  14. * - with the correct argument:
  15. * the index of the last command line argument that should
  16. * have been a match
  17. *
  18. *****************************************************************************/
  19. #include "testing.h"
  20. //-------------------------------------------------------------------
  21. template<class T>
  22. struct assignments {
  23. assignments() = default;
  24. explicit
  25. assignments(T a_, T b_, T c_, T d_, T e_, T f_, T g_, T h_, T i_,
  26. T j_, T k_, T l_, T m_, T n_, T o_, T p_, T q_, T r_)
  27. :
  28. a{a_}, b{b_}, c{c_}, d{d_}, e{e_}, f{f_}, g{g_}, h{h_}, i{i_},
  29. j{j_}, k{k_}, l{l_}, m{m_}, n{n_}, o{o_}, p{p_}, q{q_}, r{r_}
  30. {}
  31. T a = T(0), b = T(0), c = T(0), d = T(0), e = T(0), f = T(0);
  32. T g = T(0), h = T(0), i = T(0), j = T(0), k = T(0), l = T(0);
  33. T m = T(0), n = T(0), o = T(0), p = T(0), q = T(0), r = T(0);
  34. friend bool operator == (const assignments& x, const assignments& y) noexcept {
  35. return (x.a == y.a && x.b == y.b && x.c == y.c && x.d == y.d &&
  36. x.e == y.e && x.f == y.f && x.g == y.g && x.h == y.h &&
  37. x.i == y.i && x.j == y.j && x.k == y.k && x.l == y.l &&
  38. x.m == y.m && x.n == y.n && x.o == y.o && x.p == y.p &&
  39. x.q == y.q && x.r == y.r);
  40. }
  41. };
  42. using active = assignments<bool>;
  43. using counts = assignments<int>;
  44. //-------------------------------------------------------------------
  45. void test(int lineNo,
  46. const std::initializer_list<const char*> args,
  47. const active& matches,
  48. const counts& misses,
  49. counts blocked,
  50. const counts& conflicts,
  51. const counts& repeats)
  52. {
  53. using namespace clipp;
  54. //blocked @ index; compensated for arg index offset
  55. --blocked.a; --blocked.b; --blocked.c; --blocked.d; --blocked.e;
  56. --blocked.f; --blocked.g; --blocked.h; --blocked.i; --blocked.j;
  57. --blocked.k; --blocked.l; --blocked.m; --blocked.n; --blocked.o;
  58. --blocked.p; --blocked.q; --blocked.r;
  59. active a;
  60. counts m; //missing
  61. counts c; //conflicts
  62. counts r; //repeats
  63. counts b; //blocked
  64. auto cli = (
  65. option("a").set(a.a).if_blocked([&](int i){b.a=i;}).if_missing([&]{++m.a;}).if_repeated([&]{++r.a;}).if_conflicted(set(c.a,1)),
  66. required("b").set(a.b).if_blocked([&](int i){b.b=i;}).if_missing([&]{++m.b;}).if_repeated([&]{++r.b;}).if_conflicted(set(c.b,1)),
  67. repeatable(
  68. ( command("c").set(a.c).if_blocked([&](int i){b.c=i;}).if_missing([&]{++m.c;}).if_repeated([&]{++r.c;}).if_conflicted(set(c.c,1)),
  69. required("d").set(a.d).if_blocked([&](int i){b.d=i;}).if_missing([&]{++m.d;}).if_repeated([&]{++r.d;}).if_conflicted(set(c.d,1)),
  70. option("e").set(a.e).if_blocked([&](int i){b.e=i;}).if_missing([&]{++m.e;}).if_repeated([&]{++r.e;}).if_conflicted(set(c.e,1))
  71. ) |
  72. ( command("f").set(a.f).if_blocked([&](int i){b.f=i;}).if_missing([&]{++m.f;}).if_repeated([&]{++r.f;}).if_conflicted(set(c.f,1)),
  73. required("g").set(a.g).if_blocked([&](int i){b.g=i;}).if_missing([&]{++m.g;}).if_repeated([&]{++r.g;}).if_conflicted(set(c.g,1)),
  74. required("h").set(a.h).if_blocked([&](int i){b.h=i;}).if_missing([&]{++m.h;}).if_repeated([&]{++r.h;}).if_conflicted(set(c.h,1))
  75. ) |
  76. ( required("i").set(a.i).if_blocked([&](int i){b.i=i;}).if_missing([&]{++m.i;}).if_repeated([&]{++r.i;}).if_conflicted(set(c.i,1)),
  77. required("j").set(a.j).if_blocked([&](int i){b.j=i;}).if_missing([&]{++m.j;}).if_repeated([&]{++r.j;}).if_conflicted(set(c.j,1))
  78. ) |
  79. option("k").set(a.k).if_blocked([&](int i){b.k=i;}).if_missing([&]{++m.k;}).if_repeated([&]{++r.k;}).if_conflicted(set(c.k,1)) |
  80. required("l").set(a.l).if_blocked([&](int i){b.l=i;}).if_missing([&]{++m.l;}).if_repeated([&]{++r.l;}).if_conflicted(set(c.l,1))
  81. ),
  82. option("m").set(a.m).if_blocked([&](int i){b.m=i;}).if_missing([&]{++m.m;}).if_repeated([&]{++r.m;}).if_conflicted(set(c.m,1)),
  83. required("n").set(a.n).if_blocked([&](int i){b.n=i;}).if_missing([&]{++m.n;}).if_repeated([&]{++r.n;}).if_conflicted(set(c.n,1)),
  84. repeatable(
  85. required("o").set(a.o).if_blocked([&](int i){b.o=i;}).if_missing([&]{++m.o;}).if_repeated([&]{++r.o;}).if_conflicted(set(c.o,1)) |
  86. option("p").set(a.p).if_blocked([&](int i){b.p=i;}).if_missing([&]{++m.p;}).if_repeated([&]{++r.p;}).if_conflicted(set(c.p,1))
  87. ),
  88. required("q").set(a.q).if_blocked([&](int i){b.q=i;}).if_missing([&]{++m.q;}).if_repeated([&]{++r.q;}).if_conflicted(set(c.q,1)),
  89. option("r").set(a.r).if_blocked([&](int i){b.r=i;}).if_missing([&]{++m.r;}).if_repeated([&]{++r.r;}).if_conflicted(set(c.r,1))
  90. );
  91. run_wrapped_variants({ __FILE__, lineNo }, args, cli,
  92. [&] { a = active{}; m = counts{}; c = counts{}; r = counts{};
  93. b = counts{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  94. },
  95. [&] { return a == matches && m == misses && b == blocked &&
  96. c == conflicts && r == repeats; }
  97. );
  98. }
  99. //-------------------------------------------------------------------
  100. int main()
  101. {
  102. try {
  103. test(__LINE__, {""},
  104. // a b c d e f g h i j k l m n o p q r
  105. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  106. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  107. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  108. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  109. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  110. test(__LINE__, {"b", "n", "q"},
  111. // a b c d e f g h i j k l m n o p q r
  112. active{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*matched*/
  113. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*misses*/
  114. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  115. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  116. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  117. test(__LINE__, {"a"},
  118. // a b c d e f g h i j k l m n o p q r
  119. active{1,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  120. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  121. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  122. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  123. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  124. test(__LINE__, {"b"},
  125. // a b c d e f g h i j k l m n o p q r
  126. active{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  127. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  128. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  129. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  130. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  131. test(__LINE__, {"c"},
  132. // a b c d e f g h i j k l m n o p q r
  133. active{0,0, 1,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  134. counts{0,1, 0,1,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  135. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  136. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  137. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  138. test(__LINE__, {"c", "e"},
  139. // a b c d e f g h i j k l m n o p q r
  140. active{0,0, 1,0,1, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  141. counts{0,1, 0,1,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  142. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  143. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  144. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  145. test(__LINE__, {"c", "d"},
  146. // a b c d e f g h i j k l m n o p q r
  147. active{0,0, 1,1,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  148. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  149. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  150. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  151. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  152. test(__LINE__, {"c", "e", "d"},
  153. // a b c d e f g h i j k l m n o p q r
  154. active{0,0, 1,1,1, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  155. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  156. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  157. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  158. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  159. test(__LINE__, {"c", "e", "d", "b"},
  160. // a b c d e f g h i j k l m n o p q r
  161. active{0,1, 1,1,1, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  162. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  163. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  164. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  165. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  166. test(__LINE__, {"f"},
  167. // a b c d e f g h i j k l m n o p q r
  168. active{0,0, 0,0,0, 1,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  169. counts{0,1, 0,0,0, 0,1,1, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  170. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  171. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  172. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  173. test(__LINE__, {"f", "g"},
  174. // a b c d e f g h i j k l m n o p q r
  175. active{0,0, 0,0,0, 1,1,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  176. counts{0,1, 0,0,0, 0,0,1, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  177. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  178. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  179. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  180. test(__LINE__, {"f", "g", "h"},
  181. // a b c d e f g h i j k l m n o p q r
  182. active{0,0, 0,0,0, 1,1,1, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  183. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  184. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  185. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  186. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  187. test(__LINE__, {"i"},
  188. // a b c d e f g h i j k l m n o p q r
  189. active{0,0, 0,0,0, 0,0,0, 1,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  190. counts{0,1, 0,0,0, 0,0,0, 0,1, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  191. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  192. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  193. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  194. test(__LINE__, {"i", "j"},
  195. // a b c d e f g h i j k l m n o p q r
  196. active{0,0, 0,0,0, 0,0,0, 1,1, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  197. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  198. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  199. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  200. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  201. test(__LINE__, {"k"},
  202. // a b c d e f g h i j k l m n o p q r
  203. active{0,0, 0,0,0, 0,0,0, 0,0, 1, 0, 0,0, 0,0, 0,0}, /*matched*/
  204. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  205. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  206. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  207. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  208. test(__LINE__, {"l"},
  209. // a b c d e f g h i j k l m n o p q r
  210. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 1, 0,0, 0,0, 0,0}, /*matched*/
  211. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  212. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  213. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  214. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  215. test(__LINE__, {"m"},
  216. // a b c d e f g h i j k l m n o p q r
  217. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 1,0, 0,0, 0,0}, /*matched*/
  218. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  219. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  220. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  221. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  222. test(__LINE__, {"n"},
  223. // a b c d e f g h i j k l m n o p q r
  224. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 0,0}, /*matched*/
  225. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 1,0}, /*misses*/
  226. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  227. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  228. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  229. test(__LINE__, {"o"},
  230. // a b c d e f g h i j k l m n o p q r
  231. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,0, 0,0}, /*matched*/
  232. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  233. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  234. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  235. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  236. test(__LINE__, {"p"},
  237. // a b c d e f g h i j k l m n o p q r
  238. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,1, 0,0}, /*matched*/
  239. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  240. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  241. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  242. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  243. test(__LINE__, {"q"},
  244. // a b c d e f g h i j k l m n o p q r
  245. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 1,0}, /*matched*/
  246. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 0,0}, /*misses*/
  247. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  248. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  249. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  250. test(__LINE__, {"r"},
  251. // a b c d e f g h i j k l m n o p q r
  252. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,1}, /*matched*/
  253. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  254. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  255. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  256. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  257. test(__LINE__, {"o", "a", "o"},
  258. // a b c d e f g h i j k l m n o p q r
  259. active{1,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,0, 0,0}, /*matched*/
  260. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  261. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  262. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  263. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,0, 0,0} /*repeats*/);
  264. test(__LINE__, {"o", "a", "p"},
  265. // a b c d e f g h i j k l m n o p q r
  266. active{1,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,1, 0,0}, /*matched*/
  267. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  268. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  269. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  270. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  271. test(__LINE__, {"o", "p"},
  272. // a b c d e f g h i j k l m n o p q r
  273. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,1, 0,0}, /*matched*/
  274. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  275. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  276. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  277. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  278. test(__LINE__, {"o", "a", "o", "b", "p", "r", "o"},
  279. // a b c d e f g h i j k l m n o p q r
  280. active{1,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,1, 0,1}, /*matched*/
  281. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  282. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  283. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  284. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 2,0, 0,0} /*repeats*/);
  285. test(__LINE__, {"o", "o", "p", "o"},
  286. // a b c d e f g h i j k l m n o p q r
  287. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 1,1, 0,0}, /*matched*/
  288. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  289. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  290. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  291. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 2,0, 0,0} /*repeats*/);
  292. test(__LINE__, {"c", "c"},
  293. // a b c d e f g h i j k l m n o p q r
  294. active{0,0, 1,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  295. counts{0,1, 0,2,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  296. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  297. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  298. counts{0,0, 1,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  299. test(__LINE__, {"f", "f"},
  300. // a b c d e f g h i j k l m n o p q r
  301. active{0,0, 0,0,0, 1,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  302. counts{0,1, 0,0,0, 0,2,2, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  303. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  304. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  305. counts{0,0, 0,0,0, 1,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  306. test(__LINE__, {"f", "g", "f", "g", "h"},
  307. // a b c d e f g h i j k l m n o p q r
  308. active{0,0, 0,0,0, 1,1,1, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  309. counts{0,1, 0,0,0, 0,0,1, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  310. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  311. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  312. counts{0,0, 0,0,0, 1,1,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  313. test(__LINE__, {"i", "i"},
  314. // a b c d e f g h i j k l m n o p q r
  315. active{0,0, 0,0,0, 0,0,0, 1,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  316. counts{0,1, 0,0,0, 0,0,0, 0,2, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  317. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  318. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  319. counts{0,0, 0,0,0, 0,0,0, 1,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  320. test(__LINE__, {"l", "l"},
  321. // a b c d e f g h i j k l m n o p q r
  322. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 1, 0,0, 0,0, 0,0}, /*matched*/
  323. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  324. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  325. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  326. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 1, 0,0, 0,0, 0,0} /*repeats*/);
  327. test(__LINE__, {"d"},
  328. // a b c d e f g h i j k l m n o p q r
  329. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  330. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  331. counts{0,0, 0,1,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  332. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  333. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  334. test(__LINE__, {"g"},
  335. // a b c d e f g h i j k l m n o p q r
  336. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  337. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  338. counts{0,0, 0,0,0, 0,1,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  339. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  340. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  341. test(__LINE__, {"h"},
  342. // a b c d e f g h i j k l m n o p q r
  343. active{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*matched*/
  344. counts{0,1, 0,0,0, 0,0,0, 0,0, 0, 0, 0,1, 0,0, 1,0}, /*misses*/
  345. counts{0,0, 0,0,0, 0,0,1, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*blocked*/
  346. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0}, /*conflicts*/
  347. counts{0,0, 0,0,0, 0,0,0, 0,0, 0, 0, 0,0, 0,0, 0,0} /*repeats*/);
  348. }
  349. catch(std::exception& e) {
  350. std::cerr << e.what() << std::endl;
  351. return 1;
  352. }
  353. }