X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/2ca993e82fb37b597a3c73ecd1586a139a6579c5..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/test/intltest/unifiedcachetest.cpp?ds=sidebyside diff --git a/icuSources/test/intltest/unifiedcachetest.cpp b/icuSources/test/intltest/unifiedcachetest.cpp index d48b3e80..0525d475 100644 --- a/icuSources/test/intltest/unifiedcachetest.cpp +++ b/icuSources/test/intltest/unifiedcachetest.cpp @@ -1,3 +1,5 @@ +// © 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 * @@ -151,8 +153,8 @@ void UnifiedCacheTest::TestEvictionPolicy() { 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++) { @@ -160,9 +162,9 @@ void UnifiedCacheTest::TestEvictionPolicy() { } // This should free up all cache items - assertEquals("", 0, cache.keyCount()); + assertEquals("T3", 0, cache.keyCount()); - assertSuccess("", status); + assertSuccess("T4", status); } @@ -179,7 +181,7 @@ void UnifiedCacheTest::TestBounded() { // 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); @@ -200,15 +202,15 @@ void UnifiedCacheTest::TestBounded() { const UCTItem *frFr = NULL; cache.get(LocaleCacheKey("en_US"), &cache, enUs, status); cache.get(LocaleCacheKey("en"), &cache, en, status); - assertEquals("", 1, cache.unusedCount()); + assertEquals("T1", 1, cache.unusedCount()); cache.get(LocaleCacheKey("en_GB"), &cache, enGb, status); cache.get(LocaleCacheKey("fr_FR"), &cache, frFr, status); cache.get(LocaleCacheKey("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 @@ -225,40 +227,40 @@ void UnifiedCacheTest::TestBounded() { // 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("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("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("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("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("fr_FR"), &cache, throwAway, status); cache.get(LocaleCacheKey("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("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. @@ -266,8 +268,8 @@ void UnifiedCacheTest::TestBounded() { const UCTItem *ru = NULL; cache.get(LocaleCacheKey("es"), &cache, es, status); cache.get(LocaleCacheKey("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 @@ -282,13 +284,13 @@ void UnifiedCacheTest::TestBounded() { 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); } @@ -309,7 +311,7 @@ void UnifiedCacheTest::TestBasic() { cache->get(LocaleCacheKey("en_GB"), enGb, status); cache->get(LocaleCacheKey("fr_FR"), frFr, status); cache->get(LocaleCacheKey("fr"), fr, status); - cache->get(LocaleCacheKey("en_GB"), enGb2, status); + cache->get(LocaleCacheKey("en_GB"), enGb2, status); SharedObject::clearPtr(enGb2); if (enGb != enUs) { errln("Expected en_GB and en_US to resolve to same object."); @@ -320,16 +322,16 @@ void UnifiedCacheTest::TestBasic() { 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(); @@ -337,14 +339,14 @@ void UnifiedCacheTest::TestBasic() { // 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() {