summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dev/lib/except/hpptest.hpp9
-rw-r--r--dev/lib/net/url.hpp10
-rwxr-xr-xtools/hpptest.py10
3 files changed, 29 insertions, 0 deletions
diff --git a/dev/lib/except/hpptest.hpp b/dev/lib/except/hpptest.hpp
new file mode 100644
index 0000000..5277780
--- /dev/null
+++ b/dev/lib/except/hpptest.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+/// @note Place your static asserts here, for hpptest.py!
+#ifdef SOCL_HPPTEST
+SOCL_HPPTEST_ASSERT(true);
+SOCL_HPPTEST_ASSERT(1 + 1 == 2);
+#endif
+
+/// @brief This header file is meant to be a tutorial on how to use mk.test and its macro framework.
diff --git a/dev/lib/net/url.hpp b/dev/lib/net/url.hpp
index 9a28f9b..496889c 100644
--- a/dev/lib/net/url.hpp
+++ b/dev/lib/net/url.hpp
@@ -50,5 +50,15 @@ namespace snu::net
ss_ += in;
return *this;
}
+
+ explicit operator bool()
+ {
+ return this->is_valid();
+ }
+
+ bool is_valid()
+ {
+ return ss_.size() > 0;
+ }
};
} // namespace snu::net
diff --git a/tools/hpptest.py b/tools/hpptest.py
new file mode 100755
index 0000000..2cf8e9d
--- /dev/null
+++ b/tools/hpptest.py
@@ -0,0 +1,10 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import sys, os
+
+if __name__ == '__main__':
+ if len(sys.argv) == 2:
+ os.system(f"clang++ -std=c++20 -DSOCL_HPPTEST '-DSOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]} -o a.out && cat {sys.argv[1]}")
+ print("[TEST] HEADER COMPILATION PASSES")
+