You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -146,6 +143,45 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
146
143
cache2.print(m_logger);
147
144
cache2.insert(++i, "key is 112");
148
145
146
+
// Grow test - try growing the cache
147
+
m_logger->log("Growing test");
148
+
auto previousState = cache2.getState();
149
+
// Grow cache
150
+
assert(cache2.grow(10));
151
+
// Cache state should be the same
152
+
assert(cache2.getState() == previousState);
153
+
cache2.print(m_logger);
154
+
cache2.insert(++i, "key is 113");
155
+
cache2.insert(++i, "key is 114");
156
+
cache2.insert(++i, "key is 115");
157
+
cache2.insert(++i, "key is 116");
158
+
cache2.insert(++i, "key is 117");
159
+
cache2.print(m_logger);
160
+
// Should evict key 52
161
+
cache2.insert(++i, "key is 118");
162
+
cache2.print(m_logger);
163
+
constauto latestState = cache2.getState();
164
+
assert(latestState == "{21, key is 21}, {22, key is 22}, {23, key is 23}, {112, key is 112}, {113, key is 113}, {114, key is 114}, {115, key is 115}, {116, key is 116}, {117, key is 117}, {118, key is 118}");
165
+
// Invalid grow should fail
166
+
assert(!cache2.grow(5));
167
+
assert(!cache2.grow(10));
168
+
// Call a bunch of grows that shouldn't fail and some others that should
169
+
for (auto i = 1u; i < 50; i++)
170
+
{
171
+
assert(cache2.grow(50 * i));
172
+
assert(!cache2.grow(25 * i));
173
+
assert(!cache2.grow(50 * i));
174
+
assert(cache2.getState() == latestState);
175
+
}
176
+
177
+
// Single element cache test - checking for edge cases
0 commit comments