+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2015, International Business Machines Corporation and *
unusedReference->removeRef();
// unused count not to exeed in use count
- assertEquals("", UPRV_LENGTHOF(usedReferences), cache.unusedCount());
- assertEquals("", 2*UPRV_LENGTHOF(usedReferences), cache.keyCount());
+ assertEquals("T1", UPRV_LENGTHOF(usedReferences), cache.unusedCount());
+ assertEquals("T2", 2*UPRV_LENGTHOF(usedReferences), cache.keyCount());
// Free up those used entries.
for (int32_t i = 0; i < UPRV_LENGTHOF(usedReferences); i++) {
}
// This should free up all cache items
- assertEquals("", 0, cache.keyCount());
+ assertEquals("T3", 0, cache.keyCount());
- assertSuccess("", status);
+ assertSuccess("T4", status);
}
// complete control over it. Real clients should never ever create
// their own cache!
UnifiedCache cache(status);
- assertSuccess("", status);
+ assertSuccess("T0", status);
// Maximum unused count is 3.
cache.setEvictionPolicy(3, 0, status);
const UCTItem *frFr = NULL;
cache.get(LocaleCacheKey<UCTItem>("en_US"), &cache, enUs, status);
cache.get(LocaleCacheKey<UCTItem>("en"), &cache, en, status);
- assertEquals("", 1, cache.unusedCount());
+ assertEquals("T1", 1, cache.unusedCount());
cache.get(LocaleCacheKey<UCTItem>("en_GB"), &cache, enGb, status);
cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, frFr, status);
cache.get(LocaleCacheKey<UCTItem>("fr"), &cache, fr, status);
// Client holds two unique references, "en" and "fr" the other three
// entries are eligible for eviction.
- assertEquals("", 3, cache.unusedCount());
- assertEquals("", 5, cache.keyCount());
+ assertEquals("T2", 3, cache.unusedCount());
+ assertEquals("T3", 5, cache.keyCount());
// Exercise cache more but don't hold the references except for
// the last one. At the end of this, we will hold references to one
// Client holds three unique references, "en", "fr", "de" although we
// could have a total of 8 entries in the cache maxUnusedCount == 3
// so we have only 6 entries.
- assertEquals("", 3, cache.unusedCount());
- assertEquals("", 6, cache.keyCount());
+ assertEquals("T4", 3, cache.unusedCount());
+ assertEquals("T5", 6, cache.keyCount());
// For all the references we have, cache must continue to return
// those same references (#2)
cache.get(LocaleCacheKey<UCTItem>("en"), &cache, throwAway, status);
if (throwAway != en) {
- errln("Expected en to resolve to the same object.");
+ errln("T6: Expected en to resolve to the same object.");
}
cache.get(LocaleCacheKey<UCTItem>("en_US"), &cache, throwAway, status);
if (throwAway != enUs) {
- errln("Expected enUs to resolve to the same object.");
+ errln("T7: Expected enUs to resolve to the same object.");
}
cache.get(LocaleCacheKey<UCTItem>("en_GB"), &cache, throwAway, status);
if (throwAway != enGb) {
- errln("Expected enGb to resolve to the same object.");
+ errln("T8: Expected enGb to resolve to the same object.");
}
cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, throwAway, status);
if (throwAway != frFr) {
- errln("Expected frFr to resolve to the same object.");
+ errln("T9: Expected frFr to resolve to the same object.");
}
cache.get(LocaleCacheKey<UCTItem>("fr_FR"), &cache, throwAway, status);
cache.get(LocaleCacheKey<UCTItem>("fr"), &cache, throwAway, status);
if (throwAway != fr) {
- errln("Expected fr to resolve to the same object.");
+ errln("T10: Expected fr to resolve to the same object.");
}
cache.get(LocaleCacheKey<UCTItem>("de_AU"), &cache, throwAway, status);
if (throwAway != deAu) {
- errln("Expected deAu to resolve to the same object.");
+ errln("T11: Expected deAu to resolve to the same object.");
}
- assertEquals("", 3, cache.unusedCount());
- assertEquals("", 6, cache.keyCount());
+ assertEquals("T12", 3, cache.unusedCount());
+ assertEquals("T13", 6, cache.keyCount());
// Now we hold a references to two more distinct values. Cache size
// should grow to 8.
const UCTItem *ru = NULL;
cache.get(LocaleCacheKey<UCTItem>("es"), &cache, es, status);
cache.get(LocaleCacheKey<UCTItem>("ru"), &cache, ru, status);
- assertEquals("", 3, cache.unusedCount());
- assertEquals("", 8, cache.keyCount());
+ assertEquals("T14", 3, cache.unusedCount());
+ assertEquals("T15", 8, cache.keyCount());
// Now release all the references we hold except for
// es, ru, and en
SharedObject::clearPtr(throwAway);
// Size of cache should magically drop to 3.
- assertEquals("", 3, cache.unusedCount());
- assertEquals("", 3, cache.keyCount());
+ assertEquals("T16", 3, cache.unusedCount());
+ assertEquals("T17", 3, cache.keyCount());
// Be sure nothing happens setting the eviction policy in the middle of
// a run.
cache.setEvictionPolicy(3, 0, status);
- assertSuccess("", status);
+ assertSuccess("T18", status);
}
cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb, status);
cache->get(LocaleCacheKey<UCTItem>("fr_FR"), frFr, status);
cache->get(LocaleCacheKey<UCTItem>("fr"), fr, status);
- cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb2, status);
+ cache->get(LocaleCacheKey<UCTItem>("en_GB"), enGb2, status);
SharedObject::clearPtr(enGb2);
if (enGb != enUs) {
errln("Expected en_GB and en_US to resolve to same object.");
if (enGb == fr) {
errln("Expected en_GB and fr to return different objects.");
}
- assertSuccess("", status);
+ assertSuccess("T1", status);
// en_US, en_GB, en share one object; fr_FR and fr don't share.
// 5 keys in all.
- assertEquals("", baseCount + 5, cache->keyCount());
+ assertEquals("T2", baseCount + 5, cache->keyCount());
SharedObject::clearPtr(enGb);
cache->flush();
// Only 2 unique values in the cache. flushing trims cache down
// to this minimum size.
- assertEquals("", baseCount + 2, cache->keyCount());
+ assertEquals("T3", baseCount + 2, cache->keyCount());
SharedObject::clearPtr(enUs);
SharedObject::clearPtr(en);
cache->flush();
// the "en" object, so it gets flushed and the keys that refer to it
// get removed from the cache. Now we have just one unique value, fr, in
// the cache
- assertEquals("", baseCount + 1, cache->keyCount());
+ assertEquals("T4", baseCount + 1, cache->keyCount());
SharedObject::clearPtr(fr);
cache->flush();
- assertEquals("", baseCount + 1, cache->keyCount());
+ assertEquals("T5", baseCount + 1, cache->keyCount());
SharedObject::clearPtr(frFr);
cache->flush();
- assertEquals("", baseCount + 0, cache->keyCount());
- assertSuccess("", status);
+ assertEquals("T6", baseCount + 0, cache->keyCount());
+ assertSuccess("T7", status);
}
void UnifiedCacheTest::TestError() {