about summary refs log tree commit diff stats
path: root/tangle/002main.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-05 21:17:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-05 21:17:24 -0700
commitb96af395b9af2ff9df94b3e82213171f30827c8d (patch)
tree17c8c12648ccc25625e2534ec8d74fbe8f1542cc /tangle/002main.cc
parent2e3b597fe85b654e82b891c22d50754fa5a26156 (diff)
downloadmu-b96af395b9af2ff9df94b3e82213171f30827c8d.tar.gz
1276 - make C++ version the default
I've tried to update the Readme, but there are at least a couple of issues.
Diffstat (limited to 'tangle/002main.cc')
-rw-r--r--tangle/002main.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/tangle/002main.cc b/tangle/002main.cc
new file mode 100644
index 00000000..aaa91e6f
--- /dev/null
+++ b/tangle/002main.cc
@@ -0,0 +1,52 @@
+int main(int argc, const char* argv[]) {
+  if (flag("test", argc, argv))
+    return run_tests();
+  return tangle(argc, argv);
+}
+
+bool flag(const string& flag, int argc, const char* argv[]) {
+  for (int i = 1; i < argc; ++i)
+    if (string(argv[i]) == flag)
+      return true;
+  return false;
+}
+
+string flag_value(const string& flag, int argc, const char* argv[]) {
+  for (int i = 1; i < argc-1; ++i)
+    if (string(argv[i]) == flag)
+      return argv[i+1];
+  return "";
+}
+
+
+
+//// test harness
+
+int run_tests() {
+  for (unsigned long i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
+    START_TRACING_UNTIL_END_OF_SCOPE;
+    setup();
+    (*Tests[i])();
+    verify();
+  }
+
+  cerr << '\n';
+  if (Num_failures > 0)
+    cerr << Num_failures << " failure"
+         << (Num_failures > 1 ? "s" : "")
+         << '\n';
+  return Num_failures;
+}
+
+void verify() {
+  Hide_warnings = false;
+  if (!Passed)
+    ;
+  else
+    cerr << ".";
+}
+
+void setup() {
+  Hide_warnings = false;
+  Passed = true;
+}