platformStringTests.cc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. // We don't want tests in a shipping version.
  23. #ifndef TORQUE_SHIPPING
  24. #ifndef _UNIT_TESTING_H_
  25. #include "testing/unitTesting.h"
  26. #endif
  27. #ifndef _PLATFORM_H_
  28. #include "platform/platform.h"
  29. #endif
  30. //-----------------------------------------------------------------------------
  31. #define PLATFORM_UNITTEST_STRING_DESTINATION_BUFFERSIZE 1024
  32. //-----------------------------------------------------------------------------
  33. //TODO: android
  34. #ifndef TORQUE_OS_ANDROID
  35. TEST( PlatformStringTests, dStrlenTest )
  36. {
  37. // Check length of string.
  38. ASSERT_EQ( (S32)dStrlen("GarageGames"), 11 ) << "String length failed.";
  39. }
  40. //-----------------------------------------------------------------------------
  41. TEST( PlatformStringTests, dStrcatTest )
  42. {
  43. char source[] = { "Games" };
  44. char destination[] = { "Garage\0XXXXX" };
  45. // Concatenate.
  46. char* pResult = dStrcat( destination, source );
  47. // Check result.
  48. ASSERT_EQ( pResult, destination );
  49. ASSERT_STREQ( "GarageGames", pResult ) << "Concatenation failed.";
  50. }
  51. //-----------------------------------------------------------------------------
  52. TEST( PlatformStringTests, dStrncatTest )
  53. {
  54. char source[] = { "Games" };
  55. char destination[] = { "Garage\0XXXXX" };
  56. // Concatenate.
  57. char* pResult = dStrncat( destination, source, 3 );
  58. // Check result.
  59. ASSERT_EQ( pResult, destination );
  60. ASSERT_STREQ( "GarageGam", pResult ) << "Explicit-length concatenation failed.";
  61. }
  62. //-----------------------------------------------------------------------------
  63. TEST( PlatformStringTests, dStrcatlTest )
  64. {
  65. char destination[] = { "Garage\0XXXXX" };
  66. // Concatenate.
  67. char* pResult = dStrcatl( destination, sizeof(destination), "G", "am", "e", "s", NULL );
  68. // Check result.
  69. ASSERT_STREQ( "GarageGames", destination ) << "Variadic concatenation failed.";
  70. ASSERT_STREQ( "GarageGames", pResult ) << "Variadic concatenation failed.";
  71. }
  72. //-----------------------------------------------------------------------------
  73. TEST( PlatformStringTests, dStrcmp8Test )
  74. {
  75. UTF8 source1[] = { "garageGames" };
  76. UTF8 source2[] = { "GarageGames" };
  77. UTF8 source3[] = { "GarageGame" };
  78. UTF8 destination[] = { "GarageGames" };
  79. // Compare.
  80. ASSERT_GT( dStrcmp( source1, destination ), 0 ) << "Case-sensitive UTF8 compare failed.";
  81. ASSERT_EQ( dStrcmp( source2, destination ), 0 ) << "Case-sensitive UTF8 compare failed.";
  82. ASSERT_LT( dStrcmp( source3, destination ), 0 ) << "Case-sensitive UTF8 compare failed.";
  83. }
  84. //-----------------------------------------------------------------------------
  85. TEST( PlatformStringTests, dStrcmp16Test )
  86. {
  87. UTF16 source1[] = { 1001, 2000, 3000, 4000, 0 };
  88. UTF16 source2[] = { 1000, 2000, 3000, 4000, 0 };
  89. UTF16 source3[] = { 1000, 2000, 3000, 0 };
  90. UTF16 destination[] = { 1000, 2000, 3000, 4000, 0 };
  91. // Compare.
  92. ASSERT_LT( 0, dStrcmp( source1, destination ) ) << "Case-sensitive UTF16 compare failed.";
  93. ASSERT_EQ( 0, dStrcmp( source2, destination ) ) << "Case-sensitive UTF16 compare failed.";
  94. ASSERT_GT( 0, dStrcmp( source3, destination ) ) << "Case-sensitive UTF16 compare failed.";
  95. }
  96. //-----------------------------------------------------------------------------
  97. TEST( PlatformStringTests, dStricmpTest )
  98. {
  99. char source1[] = { "GaRaGeGaMeS!" };
  100. char source2[] = { "GaRaGeGaMeS" };
  101. char source3[] = { "GaRaGeGaMe" };
  102. char destination[] = { "GarageGames" };
  103. // Compare.
  104. ASSERT_GT( dStricmp( source1, destination ), 0 ) << "Case-insensitive compare failed.";
  105. ASSERT_EQ( dStricmp( source2, destination ), 0 ) << "Case-insensitive compare failed.";
  106. ASSERT_LT( dStricmp( source3, destination ), 0 ) << "Case-insensitive compare failed.";
  107. }
  108. //-----------------------------------------------------------------------------
  109. TEST( PlatformStringTests, dStrncmpTest )
  110. {
  111. char source1[] = { "GG*" };
  112. char source2[] = { "GG!" };
  113. char source3[] = { "GG " };
  114. char destination[] = { "GG!" };
  115. // Compare.
  116. ASSERT_GT( dStrncmp( source1, destination, sizeof(destination) ), 0 ) << "Case-sensitive compare failed.";
  117. ASSERT_EQ( dStrncmp( source2, destination, sizeof(destination) ), 0 ) << "Case-sensitive compare failed.";
  118. ASSERT_LT( dStrncmp( source3, destination, sizeof(destination) ), 0 ) << "Case-sensitive compare failed.";
  119. }
  120. //-----------------------------------------------------------------------------
  121. TEST( PlatformStringTests, dStrnicmpTest )
  122. {
  123. char source1[] = { "gG*" };
  124. char source2[] = { "gg!" };
  125. char source3[] = { "Gg " };
  126. char destination[] = { "GG!" };
  127. // Compare.
  128. ASSERT_GT( dStrnicmp( source1, destination, sizeof(destination) ), 0 ) << "Case-insensitive compare failed.";
  129. ASSERT_EQ( dStrnicmp( source2, destination, sizeof(destination) ), 0 ) << "Case-insensitive compare failed.";
  130. ASSERT_LT( dStrnicmp( source3, destination, sizeof(destination) ), 0 ) << "Case-insensitive compare failed.";
  131. }
  132. //-----------------------------------------------------------------------------
  133. TEST( PlatformStringTests, dStrcpyTest )
  134. {
  135. char source[] = { "GarageGames" };
  136. char destination[sizeof(source)+1];
  137. // Copy.
  138. char* pResult = dStrcpy( destination, source );
  139. // Check results.
  140. ASSERT_EQ( pResult, destination );
  141. ASSERT_STREQ( "GarageGames", destination ) << "Copy failed.";
  142. ASSERT_STREQ( pResult, destination ) << "Copy failed.";
  143. }
  144. //-----------------------------------------------------------------------------
  145. TEST( PlatformStringTests, dStrcpylTest )
  146. {
  147. char destination[] = { "GarageGames" };
  148. // Copy.
  149. char* pResult = dStrcpyl( destination, sizeof(destination), "G", "ar", "a", "ge", "Ga", "me", "s", NULL );
  150. // Check result.
  151. ASSERT_EQ( pResult, destination );
  152. ASSERT_STREQ( "GarageGames", destination ) << "Variadic copy failed.";
  153. ASSERT_STREQ( "GarageGames", pResult ) << "Variadic copy failed.";
  154. }
  155. //-----------------------------------------------------------------------------
  156. TEST( PlatformStringTests, dStruprTest )
  157. {
  158. char source[] = { "GarageGames" };
  159. // Convert.
  160. char* pResult = dStrupr( source );
  161. // Check results.
  162. ASSERT_STREQ( "GARAGEGAMES", pResult ) << "Uppercase conversion failed.";
  163. }
  164. //-----------------------------------------------------------------------------
  165. TEST( PlatformStringTests, dStrlwrTest )
  166. {
  167. char source[] = { "GarageGames" };
  168. // Convert.
  169. char* pResult = dStrlwr( source );
  170. // Check results.
  171. ASSERT_STREQ( "garagegames", pResult ) << "Lowercase conversion failed.";
  172. }
  173. //-----------------------------------------------------------------------------
  174. TEST( PlatformStringTests, dToupperTest )
  175. {
  176. // Convert.
  177. S32 index = 0;
  178. for ( char character = 'a'; character <= 'z'; character++, index++ )
  179. {
  180. // Check results.
  181. ASSERT_EQ( (char)('A' + index), dToupper( character) ) << "Uppercase conversion incorrect.";
  182. }
  183. }
  184. //-----------------------------------------------------------------------------
  185. TEST( PlatformStringTests, dTolowerTest )
  186. {
  187. // Convert.
  188. S32 index = 0;
  189. for ( char character = 'A'; character <= 'Z'; character++, index++ )
  190. {
  191. // Check results.
  192. ASSERT_EQ( (char)('a' + index), dTolower( character) ) << "Lowercase conversion incorrect.";
  193. }
  194. }
  195. //-----------------------------------------------------------------------------
  196. TEST( PlatformStringTests, dStrchrTest )
  197. {
  198. char source[] = { "GarageGames" };
  199. // Find.
  200. char* pResult1 = dStrchr( source, 'm' );
  201. char* pResult2 = dStrchr( source, 'z' );
  202. // Check results.
  203. ASSERT_STREQ( "mes", pResult1 ) << "Could not find character.";
  204. ASSERT_EQ( 0, pResult2 ) << "Should not have found character,";
  205. }
  206. //-----------------------------------------------------------------------------
  207. TEST( PlatformStringTests, dStrchrCONSTTest )
  208. {
  209. char source[] = { "GarageGames" };
  210. // Find.
  211. const char* pResult1 = dStrchr( (const char*)source, 'm' );
  212. const char* pResult2 = dStrchr( (const char*)source, 'z' );
  213. // Check results.
  214. ASSERT_STREQ( "mes", pResult1 ) << "Could not find character.";
  215. ASSERT_EQ( 0, pResult2 ) << "Should not have found character,";
  216. }
  217. //-----------------------------------------------------------------------------
  218. TEST( PlatformStringTests, dStrrchrTest )
  219. {
  220. char source[] = { "GarageGames" };
  221. // Find.
  222. char* pResult1 = dStrrchr( source, 'G' );
  223. char* pResult2 = dStrrchr( source, 'z' );
  224. // Check results.
  225. ASSERT_STREQ( "Games", pResult1 ) << "Could not find character.";
  226. ASSERT_EQ( 0, pResult2 ) << "Should not have found character,";
  227. }
  228. //-----------------------------------------------------------------------------
  229. TEST( PlatformStringTests, dStrrchrCONSTTest )
  230. {
  231. char source[] = { "GarageGames" };
  232. // Find.
  233. const char* pResult1 = dStrrchr( (const char*)source, 'G' );
  234. const char* pResult2 = dStrrchr( (const char*)source, 'z' );
  235. // Check results.
  236. ASSERT_STREQ( "Games", pResult1 ) << "Could not find character.";
  237. ASSERT_EQ( 0, pResult2 ) << "Should not have found character,";
  238. }
  239. //-----------------------------------------------------------------------------
  240. TEST( PlatformStringTests, dStrspnTest )
  241. {
  242. char source[] = { "Garage_Games!" };
  243. // Find.
  244. const S32 result = (S32)dStrspn( source, "Gargeams" );
  245. // Check results.
  246. ASSERT_EQ( 6, result ) << "Invalid index for string find.";
  247. }
  248. //-----------------------------------------------------------------------------
  249. TEST( PlatformStringTests, dStrcspnTest )
  250. {
  251. char source[] = { "Garage_Games!" };
  252. // Find.
  253. const S32 result = (S32)dStrcspn( source, "_!" );
  254. // Check results.
  255. ASSERT_EQ( 6, result ) << "Invalid index for string find.";
  256. }
  257. //-----------------------------------------------------------------------------
  258. TEST( PlatformStringTests, dStrstrTest )
  259. {
  260. char source1[] = { "GarageGames" };
  261. char source2[] = { "Games" };
  262. // Find.
  263. char* pResult = dStrstr( source1, source2 );
  264. // Check results.
  265. ASSERT_STREQ( "Games", pResult ) << "Could not find string.";
  266. }
  267. //-----------------------------------------------------------------------------
  268. TEST( PlatformStringTests, dStrstrCONSTTest )
  269. {
  270. char source1[] = { "GarageGames" };
  271. char source2[] = { "Games" };
  272. // Find.
  273. const char* pResult = dStrstr( (const char*)source1, (const char*)source2 );
  274. // Check results.
  275. ASSERT_STREQ( "Games", pResult ) << "Could not find string.";
  276. }
  277. //-----------------------------------------------------------------------------
  278. TEST( PlatformStringTests, dStrtokTest )
  279. {
  280. char source[] = { "Mich,Melv\nKyle\tRichard\nRon" };
  281. char separators[] = { ",\n\t\n" };
  282. // Find.
  283. char* pResult1 = dStrtok( source, separators );
  284. char* pResult2 = dStrtok( NULL, separators );
  285. char* pResult3 = dStrtok( NULL, separators );
  286. char* pResult4 = dStrtok( NULL, separators );
  287. char* pResult5 = dStrtok( NULL, separators );
  288. char* pResult6 = dStrtok( NULL, separators );
  289. // Check results.
  290. ASSERT_STREQ( "Mich", pResult1 ) << "Token find is incorrect.";
  291. ASSERT_STREQ( "Melv", pResult2 ) << "Token find is incorrect.";
  292. ASSERT_STREQ( "Kyle", pResult3 ) << "Token find is incorrect.";
  293. ASSERT_STREQ( "Richard", pResult4 ) << "Token find is incorrect.";
  294. ASSERT_STREQ( "Ron", pResult5 ) << "Token find is incorrect.";
  295. ASSERT_EQ( 0, pResult6 ) << "Token find is incorrect.";
  296. }
  297. //-----------------------------------------------------------------------------
  298. TEST( PlatformStringTests, dStrrevTest )
  299. {
  300. char destination[] = { "GarageGames" };
  301. // Find.
  302. const S32 result = dStrrev( destination );
  303. // Check results.
  304. ASSERT_STREQ( "semaGegaraG", destination ) << "String reverse is incorrect.";
  305. ASSERT_EQ( 5, result ) << "String reverse is incorrect.";
  306. }
  307. //-----------------------------------------------------------------------------
  308. TEST( PlatformStringTests, dAtoiTest )
  309. {
  310. char source1[] = { "16384" };
  311. char source2[] = { "-16384" };
  312. char source3[] = { "256.5" };
  313. char source4[] = { "-256.5" };
  314. // Find.
  315. const S32 result1 = dAtoi( source1 );
  316. const S32 result2 = dAtoi( source2 );
  317. const S32 result3 = dAtoi( source3 );
  318. const S32 result4 = dAtoi( source4 );
  319. // Check results.
  320. ASSERT_EQ( 16384, result1 ) << "Conversion incorrect.";
  321. ASSERT_EQ( -16384, result2 ) << "Conversion incorrect.";
  322. ASSERT_EQ( 256, result3 ) << "Conversion incorrect.";
  323. ASSERT_EQ( -256, result4 ) << "Conversion incorrect.";
  324. }
  325. //-----------------------------------------------------------------------------
  326. TEST( PlatformStringTests, dAtofTest )
  327. {
  328. char source1[] = { "123.45" };
  329. char source2[] = { "-123.45" };
  330. char source3[] = { "256.0" };
  331. char source4[] = { "-256.0" };
  332. // Find.
  333. const F32 result1 = dAtof( source1 );
  334. const F32 result2 = dAtof( source2 );
  335. const F32 result3 = dAtof( source3 );
  336. const F32 result4 = dAtof( source4 );
  337. // Check results.
  338. ASSERT_EQ( 123.45f, result1 ) << "Conversion incorrect.";
  339. ASSERT_EQ( -123.45f, result2 ) << "Conversion incorrect.";
  340. ASSERT_EQ( 256.0f, result3 ) << "Conversion incorrect.";
  341. ASSERT_EQ( -256.0f, result4 ) << "Conversion incorrect.";
  342. }
  343. //-----------------------------------------------------------------------------
  344. TEST( PlatformStringTests, dAtobTest )
  345. {
  346. char source1[] = { "1" };
  347. char source2[] = { "0" };
  348. char source3[] = { "100" };
  349. char source4[] = { "-100" };
  350. char source5[] = { "true" };
  351. char source6[] = { "false" };
  352. char source7[] = { "I refute it thus!" };
  353. // Find.
  354. const bool result1 = dAtob( source1 );
  355. const bool result2 = dAtob( source2 );
  356. const bool result3 = dAtob( source3 );
  357. const bool result4 = dAtob( source4 );
  358. const bool result5 = dAtob( source5 );
  359. const bool result6 = dAtob( source6 );
  360. const bool result7 = dAtob( source7 );
  361. // Check results.
  362. ASSERT_EQ( true, result1 ) << "Conversion incorrect.";
  363. ASSERT_EQ( false, result2 ) << "Conversion incorrect.";
  364. ASSERT_EQ( true, result3 ) << "Conversion incorrect.";
  365. ASSERT_EQ( true, result4 ) << "Conversion incorrect.";
  366. ASSERT_EQ( true, result5 ) << "Conversion incorrect.";
  367. ASSERT_EQ( false, result6 ) << "Conversion incorrect.";
  368. ASSERT_EQ( false, result7 ) << "Conversion incorrect.";
  369. }
  370. //-----------------------------------------------------------------------------
  371. TEST( PlatformStringTests, dItoaTest )
  372. {
  373. char destination1[64];
  374. char destination2[64];
  375. char destination3[64];
  376. char destination4[64];
  377. // Find.
  378. const S32 result1 = dItoa( 16384, destination1 );
  379. const S32 result2 = dItoa( -16384, destination2 );
  380. const S32 result3 = dItoa( 256, destination3 );
  381. const S32 result4 = dItoa( -256, destination4 );
  382. // Check results.
  383. ASSERT_STREQ( "16384", destination1 ) << "Conversion incorrect.";
  384. ASSERT_STREQ( "-16384", destination2 ) << "Conversion incorrect.";
  385. ASSERT_STREQ( "256", destination3 ) << "Conversion incorrect.";
  386. ASSERT_STREQ( "-256", destination4 ) << "Conversion incorrect.";
  387. ASSERT_EQ( 5, result1 ) << "Conversion incorrect.";
  388. ASSERT_EQ( 5+1, result2 ) << "Conversion incorrect.";
  389. ASSERT_EQ( 3, result3 ) << "Conversion incorrect.";
  390. ASSERT_EQ( 3+1, result4 ) << "Conversion incorrect.";
  391. }
  392. //-----------------------------------------------------------------------------
  393. TEST( PlatformStringTests, dIsalnumTest )
  394. {
  395. char source1[] = { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" };
  396. char source2[] = { "!$%^&*()+-={}[]~#@':;?/>.<,|`" };
  397. // Check results on source#1.
  398. const S32 sourceLength1 = dStrlen( source1 );
  399. for ( S32 index = 0; index < sourceLength1; ++index )
  400. {
  401. ASSERT_EQ( true, dIsalnum(source1[index]) );
  402. }
  403. // Check results on source#2.
  404. const S32 sourceLength2 = dStrlen( source2 );
  405. for ( S32 index = 0; index < sourceLength2; ++index )
  406. {
  407. ASSERT_EQ( false, dIsalnum(source2[index]) );
  408. }
  409. }
  410. //-----------------------------------------------------------------------------
  411. TEST( PlatformStringTests, dIsalphaTest )
  412. {
  413. char source1[] = { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
  414. char source2[] = { "!$%^&*()+-={}[]~#@':;?/>.<,|`" };
  415. char source3[] = { "0123456789" };
  416. // Check results on source#1.
  417. const S32 sourceLength1 = dStrlen( source1 );
  418. for ( S32 index = 0; index < sourceLength1; ++index )
  419. {
  420. ASSERT_EQ( true, dIsalpha(source1[index]) );
  421. }
  422. // Check results on source#2.
  423. const S32 sourceLength2 = dStrlen( source2 );
  424. for ( S32 index = 0; index < sourceLength2; ++index )
  425. {
  426. ASSERT_EQ( false, dIsalpha(source2[index]) );
  427. }
  428. // Check results on source#3.
  429. const S32 sourceLength3 = dStrlen( source3 );
  430. for ( S32 index = 0; index < sourceLength3; ++index )
  431. {
  432. ASSERT_EQ( false, dIsalpha(source3[index]) );
  433. }
  434. }
  435. //-----------------------------------------------------------------------------
  436. TEST( PlatformStringTests, dIsdigitTest )
  437. {
  438. char source1[] = { "0123456789" };
  439. char source2[] = { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
  440. char source3[] = { "!$%^&*()+-={}[]~#@':;?/>.<,|`" };
  441. // Check results on source#1.
  442. const S32 sourceLength1 = dStrlen( source1 );
  443. for ( S32 index = 0; index < sourceLength1; ++index )
  444. {
  445. ASSERT_EQ( true, dIsdigit(source1[index]) );
  446. }
  447. // Check results on source#2.
  448. const S32 sourceLength2 = dStrlen( source2 );
  449. for ( S32 index = 0; index < sourceLength2; ++index )
  450. {
  451. ASSERT_EQ( false, dIsdigit(source2[index]) );
  452. }
  453. // Check results on source#3.
  454. const S32 sourceLength3 = dStrlen( source3 );
  455. for ( S32 index = 0; index < sourceLength3; ++index )
  456. {
  457. ASSERT_EQ( false, dIsdigit(source3[index]) );
  458. }
  459. }
  460. //-----------------------------------------------------------------------------
  461. TEST( PlatformStringTests, dIsspaceTest )
  462. {
  463. char source1[] = { "\t\r " };
  464. char source2[] = { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" };
  465. char source3[] = { "!$%^&*()+-={}[]~#@':;?/>.<,|`" };
  466. // Check results on source#1.
  467. const S32 sourceLength1 = dStrlen( source1 );
  468. for ( S32 index = 0; index < sourceLength1; ++index )
  469. {
  470. ASSERT_EQ( true, dIsspace(source1[index]) );
  471. }
  472. // Check results on source#2.
  473. const S32 sourceLength2 = dStrlen( source2 );
  474. for ( S32 index = 0; index < sourceLength2; ++index )
  475. {
  476. ASSERT_EQ( false, dIsspace(source2[index]) );
  477. }
  478. // Check results on source#3.
  479. const S32 sourceLength3 = dStrlen( source3 );
  480. for ( S32 index = 0; index < sourceLength3; ++index )
  481. {
  482. ASSERT_EQ( false, dIsspace(source3[index]) );
  483. }
  484. }
  485. #endif
  486. #endif // TORQUE_SHIPPING