MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / test2

Function test2

code/data-structures/fenwick_tree.test.cpp:116–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116void test2() {
117 int n = 5000;
118 fenwick_tree_sq ft(n);
119 fake_fenwick_tree fft(n);
120 for (int i = 0; i < 100000; i++) {
121 int op = randint(0, 4);
122 if (op == 0) {
123 int at = randint(0, n-1);
124 assert_equal(range_query(ft, at, at), fft.rsq(at, at));
125 } else if (op == 1) {
126 int j = randint(0, n-1),
127 k = randint(j, n-1);
128 // assert_equal(ft.rsq(j, k), fft.rsq(j, k));
129 assert_equal(range_query(ft, j, k), fft.rsq(j, k));
130 } else if (op == 2) {
131 int at = randint(0, n-1);
132 assert_equal(range_query(ft, 0, at), fft.rsq(at));
133 } else if (op == 3) {
134 int j = randint(0, n-1),
135 k = randint(j, n-1),
136 v = randint(-1337, 1337);
137 // ft.update(j, k, v);
138 range_update(ft, j, k, v);
139 fft.update(j, k, v);
140 } else {
141 int at = randint(0, n-1),
142 upd = randint(-1337, 1337);
143 range_update(ft, at, at, upd);
144 // ft.update(at, upd);
145 fft.update(at, upd);
146 }
147 }
148}
149
150void test() {
151 test1();

Callers 1

testFunction · 0.70

Calls 6

range_queryFunction · 0.85
range_updateFunction · 0.85
randintFunction · 0.50
assert_equalFunction · 0.50
rsqMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected