mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
0098375b73
248 changed files with 40027 additions and 0 deletions
44
Testing/test04.m
Normal file
44
Testing/test04.m
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
#include <objects/objects.h>
|
||||
|
||||
#define N 20
|
||||
|
||||
#if (sun && __svr4__)
|
||||
long lrand48();
|
||||
#define random lrand48
|
||||
#else
|
||||
long random();
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
short s, s1, s2;
|
||||
|
||||
Heap* heap = [[Heap alloc] initWithType:"s"];
|
||||
Array* array = [[Array alloc] initWithType:"s"];
|
||||
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
s = (short)random();
|
||||
[heap addElement:s];
|
||||
[array addElement:s];
|
||||
}
|
||||
[array sortContents];
|
||||
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
s1 = [heap removeFirstElement].short_int_u;
|
||||
s2 = [array removeLastElement].short_int_u;
|
||||
printf("(%d,%d) ", s1, s2);
|
||||
if (s1 != s2)
|
||||
exit(1);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/* cause an error */
|
||||
/* s = [heap elementAtIndex:999].short_int_u; */
|
||||
|
||||
[heap free];
|
||||
exit(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue