Ticket #5927: 5408-LocaleKitTests.patch
File 5408-LocaleKitTests.patch, 4.7 KB (added by , 14 years ago) |
---|
-
src/tests/kits/locale/catalogTestAddOn.cpp
1 /* 1 /* 2 2 ** Copyright 2003, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved. 3 3 ** Distributed under the terms of the OpenBeOS License. 4 4 */ … … 22 22 #define catName catSig".catalog" 23 23 24 24 25 void 25 void 26 26 CatalogTestAddOn::Run() { 27 27 printf("addon..."); 28 28 status_t res; … … 86 86 } 87 87 88 88 89 void 89 void 90 90 CatalogTestAddOn::Check() { 91 91 status_t res; 92 92 printf("addon-check..."); … … 95 95 size_t hashVal = CatKey::HashFun(s.String()); 96 96 // ok, we now try to re-load the catalog that has just been written: 97 97 // 98 // actually, the following code can be seen as an example of what an 98 // actually, the following code can be seen as an example of what an 99 99 // add_on needs in order to translate strings: 100 100 BCatalog cat; 101 101 res = get_add_on_catalog(&cat, catSig); … … 114 114 assert(sig == catSig); 115 115 116 116 // now check strings: 117 s = TR_ID(hashVal);117 s = B_TRANSLATE_ID(hashVal); 118 118 assert(s == "Schnur_id_A"); 119 s = TR_ALL("string", "programming", "");119 s = B_TRANSLATE_ALL("string", "programming", ""); 120 120 assert(s == "String_A"); 121 s = TR_ALL("string", "programming", "Deutsches Fachbuch");121 s = B_TRANSLATE_ALL("string", "programming", "Deutsches Fachbuch"); 122 122 assert(s == "Textpuffer_A"); 123 s = TR_CMT("string", "Deutsches Fachbuch");123 s = B_TRANSLATE_COMMENT("string", "Deutsches Fachbuch"); 124 124 assert(s == "Leine_A"); 125 125 // the following string should be found in the embedded catalog only: 126 s = TR_ALL("string", "base", "");126 s = B_TRANSLATE_ALL("string", "base", ""); 127 127 assert(s == "string_A"); 128 128 // the following id should be found in the embedded catalog only: 129 s = TR_ID(32);129 s = B_TRANSLATE_ID(32); 130 130 assert(s == "hashed string_A"); 131 131 // the following id doesn't exist anywhere (hopefully): 132 s = TR_ID(-1);132 s = B_TRANSLATE_ID(-1); 133 133 assert(s == ""); 134 // the following string exists twice, in the embedded as well as in the 134 // the following string exists twice, in the embedded as well as in the 135 135 // external catalog. So we should get the external translation (as it should 136 136 // override the embedded one): 137 s = TR("string");137 s = B_TRANSLATE("string"); 138 138 assert(s == "Schnur_A"); 139 139 140 140 // check access to app-catalog from inside add-on: -
src/tests/kits/locale/catalogTest.cpp
124 124 assert(res == B_OK); 125 125 126 126 // now check strings: 127 s = TR_ID(hashVal);127 s = B_TRANSLATE_ID(hashVal); 128 128 assert(s == "Schnur_id"); 129 s = TR_ALL("string", "programming", "");129 s = B_TRANSLATE_ALL("string", "programming", ""); 130 130 assert(s == "String"); 131 s = TR_ALL("string", "programming", "Deutsches Fachbuch");131 s = B_TRANSLATE_ALL("string", "programming", "Deutsches Fachbuch"); 132 132 assert(s == "Textpuffer"); 133 s = TR_CMT("string", "Deutsches Fachbuch");133 s = B_TRANSLATE_COMMENT("string", "Deutsches Fachbuch"); 134 134 assert(s == "Leine"); 135 135 // the following string should be found in the embedded catalog only: 136 s = TR_ALL("string", "base", NULL);136 s = B_TRANSLATE_ALL("string", "base", NULL); 137 137 assert(s == "string"); 138 138 // the following id should be found in the embedded catalog only: 139 s = TR_ID(32);139 s = B_TRANSLATE_ID(32); 140 140 assert(s == "hashed string"); 141 141 // the following id doesn't exist anywhere (hopefully): 142 s = TR_ID(-1);142 s = B_TRANSLATE_ID(-1); 143 143 assert(s == ""); 144 144 // the following string exists twice, in the embedded as well as in the 145 145 // external catalog. So we should get the external translation (as it should 146 146 // override the embedded one): 147 s = TR("string");147 s = B_TRANSLATE("string"); 148 148 assert(s == "Schnur"); 149 149 150 150 // now check if trying to access same catalog by specifying its data works: -
src/tests/kits/locale/catalogSpeed.cpp
95 95 watch.Reset(); 96 96 watch.Resume(); 97 97 for (uint32 i = 0; i < kNumStrings; i++) { 98 translated = TR(strs[i].String());98 translated = B_TRANSLATE(strs[i].String()); 99 99 } 100 100 watch.Suspend(); 101 101 printf("\tlooked up %lu strings in %9Ld usecs\n", … … 161 161 watch.Reset(); 162 162 watch.Resume(); 163 163 for (uint32 i = 0; i < kNumStrings; i++) { 164 translated = TR_ID(i);164 translated = B_TRANSLATE_ID(i); 165 165 } 166 166 watch.Suspend(); 167 167 printf("\tlooked up %lu strings in %9Ld usecs\n",