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

Function test1_fake

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

Source from the content-addressed store, hash-verified

76};
77
78void test1_fake() {
79 fake_fenwick_tree ft(20);
80
81 for (int i = 0; i < 20; i++) {
82 assert_equal(0, ft.rsq(i, i));
83 ft.update(i, i);
84 assert_equal(i, ft.rsq(i, i));
85 ft.update(i, -i);
86 assert_equal(0, ft.rsq(i, i));
87 }
88
89 ft.update(3, 1);
90 for (int i = 0; i < 20; i++)
91 {
92 for (int j = i; j < 20; j++)
93 {
94 if (i <= 3 && 3 <= j)
95 {
96 assert_equal(1, ft.rsq(i, j));
97 }
98 else
99 {
100 assert_equal(0, ft.rsq(i, j));
101 }
102 }
103 }
104
105 ft.update(5, -2);
106 assert_equal(-1, ft.rsq(1, 8));
107 ft.update(4, 5);
108 assert_equal(4, ft.rsq(1, 8));
109 ft.update(0, 100);
110 assert_equal(4, ft.rsq(1, 8));
111 assert_equal(104, ft.rsq(0, 19));
112 ft.update(19, -200);
113 assert_equal(-96, ft.rsq(0, 19));
114}
115
116void test2() {
117 int n = 5000;

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.50
rsqMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected