I want to have tests, that check if the implementations are actually functional or not.
Similar proposal: #117.
How do the tests have to look?
This is really difficult, because obviously I don't want to show the complete test (e.g. generating graph, main functions, ...) on the page.
But also I don't want to have the tests in a different file.
My proposal / quick and dirty solution:
One possible solution would look like this: jakobkogler@6ac6978
I used html comments and a few little commands to indicate where the test case starts
<!--- begin test my_test_name
```cpp
#include <bits/stdc++.h>
using namespace std;
```
-->
and where it ends (because there might be multiple tests in one file).
<!---
```cpp
int main() {
TEST_EQ(1, 2);
}
```
end test -->
We can then easily parse all code lines from the between begin test
and end test
, put them into $my_test_name.cpp
files, compile them and execute them. I already implemented a quick program that does this: jakobkogler@6ac6978
This program can be executed on each clone of the project.
Travis CI / Github integration
But we can also connect it with Travis CI and integrated with Github (e.g. every Push request will automatically trigger compiling and running all tests, and we can see the results directly on the Github page).
This will look something like this: jakobkogler#1 (Notice the checkmarks / x-marks on all commits, and the all checks passed)
And here an example where the tests failed: jakobkogler#2
Details show:
Test failed!
TEST_EQ((L + R) * (R - L + 1) / 2, sum_query(L, R)): 0 != 1
Test sparse-table_sum_queries.cpp failed!
0 / 1 tests were successful.
What's you opinion?
So this is my proposal: What do you think? Like it, hate it? Ideas?
I'm not really happy with the syntax right now, maybe somebody can come up with something else. Also my implementation is currently really bad. I just want to know your opinions?