mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
remove testmap.c
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
all : test testmap
|
||||
all : test
|
||||
|
||||
test : connection.c test.c
|
||||
gcc -g -Wall -o $@ $^
|
||||
|
||||
testmap : testmap.c map.c
|
||||
gcc -g -Wall -o $@ $^
|
||||
|
||||
clean :
|
||||
rm test testmap
|
||||
rm test
|
||||
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "map.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX 2000
|
||||
|
||||
static void
|
||||
test(struct map *m) {
|
||||
int a[MAX * 2];
|
||||
int i;
|
||||
int s = 0;
|
||||
for (i=0;i<MAX*2;i++) {
|
||||
int inc = rand() % 3 + 1;
|
||||
s += inc;
|
||||
a[i] = s;
|
||||
}
|
||||
for (i=0;i<MAX * 2;i++) {
|
||||
int x = rand()%(MAX*2);
|
||||
int y = rand()%(MAX*2);
|
||||
int temp = a[x];
|
||||
a[x] = a[y];
|
||||
a[y] = temp;
|
||||
}
|
||||
for (i=0;i<MAX;i++) {
|
||||
map_insert(m, a[i], i);
|
||||
}
|
||||
for (i=0;i<MAX;i++) {
|
||||
int id = map_search(m,a[i]);
|
||||
assert(id == i);
|
||||
}
|
||||
for (i=0;i<MAX/2;i++) {
|
||||
map_erase(m, a[i]);
|
||||
}
|
||||
for (i=0;i<MAX/2;i++) {
|
||||
a[i] = a[i+MAX];
|
||||
map_insert(m,a[i],i);
|
||||
}
|
||||
for (i=0;i<MAX;i++) {
|
||||
int id = map_search(m,a[i]);
|
||||
assert(id == i);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main() {
|
||||
struct map * m = map_new(MAX);
|
||||
test(m);
|
||||
map_delete(m);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user