Got build/execute/report working.
This commit is contained in:
32
Makefile
Normal file
32
Makefile
Normal file
@@ -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 $@ $<
|
||||
0
examples/ClassToTest.cpp
Normal file
0
examples/ClassToTest.cpp
Normal file
3
examples/ClassToTest.h
Normal file
3
examples/ClassToTest.h
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace MyNS {
|
||||
|
||||
}
|
||||
33
examples/JTest.cpp
Normal file
33
examples/JTest.cpp
Normal file
@@ -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<error_t> errors;
|
||||
// // vector<testfailure_t> failures;
|
||||
// // vector<testmethod_t> 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;
|
||||
}
|
||||
}
|
||||
21
examples/JTest.h
Normal file
21
examples/JTest.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <iostream> // 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<T> get(uint32_t index)
|
||||
|
||||
typedef struct {
|
||||
uint32_t total;
|
||||
uint32_t skipped;
|
||||
uint32_t passed;
|
||||
uint32_t failed;
|
||||
// vector<error_t> errors;
|
||||
// vector<testfailure_t> failures;
|
||||
// vector<testmethod_t> 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&);
|
||||
}
|
||||
30
examples/example.cpp
Normal file
30
examples/example.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// #include <JTest.h>
|
||||
#include "JTest.h"
|
||||
#include "ClassToTest.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
|
||||
|
||||
using namespace JTest;
|
||||
using namespace MyNS;
|
||||
|
||||
using std::wstring;
|
||||
using std::vector;
|
||||
using std::wcout;
|
||||
|
||||
// const vector<wstring>& might stop being a reference
|
||||
testresults_t test_ClassToTest_main(int argc, const vector<wstring>& 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<wstring>()));
|
||||
|
||||
print_test_results(results, wcout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
examples/example.o
Normal file
BIN
examples/example.o
Normal file
Binary file not shown.
0
include/JTest.h
Normal file
0
include/JTest.h
Normal file
Reference in New Issue
Block a user