Skip to content
Snippets Groups Projects
Commit f25c6528 authored by Pavel Veselý's avatar Pavel Veselý
Browse files

02: splay op.: adding more tests

parent 7d2ab623
No related branches found
No related tags found
No related merge requests found
test: splay_operation_test
test: splay_operation_test splay_operation_more_tests
./$<
./splay_operation_more_tests
CXXFLAGS=-std=c++11 -O2 -Wall -Wextra -g -Wno-sign-compare
splay_operation_test: splay_operation.h splay_operation_test.cpp test_main.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
splay_operation_more_tests: splay_operation.h splay_operation_more_tests.cpp test_main.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
clean::
rm -f splay_operation_test
......
#include <algorithm>
#include <cassert>
#include <fstream>
#include <functional>
#include <string>
#include <utility>
#include <vector>
#include "splay_operation.h"
using namespace std;
const int elements = 5000000;
void test_failed_insert() {
// Test speed
{
Tree tree;
for (int i = 0; i < elements; i++)
tree.insert(i);
for (int i = 0; i < 2*elements; i++)
tree.insert(0);
}
}
vector<pair<string, function<void()>>> tests = {
{ "failed_insert", test_failed_insert },
};
#!/usr/bin/env python3
import itertools
import math
import sys
from splay_operation import Tree, Node
def test_failed_insert():
elements = 100000
tree = Tree()
for elem in range(elements):
tree.insert(elem)
for _ in range(2*elements):
tree.insert(0)
tests = [
("failed_insert", test_failed_insert),
]
if __name__ == "__main__":
for required_test in sys.argv[1:] or [name for name, _ in tests]:
for name, test in tests:
if name == required_test:
print("Running test {}".format(name), file=sys.stderr)
test()
break
else:
raise ValueError("Unknown test {}".format(name))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment