get code to compile, failing Lua tests

This commit is contained in:
Enno Rehling 2016-02-13 07:50:06 +01:00
parent b09c6974c6
commit bbe8faee2b
3 changed files with 29 additions and 3 deletions

25
src/util/gamedata.test.c Normal file
View File

@ -0,0 +1,25 @@
#include <platform.h>
#include "gamedata.h"
#include <CuTest.h>
#include <tests.h>
#include <stdio.h>
static void test_gamedata(CuTest * tc)
{
gamedata *data;
data = gamedata_open("test.dat", "wb", 0);
CuAssertPtrNotNull(tc, data);
gamedata_close(data);
data = gamedata_open("test.dat", "rb", 0);
CuAssertPtrNotNull(tc, data);
gamedata_close(data);
CuAssertIntEquals(tc, 0, remove("test.dat"));
}
CuSuite *get_gamedata_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_gamedata);
return suite;
}

View File

@ -3,8 +3,8 @@
#include <md5.h> #include <md5.h>
#include <crypt_blowfish.h> #include <crypt_blowfish.h>
#include <drepper.h>
#include <mtrand.h> #include <mtrand.h>
#include <drepper.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -79,7 +79,7 @@ static const char * password_hash_i(const char * passwd, const char *input, int
salt_len = strlen(input); salt_len = strlen(input);
} }
assert(salt_len < MAXSALTLEN); assert(salt_len < MAXSALTLEN);
stpncpy(salt, input, salt_len); memcpy(salt, input, salt_len);
salt[salt_len] = 0; salt[salt_len] = 0;
} else { } else {
input = password_gensalt(salt, sizeof(salt)); input = password_gensalt(salt, sizeof(salt));

View File

@ -1,6 +1,7 @@
#include <platform.h> #include <platform.h>
#include <CuTest.h>
#include "password.h" #include "password.h"
#include <CuTest.h>
#include <string.h>
static void test_passwords(CuTest *tc) { static void test_passwords(CuTest *tc) {
const char *hash, *expect; const char *hash, *expect;