forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-middle-ram.cpp
More file actions
73 lines (58 loc) · 1.88 KB
/
Copy pathtest-middle-ram.cpp
File metadata and controls
73 lines (58 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cassert>
#include <stdexcept>
#include "osmtypes.hpp"
#include "output-null.hpp"
#include "options.hpp"
#include "middle-ram.hpp"
#include "tests/middle-tests.hpp"
void run_tests(const options_t options, const std::string cache_type) {
{
middle_ram_t mid_ram;
output_null_t out_test(&mid_ram, options);
mid_ram.start(&options);
if (test_node_set(&mid_ram) != 0) { throw std::runtime_error("test_node_set failed with " + cache_type + " cache."); }
mid_ram.commit();
mid_ram.stop();
}
{
middle_ram_t mid_ram;
output_null_t out_test(&mid_ram, options);
mid_ram.start(&options);
if (test_nodes_comprehensive_set(&mid_ram) != 0) { throw std::runtime_error("test_nodes_comprehensive_set failed with " + cache_type + " cache."); }
mid_ram.commit();
mid_ram.stop();
}
{
middle_ram_t mid_ram;
output_null_t out_test(&mid_ram, options);
mid_ram.start(&options);
if (test_way_set(&mid_ram) != 0) { throw std::runtime_error("test_way_set failed with " + cache_type + " cache."); }
mid_ram.commit();
mid_ram.stop();
}
}
int main(int argc, char *argv[]) {
try {
options_t options;
options.cache = 1; // Non-zero cache is needed to test
options.alloc_chunkwise = ALLOC_SPARSE | ALLOC_DENSE; // what you get with optimized
run_tests(options, "optimized");
options.alloc_chunkwise = ALLOC_SPARSE;
run_tests(options, "sparse");
options.alloc_chunkwise = ALLOC_DENSE;
run_tests(options, "dense");
options.alloc_chunkwise = ALLOC_DENSE | ALLOC_DENSE_CHUNK; // what you get with chunk
run_tests(options, "chunk");
} catch (const std::exception &e) {
std::cerr << "ERROR: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "UNKNOWN ERROR" << std::endl;
return 1;
}
return 0;
}