forked from github/server
fix memstream-based tests, new storage submodule.
This commit is contained in:
parent
2ddabc1477
commit
13a358005f
|
@ -101,13 +101,7 @@ static void test_memstream(CuTest *tc) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int val=0;
|
int val=0;
|
||||||
|
|
||||||
#ifdef FILESTREAMTEST
|
|
||||||
FILE *F;
|
|
||||||
F = fopen("test.dat", "wb");
|
|
||||||
fstream_init(&out, F);
|
|
||||||
#else
|
|
||||||
mstream_init(&out);
|
mstream_init(&out);
|
||||||
#endif
|
|
||||||
binstore_init(&store, &out);
|
binstore_init(&store, &out);
|
||||||
store.handle.data = &out;
|
store.handle.data = &out;
|
||||||
|
|
||||||
|
@ -115,11 +109,6 @@ static void test_memstream(CuTest *tc) {
|
||||||
WRITE_TOK(&store, "fortytwo");
|
WRITE_TOK(&store, "fortytwo");
|
||||||
WRITE_INT(&store, 42);
|
WRITE_INT(&store, 42);
|
||||||
|
|
||||||
#ifdef FILESTREAMTEST
|
|
||||||
fstream_done(&out);
|
|
||||||
F = fopen("test.dat", "rb");
|
|
||||||
fstream_init(&out, F);
|
|
||||||
#endif
|
|
||||||
out.api->rewind(out.handle);
|
out.api->rewind(out.handle);
|
||||||
READ_INT(&store, &val);
|
READ_INT(&store, &val);
|
||||||
READ_TOK(&store, buf, 1024);
|
READ_TOK(&store, buf, 1024);
|
||||||
|
@ -127,6 +116,7 @@ static void test_memstream(CuTest *tc) {
|
||||||
CuAssertStrEquals(tc, "fortytwo", buf);
|
CuAssertStrEquals(tc, "fortytwo", buf);
|
||||||
READ_INT(&store, &val);
|
READ_INT(&store, &val);
|
||||||
CuAssertIntEquals(tc, 42, val);
|
CuAssertIntEquals(tc, 42, val);
|
||||||
|
mstream_done(&out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_write_flag(CuTest *tc) {
|
static void test_write_flag(CuTest *tc) {
|
||||||
|
@ -135,24 +125,14 @@ static void test_write_flag(CuTest *tc) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
stream out = { 0 };
|
stream out = { 0 };
|
||||||
size_t len;
|
size_t len;
|
||||||
#ifdef FILESTREAMTEST
|
|
||||||
FILE *F;
|
|
||||||
F = fopen("test.dat", "wb");
|
|
||||||
fstream_init(&out, F);
|
|
||||||
#else
|
|
||||||
mstream_init(&out);
|
mstream_init(&out);
|
||||||
#endif
|
|
||||||
binstore_init(&store, &out);
|
binstore_init(&store, &out);
|
||||||
store.handle.data = &out;
|
store.handle.data = &out;
|
||||||
|
|
||||||
setup_curse(&fix, "gbdream");
|
setup_curse(&fix, "gbdream");
|
||||||
fix.c->flags = 42 | CURSE_ISNEW;
|
fix.c->flags = 42 | CURSE_ISNEW;
|
||||||
curse_write(fix.r->attribs, fix.r, &store);
|
curse_write(fix.r->attribs, fix.r, &store);
|
||||||
#ifdef FILESTREAMTEST
|
|
||||||
fstream_done(&out);
|
|
||||||
F = fopen("test.dat", "rb");
|
|
||||||
fstream_init(&out, F);
|
|
||||||
#endif
|
|
||||||
out.api->rewind(out.handle);
|
out.api->rewind(out.handle);
|
||||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
@ -162,11 +142,7 @@ static void test_write_flag(CuTest *tc) {
|
||||||
global.data_version = RELEASE_VERSION;
|
global.data_version = RELEASE_VERSION;
|
||||||
CuAssertIntEquals(tc, RELEASE_VERSION, global.data_version);
|
CuAssertIntEquals(tc, RELEASE_VERSION, global.data_version);
|
||||||
|
|
||||||
#ifdef FILESTREAMTEST
|
|
||||||
fstream_done(&out);
|
|
||||||
#else
|
|
||||||
mstream_done(&out);
|
mstream_done(&out);
|
||||||
#endif
|
|
||||||
binstore_done(&store);
|
binstore_done(&store);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,6 @@ int wrptr(char **ptr, size_t * size, size_t bytes)
|
||||||
if (bytes == 0) {
|
if (bytes == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (bytes < 0) {
|
|
||||||
*size = 0;
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
if (bytes <= *size) {
|
if (bytes <= *size) {
|
||||||
*ptr += bytes;
|
*ptr += bytes;
|
||||||
*size -= bytes;
|
*size -= bytes;
|
||||||
|
|
2
storage
2
storage
|
@ -1 +1 @@
|
||||||
Subproject commit 48768e4bef7ff28365487e047d3b910127c716d0
|
Subproject commit 2bcd3b1e64764321773672333bd133a61b35b840
|
Loading…
Reference in New Issue