mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 09:26:21 +00:00
Mock otr module for cmd_otr tests
This commit is contained in:
46
tests/otr/mock_otr.c
Normal file
46
tests/otr/mock_otr.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "otr/otr.h"
|
||||
#include "config/account.h"
|
||||
|
||||
static void
|
||||
_mock_otr_keygen(ProfAccount *account)
|
||||
{
|
||||
check_expected(account);
|
||||
}
|
||||
|
||||
static char *
|
||||
_mock_otr_libotr_version(void)
|
||||
{
|
||||
return (char *)mock();
|
||||
}
|
||||
|
||||
void
|
||||
mock_otr_keygen(void)
|
||||
{
|
||||
otr_keygen = _mock_otr_keygen;
|
||||
}
|
||||
|
||||
void
|
||||
mock_otr_libotr_version(void)
|
||||
{
|
||||
otr_libotr_version = _mock_otr_libotr_version;
|
||||
}
|
||||
|
||||
void
|
||||
otr_keygen_expect(ProfAccount *account)
|
||||
{
|
||||
expect_memory(_mock_otr_keygen, account, account, sizeof(ProfAccount));
|
||||
}
|
||||
|
||||
void
|
||||
otr_libotr_version_returns(char *version)
|
||||
{
|
||||
will_return(_mock_otr_libotr_version, version);
|
||||
}
|
||||
12
tests/otr/mock_otr.h
Normal file
12
tests/otr/mock_otr.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef MOCK_OTR_H
|
||||
#define MOCK_OTR_H
|
||||
|
||||
#include "config/account.h"
|
||||
|
||||
void mock_otr_keygen(void);
|
||||
void otr_keygen_expect(ProfAccount *account);
|
||||
|
||||
void mock_otr_libotr_version(void);
|
||||
void otr_libotr_version_returns(char *version);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user