1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/******************************************************************** 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * COPYRIGHT: 3c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert * Copyright (c) 1997-2015, International Business Machines Corporation and 4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * others. All Rights Reserved. 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ********************************************************************/ 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * IntlTestUtilities is the medium level test class for everything in the directory "utility". 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h" 13b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#include "unicode/errorcode.h" 1450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/localpointer.h" 151b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert#include "charstr.h" 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "itutil.h" 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "strtest.h" 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "loctest.h" 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "citrtest.h" 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ustrtest.h" 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ucdtest.h" 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "restest.h" 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "restsnew.h" 24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "tsmthred.h" 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "tsputil.h" 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uobjtest.h" 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "utxttest.h" 28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "v32test.h" 29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uvectest.h" 30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "aliastst.h" 31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "usettest.h" 32c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 33b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoextern IntlTest *createBytesTrieTest(); 3450294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehostatic IntlTest *createLocalPointerTest(); 35b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoextern IntlTest *createUCharsTrieTest(); 368393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliusstatic IntlTest *createEnumSetTest(); 37fceb39872958b9fa2505e63f8b8699a9e0f882f4ccorneliusextern IntlTest *createSimplePatternFormatterTest(); 38f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusextern IntlTest *createUnifiedCacheTest(); 39f9878a236aa0d9662d8e40cafdaf2e04cd615835ccorneliusextern IntlTest *createQuantityFormatterTest(); 40c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertextern IntlTest *createPluralMapTest(); 41c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define CASE(id, test) case id: \ 44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru name = #test; \ 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if (exec) { \ 46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln(#test "---"); logln(); \ 47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru test t; \ 48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru callTest(t, par); \ 49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } \ 50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break 51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTestUtilities::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ) 53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if (exec) logln("TestSuite Utilities: "); 55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru switch (index) { 5627f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(0, MultithreadTest); 5727f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(1, StringTest); 5827f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(2, UnicodeStringTest); 5927f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(3, LocaleTest); 6027f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(4, CharIterTest); 6127f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(5, UObjectTest); 6227f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(6, UnicodeTest); 6327f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(7, ResourceBundleTest); 6427f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(8, NewResourceBundleTest); 6527f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(9, PUtilTest); 6627f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(10, UVector32Test); 6727f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(11, UVectorTest); 6827f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(12, UTextTest); 6927f654740f2a26ad62a5c155af9199af9e69b889claireho CASE(13, LocaleAliasTest); 70b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru CASE(14, UnicodeSetTest); 71b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru CASE(15, ErrorCodeTest); 7250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho case 16: 7350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho name = "LocalPointerTest"; 7450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if (exec) { 7550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho logln("TestSuite LocalPointerTest---"); logln(); 7650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalPointer<IntlTest> test(createLocalPointerTest()); 7750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho callTest(*test, par); 7850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 7950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho break; 80b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho case 17: 81b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho name = "BytesTrieTest"; 82b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if (exec) { 83b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho logln("TestSuite BytesTrieTest---"); logln(); 84b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho LocalPointer<IntlTest> test(createBytesTrieTest()); 85b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho callTest(*test, par); 86b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho } 87b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho break; 88b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho case 18: 89b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho name = "UCharsTrieTest"; 90b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if (exec) { 91b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho logln("TestSuite UCharsTrieTest---"); logln(); 92b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho LocalPointer<IntlTest> test(createUCharsTrieTest()); 93b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho callTest(*test, par); 94b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho } 95b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho break; 968393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius case 19: 978393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius name = "EnumSetTest"; 988393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius if (exec) { 998393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("TestSuite EnumSetTest---"); logln(); 1008393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius LocalPointer<IntlTest> test(createEnumSetTest()); 1018393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius callTest(*test, par); 1028393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius } 1038393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius break; 104fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius case 20: 105f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius name = "SimplePatternFormatterTest"; 106fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius if (exec) { 107f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius logln("TestSuite SimplePatternFormatterTest---"); logln(); 108f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius LocalPointer<IntlTest> test(createSimplePatternFormatterTest()); 109fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius callTest(*test, par); 110fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 111fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius break; 112fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius case 21: 113f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius name = "UnifiedCacheTest"; 114fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius if (exec) { 115f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius logln("TestSuite UnifiedCacheTest---"); logln(); 116f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius LocalPointer<IntlTest> test(createUnifiedCacheTest()); 117f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius callTest(*test, par); 118f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius } 119f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius break; 120f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius case 22: 121f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius name = "QuantityFormatterTest"; 122f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius if (exec) { 123f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius logln("TestSuite QuantityFormatterTest---"); logln(); 124f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius LocalPointer<IntlTest> test(createQuantityFormatterTest()); 125fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius callTest(*test, par); 126fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 1278ce198ebe2317b05a969826d0b629cb2d0b894a2Markus Scherer break; 128c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert case 23: 129c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert name = "PluralMapTest"; 130c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if (exec) { 131c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert logln("TestSuite PluralMapTest---"); logln(); 132c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalPointer<IntlTest> test(createPluralMapTest()); 133c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert callTest(*test, par); 134c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 135fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius break; 136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru default: name = ""; break; //needed to end loop 137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 140b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruvoid ErrorCodeTest::runIndexedTest(int32_t index, UBool exec, const char* &name, char* /*par*/) { 141b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if (exec) logln("TestSuite Utilities: "); 142b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru switch (index) { 143b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru case 0: name = "TestErrorCode"; if (exec) TestErrorCode(); break; 144b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru case 1: name = "TestSubclass"; if (exec) TestSubclass(); break; 145b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru default: name = ""; break; //needed to end loop 146b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 147b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru} 148b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 149b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Querustatic void RefPlusOne(UErrorCode &code) { code=(UErrorCode)(code+1); } 150b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Querustatic void PtrPlusTwo(UErrorCode *code) { *code=(UErrorCode)(*code+2); } 151b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 152b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruvoid ErrorCodeTest::TestErrorCode() { 153b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ErrorCode errorCode; 154b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_ZERO_ERROR || !errorCode.isSuccess() || errorCode.isFailure()) { 155b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not initialize properly"); 156b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru return; 157b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 15850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errorCode.assertSuccess(); 15950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.errorName()!=u_errorName(U_ZERO_ERROR)) { 16050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("ErrorCode did not format error message string properly"); 16150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 162b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru RefPlusOne(errorCode); 163b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_ILLEGAL_ARGUMENT_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) { 164b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not yield a writable reference"); 165b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 166b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru PtrPlusTwo(errorCode); 167b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_INVALID_FORMAT_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) { 168b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not yield a writable pointer"); 169b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 170b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errorCode.set(U_PARSE_ERROR); 171b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_PARSE_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) { 172b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode.set() failed"); 173b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 174b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if( errorCode.reset()!=U_PARSE_ERROR || errorCode.get()!=U_ZERO_ERROR || 175b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru !errorCode.isSuccess() || errorCode.isFailure() 176b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ) { 177b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not reset properly"); 178b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 179b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru} 180b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 181b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruclass MyErrorCode: public ErrorCode { 182b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Querupublic: 183b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru MyErrorCode(int32_t &countChecks, int32_t &countDests) 184b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru : checks(countChecks), dests(countDests) {} 185b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ~MyErrorCode() { 186b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(isFailure()) { 187b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ++dests; 188b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 189b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 190b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruprivate: 191b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru virtual void handleFailure() const { 192b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ++checks; 193b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 194b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t &checks; 195b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t &dests; 196b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru}; 197b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 198b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruvoid ErrorCodeTest::TestSubclass() { 199b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t countChecks=0; 200b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t countDests=0; 201b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru { 202b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru MyErrorCode errorCode(countChecks, countDests); 203b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if( errorCode.get()!=U_ZERO_ERROR || !errorCode.isSuccess() || errorCode.isFailure() || 204b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru countChecks!=0 || countDests!=0 205b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ) { 206b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not initialize properly"); 207b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru return; 208b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 20950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errorCode.assertSuccess(); 210b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(countChecks!=0) { 21150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("ErrorCode.assertSuccess() called handleFailure() despite success"); 212b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 213b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru RefPlusOne(errorCode); 214b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_ILLEGAL_ARGUMENT_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) { 215b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not yield a writable reference"); 216b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 21750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errorCode.assertSuccess(); 218b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(countChecks!=1) { 21950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("ErrorCode.assertSuccess() did not handleFailure()"); 220b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 221b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru PtrPlusTwo(errorCode); 222b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_INVALID_FORMAT_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) { 223b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not yield a writable pointer"); 224b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 22550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errorCode.assertSuccess(); 226b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(countChecks!=2) { 22750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("ErrorCode.assertSuccess() did not handleFailure()"); 228b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 229b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errorCode.set(U_PARSE_ERROR); 230b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(errorCode.get()!=U_PARSE_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) { 231b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode.set() failed"); 232b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 233b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if( errorCode.reset()!=U_PARSE_ERROR || errorCode.get()!=U_ZERO_ERROR || 234b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru !errorCode.isSuccess() || errorCode.isFailure() 235b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru ) { 236b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errln("ErrorCode did not reset properly"); 237b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 23850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errorCode.assertSuccess(); 239b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(countChecks!=2) { 24050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("ErrorCode.assertSuccess() called handleFailure() despite success"); 241b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 242b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 243b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(countDests!=0) { 24450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("MyErrorCode destructor detected failure despite success"); 245b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 246b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru countChecks=countDests=0; 247b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru { 248b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru MyErrorCode errorCode(countChecks, countDests); 249b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru errorCode.set(U_PARSE_ERROR); 250b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 251b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru if(countDests!=1) { 25250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("MyErrorCode destructor failed to detect failure"); 25350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 25450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 25550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 25650294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoclass LocalPointerTest : public IntlTest { 25750294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehopublic: 25850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalPointerTest() {} 25950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 26050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=NULL); 26150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 26250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho void TestLocalPointer(); 263c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert void TestLocalPointerMoveSwap(); 26450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho void TestLocalArray(); 265c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert void TestLocalArrayMoveSwap(); 26650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho void TestLocalXyzPointer(); 267c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert void TestLocalXyzPointerMoveSwap(); 26850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho void TestLocalXyzPointerNull(); 26950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho}; 27050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 27150294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehostatic IntlTest *createLocalPointerTest() { 27250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return new LocalPointerTest(); 27350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 27450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 27550294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid LocalPointerTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) { 27650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(exec) { 27750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho logln("TestSuite LocalPointerTest: "); 278b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 2791b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert TESTCASE_AUTO_BEGIN; 2801b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert TESTCASE_AUTO(TestLocalPointer); 281c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert TESTCASE_AUTO(TestLocalPointerMoveSwap); 2821b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert TESTCASE_AUTO(TestLocalArray); 283c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert TESTCASE_AUTO(TestLocalArrayMoveSwap); 2841b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert TESTCASE_AUTO(TestLocalXyzPointer); 285c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert TESTCASE_AUTO(TestLocalXyzPointerMoveSwap); 2861b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert TESTCASE_AUTO(TestLocalXyzPointerNull); 2871b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert TESTCASE_AUTO_END; 28850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 28950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 290c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert// Exercise almost every LocalPointer and LocalPointerBase method. 29150294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid LocalPointerTest::TestLocalPointer() { 29250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // constructor 29350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005)); 29450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // isNULL(), isValid(), operator==(), operator!=() 29550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(s.isNull() || !s.isValid() || s==NULL || !(s!=NULL)) { 29650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalPointer constructor or NULL test failure"); 29750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 29850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 29950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // getAlias(), operator->, operator* 30050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(s.getAlias()->length()!=2 || s->length()!=2 || (*s).length()!=2) { 30150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalPointer access failure"); 30250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 30350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // adoptInstead(), orphan() 30450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho s.adoptInstead(new UnicodeString((UChar)0xfffc)); 30550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(s->length()!=1) { 30650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalPointer adoptInstead(U+FFFC) failure"); 30750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 30850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString *orphan=s.orphan(); 30950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(orphan==NULL || orphan->length()!=1 || s.isValid() || s!=NULL) { 31050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalPointer orphan() failure"); 31150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 31250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho delete orphan; 31350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho s.adoptInstead(new UnicodeString()); 31450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(s->length()!=0) { 31550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalPointer adoptInstead(empty) failure"); 31650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 3171b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert 3181b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert // LocalPointer(p, errorCode) sets U_MEMORY_ALLOCATION_ERROR if p==NULL. 3191b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert UErrorCode errorCode = U_ZERO_ERROR; 3201b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert LocalPointer<CharString> cs(new CharString("some chars", errorCode), errorCode); 3211b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert if(cs.isNull() && U_SUCCESS(errorCode)) { 3221b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errln("LocalPointer(p, errorCode) failure"); 3231b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert return; 3241b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert } 3251b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errorCode = U_ZERO_ERROR; 3261b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert cs.adoptInsteadAndCheckErrorCode(new CharString("different chars", errorCode), errorCode); 3271b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert if(cs.isNull() && U_SUCCESS(errorCode)) { 3281b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errln("adoptInsteadAndCheckErrorCode(p, errorCode) failure"); 3291b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert return; 3301b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert } 3311b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert // Incoming failure: Keep the current object and delete the input object. 3321b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errorCode = U_ILLEGAL_ARGUMENT_ERROR; 3331b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert cs.adoptInsteadAndCheckErrorCode(new CharString("unused", errorCode), errorCode); 3341b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert if(cs.isValid() && strcmp(cs->data(), "different chars") != 0) { 3351b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errln("adoptInsteadAndCheckErrorCode(p, U_FAILURE) did not retain the old object"); 3361b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert return; 3371b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert } 3381b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errorCode = U_ZERO_ERROR; 3391b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert cs.adoptInsteadAndCheckErrorCode(NULL, errorCode); 3401b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert if(errorCode != U_MEMORY_ALLOCATION_ERROR) { 3411b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR"); 3421b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert return; 3431b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert } 3441b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert if(cs.isValid()) { 3451b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) kept the object"); 3461b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert return; 3471b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert } 3481b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errorCode = U_ZERO_ERROR; 3491b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert LocalPointer<CharString> null(NULL, errorCode); 3501b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert if(errorCode != U_MEMORY_ALLOCATION_ERROR) { 3511b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert errln("LocalPointer(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR"); 3521b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert return; 3531b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert } 354c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 355c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // destructor 356c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert} 357c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 358c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertvoid LocalPointerTest::TestLocalPointerMoveSwap() { 359c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString *p1 = new UnicodeString((UChar)0x61); 360c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString *p2 = new UnicodeString((UChar)0x62); 361c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalPointer<UnicodeString> s1(p1); 362c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalPointer<UnicodeString> s2(p2); 363c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert s1.swap(s2); 364c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(s1.getAlias() != p2 || s2.getAlias() != p1) { 365c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalPointer.swap() did not swap"); 366c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 367c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert swap(s1, s2); 368c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(s1.getAlias() != p1 || s2.getAlias() != p2) { 369c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("swap(LocalPointer) did not swap back"); 370c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 371c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalPointer<UnicodeString> s3; 372c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert s3.moveFrom(s1); 373c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(s3.getAlias() != p1 || s1.isValid()) { 374c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalPointer.moveFrom() did not move"); 375c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 376c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#if U_HAVE_RVALUE_REFERENCES 377c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert infoln("TestLocalPointerMoveSwap() with rvalue references"); 378c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert s1 = static_cast<LocalPointer<UnicodeString> &&>(s3); 379c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(s1.getAlias() != p1 || s3.isValid()) { 380c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalPointer move assignment operator did not move"); 381c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 382c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalPointer<UnicodeString> s4(static_cast<LocalPointer<UnicodeString> &&>(s2)); 383c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(s4.getAlias() != p2 || s2.isValid()) { 384c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalPointer move constructor did not move"); 385c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 386c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#else 387c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert infoln("TestLocalPointerMoveSwap() without rvalue references"); 388c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#endif 389c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 390c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Move self assignment leaves the object valid but in an undefined state. 391c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Do it to make sure there is no crash, 392c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // but do not check for any particular resulting value. 393c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert s1.moveFrom(s1); 394c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert s3.moveFrom(s3); 39550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 39650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 397c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert// Exercise almost every LocalArray method (but not LocalPointerBase). 39850294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid LocalPointerTest::TestLocalArray() { 39950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // constructor 40050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalArray<UnicodeString> a(new UnicodeString[2]); 40150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // operator[]() 40250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho a[0].append((UChar)0x61); 40350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho a[1].append((UChar32)0x60006); 40450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(a[0].length()!=1 || a[1].length()!=2) { 40550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalArray access failure"); 40650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 40750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // adoptInstead() 40850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho a.adoptInstead(new UnicodeString[4]); 40950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho a[3].append((UChar)0x62).append((UChar)0x63).reverse(); 41050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(a[3].length()!=2 || a[3][1]!=0x62) { 41150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalArray adoptInstead() failure"); 41250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 413c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 414c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // LocalArray(p, errorCode) sets U_MEMORY_ALLOCATION_ERROR if p==NULL. 415c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UErrorCode errorCode = U_ZERO_ERROR; 416c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalArray<UnicodeString> ua(new UnicodeString[3], errorCode); 417c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(ua.isNull() && U_SUCCESS(errorCode)) { 418c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalArray(p, errorCode) failure"); 419c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 420c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 421c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errorCode = U_ZERO_ERROR; 422c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString *u4 = new UnicodeString[4]; 423c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert ua.adoptInsteadAndCheckErrorCode(u4, errorCode); 424c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(ua.isNull() && U_SUCCESS(errorCode)) { 425c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("adoptInsteadAndCheckErrorCode(p, errorCode) failure"); 426c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 427c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 428c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Incoming failure: Keep the current object and delete the input object. 429c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errorCode = U_ILLEGAL_ARGUMENT_ERROR; 430c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert ua.adoptInsteadAndCheckErrorCode(new UnicodeString[5], errorCode); 431c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(ua.isValid() && ua.getAlias() != u4) { 432c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("adoptInsteadAndCheckErrorCode(p, U_FAILURE) did not retain the old array"); 433c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 434c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 435c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errorCode = U_ZERO_ERROR; 436c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert ua.adoptInsteadAndCheckErrorCode(NULL, errorCode); 437c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(errorCode != U_MEMORY_ALLOCATION_ERROR) { 438c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR"); 439c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 440c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 441c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(ua.isValid()) { 442c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) kept the array"); 443c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 444c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 445c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errorCode = U_ZERO_ERROR; 446c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalArray<UnicodeString> null(NULL, errorCode); 447c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(errorCode != U_MEMORY_ALLOCATION_ERROR) { 448c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalArray(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR"); 449c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 450c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 451c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 45250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // destructor 45350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 45450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 455c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertvoid LocalPointerTest::TestLocalArrayMoveSwap() { 456c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString *p1 = new UnicodeString[2]; 457c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeString *p2 = new UnicodeString[3]; 458c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalArray<UnicodeString> a1(p1); 459c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalArray<UnicodeString> a2(p2); 460c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert a1.swap(a2); 461c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(a1.getAlias() != p2 || a2.getAlias() != p1) { 462c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalArray.swap() did not swap"); 463c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 464c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert swap(a1, a2); 465c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(a1.getAlias() != p1 || a2.getAlias() != p2) { 466c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("swap(LocalArray) did not swap back"); 467c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 468c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalArray<UnicodeString> a3; 469c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert a3.moveFrom(a1); 470c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(a3.getAlias() != p1 || a1.isValid()) { 471c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalArray.moveFrom() did not move"); 472c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 473c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#if U_HAVE_RVALUE_REFERENCES 474c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert infoln("TestLocalArrayMoveSwap() with rvalue references"); 475c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert a1 = static_cast<LocalArray<UnicodeString> &&>(a3); 476c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(a1.getAlias() != p1 || a3.isValid()) { 477c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalArray move assignment operator did not move"); 478c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 479c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalArray<UnicodeString> a4(static_cast<LocalArray<UnicodeString> &&>(a2)); 480c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(a4.getAlias() != p2 || a2.isValid()) { 481c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalArray move constructor did not move"); 482c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 483c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#else 484c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert infoln("TestLocalArrayMoveSwap() without rvalue references"); 485c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#endif 486c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 487c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Move self assignment leaves the object valid but in an undefined state. 488c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Do it to make sure there is no crash, 489c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // but do not check for any particular resulting value. 490c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert a1.moveFrom(a1); 491c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert a3.moveFrom(a3); 492c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert} 493c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 49450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/ucnvsel.h" 49550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/ucal.h" 49650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/udatpg.h" 49727f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/uidna.h" 49850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/uldnames.h" 49950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/umsg.h" 50050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/unorm2.h" 50150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/uregex.h" 50250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/utrans.h" 50350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 50450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho// Use LocalXyzPointer types that are not covered elsewhere in the intltest suite. 50550294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid LocalPointerTest::TestLocalXyzPointer() { 50650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointer"); 50750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 50850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho static const char *const encoding="ISO-8859-1"; 50950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUConverterSelectorPointer sel( 51050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho ucnvsel_open(&encoding, 1, NULL, UCNV_ROUNDTRIP_SET, errorCode)); 51150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logIfFailureAndReset("ucnvsel_open()")) { 51250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 51350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 51450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(sel.isNull()) { 51550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalUConverterSelectorPointer failure"); 51650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 51750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 51850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 51950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_FORMATTING 52050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUCalendarPointer cal(ucal_open(NULL, 0, "root", UCAL_GREGORIAN, errorCode)); 52150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logDataIfFailureAndReset("ucal_open()")) { 52250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 52350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 52450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(cal.isNull()) { 52550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalUCalendarPointer failure"); 52650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 52750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 52850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 52950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUDateTimePatternGeneratorPointer patgen(udatpg_open("root", errorCode)); 530b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if(errorCode.logDataIfFailureAndReset("udatpg_open()")) { 53150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 53250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 53350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(patgen.isNull()) { 53450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalUDateTimePatternGeneratorPointer failure"); 53550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 53650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 53750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 53850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalULocaleDisplayNamesPointer ldn(uldn_open("de-CH", ULDN_STANDARD_NAMES, errorCode)); 53950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logIfFailureAndReset("uldn_open()")) { 54050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 54150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 54250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(ldn.isNull()) { 54350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalULocaleDisplayNamesPointer failure"); 54450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 54550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 54650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 54750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString hello=UNICODE_STRING_SIMPLE("Hello {0}!"); 54850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUMessageFormatPointer msg( 54950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho umsg_open(hello.getBuffer(), hello.length(), "root", NULL, errorCode)); 55050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logIfFailureAndReset("umsg_open()")) { 55150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 55250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 55350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(msg.isNull()) { 55450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalUMessageFormatPointer failure"); 55550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 55650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 55750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* UCONFIG_NO_FORMATTING */ 55850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 55950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_NORMALIZATION 560103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius const UNormalizer2 *nfc=unorm2_getNFCInstance(errorCode); 56150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeSet emptySet; 56250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUNormalizer2Pointer fn2(unorm2_openFiltered(nfc, emptySet.toUSet(), errorCode)); 56350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logIfFailureAndReset("unorm2_openFiltered()")) { 56450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 56550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 56650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(fn2.isNull()) { 56750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalUNormalizer2Pointer failure"); 56850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 56950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 57050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* !UCONFIG_NO_NORMALIZATION */ 57150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 57227f654740f2a26ad62a5c155af9199af9e69b889claireho#if !UCONFIG_NO_IDNA 57327f654740f2a26ad62a5c155af9199af9e69b889claireho LocalUIDNAPointer idna(uidna_openUTS46(0, errorCode)); 57427f654740f2a26ad62a5c155af9199af9e69b889claireho if(errorCode.logIfFailureAndReset("uidna_openUTS46()")) { 57527f654740f2a26ad62a5c155af9199af9e69b889claireho return; 57627f654740f2a26ad62a5c155af9199af9e69b889claireho } 57727f654740f2a26ad62a5c155af9199af9e69b889claireho if(idna.isNull()) { 57827f654740f2a26ad62a5c155af9199af9e69b889claireho errln("LocalUIDNAPointer failure"); 57927f654740f2a26ad62a5c155af9199af9e69b889claireho return; 58027f654740f2a26ad62a5c155af9199af9e69b889claireho } 58127f654740f2a26ad62a5c155af9199af9e69b889claireho#endif /* !UCONFIG_NO_IDNA */ 58227f654740f2a26ad62a5c155af9199af9e69b889claireho 58350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_REGULAR_EXPRESSIONS 58450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString pattern=UNICODE_STRING_SIMPLE("abc|xy+z"); 58550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalURegularExpressionPointer regex( 58650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, errorCode)); 58750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logIfFailureAndReset("uregex_open()")) { 58850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 58950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 59050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(regex.isNull()) { 59150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalURegularExpressionPointer failure"); 59250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 59350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 59450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* UCONFIG_NO_REGULAR_EXPRESSIONS */ 59550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 59650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_TRANSLITERATION 59750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString id=UNICODE_STRING_SIMPLE("Grek-Latn"); 59850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUTransliteratorPointer trans( 59950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho utrans_openU(id.getBuffer(), id.length(), UTRANS_FORWARD, NULL, 0, NULL, errorCode)); 60050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(errorCode.logIfFailureAndReset("utrans_open()")) { 60150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 60250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 60350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(trans.isNull()) { 60450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho errln("LocalUTransliteratorPointer failure"); 60550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return; 60650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 60750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* !UCONFIG_NO_TRANSLITERATION */ 60850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 60950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // destructors 61050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 61150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 612c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubertvoid LocalPointerTest::TestLocalXyzPointerMoveSwap() { 613c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#if !UCONFIG_NO_NORMALIZATION 614c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerMoveSwap"); 615c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert const UNormalizer2 *nfc=unorm2_getNFCInstance(errorCode); 616c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert const UNormalizer2 *nfd=unorm2_getNFDInstance(errorCode); 617c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(errorCode.logIfFailureAndReset("unorm2_getNF[CD]Instance()")) { 618c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 619c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 620c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UnicodeSet emptySet; 621c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UNormalizer2 *p1 = unorm2_openFiltered(nfc, emptySet.toUSet(), errorCode); 622c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert UNormalizer2 *p2 = unorm2_openFiltered(nfd, emptySet.toUSet(), errorCode); 623c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalUNormalizer2Pointer f1(p1); 624c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalUNormalizer2Pointer f2(p2); 625c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(errorCode.logIfFailureAndReset("unorm2_openFiltered()")) { 626c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 627c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 628c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(f1.isNull() || f2.isNull()) { 629c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalUNormalizer2Pointer failure"); 630c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert return; 631c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 632c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert f1.swap(f2); 633c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(f1.getAlias() != p2 || f2.getAlias() != p1) { 634c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalUNormalizer2Pointer.swap() did not swap"); 635c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 636c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert swap(f1, f2); 637c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(f1.getAlias() != p1 || f2.getAlias() != p2) { 638c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("swap(LocalUNormalizer2Pointer) did not swap back"); 639c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 640c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalUNormalizer2Pointer f3; 641c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert f3.moveFrom(f1); 642c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(f3.getAlias() != p1 || f1.isValid()) { 643c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalUNormalizer2Pointer.moveFrom() did not move"); 644c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 645c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#if U_HAVE_RVALUE_REFERENCES 646c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert infoln("TestLocalXyzPointerMoveSwap() with rvalue references"); 647c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert f1 = static_cast<LocalUNormalizer2Pointer &&>(f3); 648c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(f1.getAlias() != p1 || f3.isValid()) { 649c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalUNormalizer2Pointer move assignment operator did not move"); 650c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 651c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert LocalUNormalizer2Pointer f4(static_cast<LocalUNormalizer2Pointer &&>(f2)); 652c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert if(f4.getAlias() != p2 || f2.isValid()) { 653c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert errln("LocalUNormalizer2Pointer move constructor did not move"); 654c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert } 655c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#else 656c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert infoln("TestLocalXyzPointerMoveSwap() without rvalue references"); 657c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#endif 658c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Move self assignment leaves the object valid but in an undefined state. 659c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // Do it to make sure there is no crash, 660c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert // but do not check for any particular resulting value. 661c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert f1.moveFrom(f1); 662c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert f3.moveFrom(f3); 663c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert#endif /* !UCONFIG_NO_NORMALIZATION */ 664c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert} 665c14898b482f76ecab9026615e2e4c6fe78358bdcFredrik Roubert 66650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho// Try LocalXyzPointer types with NULL pointers. 66750294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid LocalPointerTest::TestLocalXyzPointerNull() { 66850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho { 66950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUConverterSelectorPointer"); 67050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho static const char *const encoding="ISO-8859-1"; 67150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUConverterSelectorPointer null; 67250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUConverterSelectorPointer sel( 67350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho ucnvsel_open(&encoding, 1, NULL, UCNV_ROUNDTRIP_SET, errorCode)); 67450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho sel.adoptInstead(NULL); 67550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 67650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_FORMATTING 67750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho { 67850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUCalendarPointer"); 67950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUCalendarPointer null; 68050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUCalendarPointer cal(ucal_open(NULL, 0, "root", UCAL_GREGORIAN, errorCode)); 68150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(!errorCode.logDataIfFailureAndReset("ucal_open()")) { 68250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho cal.adoptInstead(NULL); 68350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 68450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 68550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho { 68650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUDateTimePatternGeneratorPointer"); 68750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUDateTimePatternGeneratorPointer null; 68850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUDateTimePatternGeneratorPointer patgen(udatpg_open("root", errorCode)); 68950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho patgen.adoptInstead(NULL); 69050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 69150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho { 69250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUMessageFormatPointer"); 69350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString hello=UNICODE_STRING_SIMPLE("Hello {0}!"); 69450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUMessageFormatPointer null; 69550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUMessageFormatPointer msg( 69650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho umsg_open(hello.getBuffer(), hello.length(), "root", NULL, errorCode)); 69750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho msg.adoptInstead(NULL); 69850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 69950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* !UCONFIG_NO_FORMATTING */ 70050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 70150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_REGULAR_EXPRESSIONS 70250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho { 70350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalURegularExpressionPointer"); 70450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString pattern=UNICODE_STRING_SIMPLE("abc|xy+z"); 70550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalURegularExpressionPointer null; 70650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalURegularExpressionPointer regex( 70750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho uregex_open(pattern.getBuffer(), pattern.length(), 0, NULL, errorCode)); 70850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(!errorCode.logDataIfFailureAndReset("urege_open()")) { 70950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho regex.adoptInstead(NULL); 71050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 71150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 71250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ 71350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 71450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_TRANSLITERATION 71550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho { 71650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUTransliteratorPointer"); 71750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString id=UNICODE_STRING_SIMPLE("Grek-Latn"); 71850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUTransliteratorPointer null; 71950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho LocalUTransliteratorPointer trans( 72050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho utrans_openU(id.getBuffer(), id.length(), UTRANS_FORWARD, NULL, 0, NULL, errorCode)); 72150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(!errorCode.logDataIfFailureAndReset("utrans_openU()")) { 72250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho trans.adoptInstead(NULL); 72350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 72450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 72550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif /* !UCONFIG_NO_TRANSLITERATION */ 72650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 727b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru} 7288393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7298393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius/** EnumSet test **/ 7308393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "unicode/enumset.h" 7318393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7328393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliusclass EnumSetTest : public IntlTest { 7338393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliuspublic: 7348393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius EnumSetTest() {} 7358393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius virtual void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=NULL); 7368393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius void TestEnumSet(); 7378393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius}; 7388393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7398393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliusstatic IntlTest *createEnumSetTest() { 7408393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius return new EnumSetTest(); 7418393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius} 7428393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7438393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliusvoid EnumSetTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) { 7448393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TESTCASE_AUTO_BEGIN; 7458393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TESTCASE_AUTO(TestEnumSet); 7468393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TESTCASE_AUTO_END; 7478393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius} 7488393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliusenum myEnum { 7498393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius MAX_NONBOOLEAN=-1, 7508393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius THING1, 7518393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius THING2, 7528393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius THING3, 7538393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius LIMIT_BOOLEAN 7548393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius}; 7558393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7568393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Corneliusvoid EnumSetTest::TestEnumSet() { 7578393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius EnumSet<myEnum, 7588393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius MAX_NONBOOLEAN+1, 7598393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius LIMIT_BOOLEAN> 7608393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags; 7618393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7628393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("Enum is from [%d..%d]\n", MAX_NONBOOLEAN+1, 7638393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius LIMIT_BOOLEAN); 7648393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7658393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == FALSE); 7668393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 7678393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == FALSE); 7688393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 7698393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 7708393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("Value now: %d\n", flags.getAll()); 7718393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags.clear(); 7728393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("clear -Value now: %d\n", flags.getAll()); 7738393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 7748393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == FALSE); 7758393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 7768393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == FALSE); 7778393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags.add(THING1); 7788393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("set THING1 -Value now: %d\n", flags.getAll()); 7798393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == TRUE); 7808393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 7818393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == FALSE); 7828393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 7838393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags.add(THING3); 7848393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("set THING3 -Value now: %d\n", flags.getAll()); 7858393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == TRUE); 7868393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 7878393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == TRUE); 7888393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 7898393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags.remove(THING2); 7908393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == TRUE); 7918393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 7928393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == TRUE); 7938393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("remove THING2 -Value now: %d\n", flags.getAll()); 7948393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 7958393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags.remove(THING1); 7968393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == FALSE); 7978393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 7988393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == TRUE); 7998393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("remove THING1 -Value now: %d\n", flags.getAll()); 8008393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 8018393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius 8028393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius flags.clear(); 8038393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("clear -Value now: %d\n", flags.getAll()); 8048393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get(THING1), flags.get(THING2), flags.get(THING3)); 8058393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING1) == FALSE); 8068393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); 8078393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius TEST_ASSERT_TRUE(flags.get(THING3) == FALSE); 8088393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius} 809