diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aac9e7f --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ + +BUILD_DIR ?= build +ARCHS = -arch arm64 # -arch x86_64 +CC = clang++ +CCFLAGS += -std=c++17 -finput-charset=utf-8 -fdiagnostics-show-template-tree -fno-elide-type -g $(ARCHS) --stdlib=libc++ +LD = clang++ +LDFLAGS += $(ARCHS) + +.Phony: clean all $(BUILD_DIR)/test.txt + +all: $(BUILD_DIR)/test.txt $(BUILD_DIR)/examples/example + @echo $(BUILD_DIR) + +clean: + rm -rf $(BUILD_DIR) + mkdir -p $(BUILD_DIR)/examples + @echo CC=$(CC) + @echo CCFLAGS=$(CCFLAGS) + @echo LD=$(LD) + @echo LDFLAGS=$(LDFLAGS) + +$(BUILD_DIR)/test.txt: + @echo $(BUILD_DIR)/test.txt + +$(BUILD_DIR)/examples/example: $(BUILD_DIR)/examples/example.o $(BUILD_DIR)/examples/JTest.o + $(LD) $(LDFLAGS) -o $@ $^ + +$(BUILD_DIR)/examples/example.o: examples/example.cpp examples/ClassToTest.h examples/JTest.h + $(CC) $(CCFLAGS) -c -o $@ $< + +$(BUILD_DIR)/examples/JTest.o: examples/JTest.cpp examples/JTest.h + $(CC) $(CCFLAGS) -c -o $@ $< diff --git a/examples/ClassToTest.cpp b/examples/ClassToTest.cpp new file mode 100644 index 0000000..e69de29 diff --git a/examples/ClassToTest.h b/examples/ClassToTest.h new file mode 100644 index 0000000..fbeafb0 --- /dev/null +++ b/examples/ClassToTest.h @@ -0,0 +1,3 @@ +namespace MyNS { + +} diff --git a/examples/JTest.cpp b/examples/JTest.cpp new file mode 100644 index 0000000..84a255c --- /dev/null +++ b/examples/JTest.cpp @@ -0,0 +1,33 @@ +#include "JTest.h" + +namespace JTest { + using std::wostream; + using std::endl; + + // typedef struct { + // uint32_t total; + // uint32_t skipped; + // uint32_t passed; + // uint32_t failed; + // // vector errors; + // // vector failures; + // // vector skipped; + // } testresults_t; + + testresults_t make_testresults() { + return {0, 0, 0, 0}; + } + + testresults_t make_testresults(uint32_t total, uint32_t skipped, uint32_t passed, uint32_t failed) { + return {total, skipped, passed, failed}; + } + + testresults_t add(const testresults_t& l, const testresults_t& r) { + return {l.total + r.total, l.skipped + r.skipped, l.passed + r.passed, l.failed + r.failed}; + } + + void print_test_results(const testresults_t& results, wostream& out) { + out << L"Tests: " << results.total << endl; + out << L"Failed: " << results.failed << ", Passed: " << results.passed << ", Skipped: " << results.skipped << endl; + } +} diff --git a/examples/JTest.h b/examples/JTest.h new file mode 100644 index 0000000..f54135d --- /dev/null +++ b/examples/JTest.h @@ -0,0 +1,21 @@ +#include // TODO: Maybe just ostream. + +namespace JTest { + using std::wostream; + // TODO: Consider making testresults_t a class so we can hide the vectors behind accessor methods void add(...), T get(), vector get(uint32_t index) + + typedef struct { + uint32_t total; + uint32_t skipped; + uint32_t passed; + uint32_t failed; + // vector errors; + // vector failures; + // vector skipped; + } testresults_t; + + testresults_t make_testresults(); + testresults_t make_testresults(uint32_t total, uint32_t skipped, uint32_t passed, uint32_t failed); + testresults_t add(const testresults_t&, const testresults_t&); + void print_test_results(const testresults_t&, wostream&); +} diff --git a/examples/example.cpp b/examples/example.cpp new file mode 100644 index 0000000..2793af6 --- /dev/null +++ b/examples/example.cpp @@ -0,0 +1,30 @@ +// #include +#include "JTest.h" +#include "ClassToTest.h" +#include +#include +#include + + +using namespace JTest; +using namespace MyNS; + +using std::wstring; +using std::vector; +using std::wcout; + +// const vector& might stop being a reference +testresults_t test_ClassToTest_main(int argc, const vector& argv) { + return make_testresults(); +} + +// Dummy test harness +int main(int argc, char* argv[]) { + testresults_t results = make_testresults(); + + results = add(results, test_ClassToTest_main(0, vector())); + + print_test_results(results, wcout); + + return 0; +} diff --git a/examples/example.o b/examples/example.o new file mode 100644 index 0000000..9945706 Binary files /dev/null and b/examples/example.o differ diff --git a/include/JTest.h b/include/JTest.h new file mode 100644 index 0000000..e69de29