Skip to content

Commit

Permalink
refactor: Fix network test not using the strong typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
nurupo authored and iphydf committed Feb 9, 2024
1 parent 93c83fb commit 969e3a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions toxcore/network_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,49 @@ Network_Funcs const Network_Class::vtable = {
Method<net_freeaddrinfo_cb, Network_Class>::invoke<&Network_Class::freeaddrinfo>,
};

int Test_Network::close(void *obj, int sock) { return net->funcs->close(net->obj, sock); }
int Test_Network::accept(void *obj, int sock) { return net->funcs->accept(net->obj, sock); }
int Test_Network::bind(void *obj, int sock, const Network_Addr *addr)
int Test_Network::close(void *obj, Socket sock) { return net->funcs->close(net->obj, sock); }
Socket Test_Network::accept(void *obj, Socket sock) { return net->funcs->accept(net->obj, sock); }

Check warning on line 28 in toxcore/network_test_util.cc

View check run for this annotation

Codecov / codecov/patch

toxcore/network_test_util.cc#L27-L28

Added lines #L27 - L28 were not covered by tests
int Test_Network::bind(void *obj, Socket sock, const Network_Addr *addr)
{
return net->funcs->bind(net->obj, sock, addr);
}
int Test_Network::listen(void *obj, int sock, int backlog)
int Test_Network::listen(void *obj, Socket sock, int backlog)
{
return net->funcs->listen(net->obj, sock, backlog);
}
int Test_Network::recvbuf(void *obj, int sock) { return net->funcs->recvbuf(net->obj, sock); }
int Test_Network::recv(void *obj, int sock, uint8_t *buf, size_t len)
int Test_Network::recvbuf(void *obj, Socket sock) { return net->funcs->recvbuf(net->obj, sock); }

Check warning on line 37 in toxcore/network_test_util.cc

View check run for this annotation

Codecov / codecov/patch

toxcore/network_test_util.cc#L37

Added line #L37 was not covered by tests
int Test_Network::recv(void *obj, Socket sock, uint8_t *buf, size_t len)
{
return net->funcs->recv(net->obj, sock, buf, len);
}
int Test_Network::recvfrom(void *obj, int sock, uint8_t *buf, size_t len, Network_Addr *addr)
int Test_Network::recvfrom(void *obj, Socket sock, uint8_t *buf, size_t len, Network_Addr *addr)
{
return net->funcs->recvfrom(net->obj, sock, buf, len, addr);
}
int Test_Network::send(void *obj, int sock, const uint8_t *buf, size_t len)
int Test_Network::send(void *obj, Socket sock, const uint8_t *buf, size_t len)
{
return net->funcs->send(net->obj, sock, buf, len);
}
int Test_Network::sendto(
void *obj, int sock, const uint8_t *buf, size_t len, const Network_Addr *addr)
void *obj, Socket sock, const uint8_t *buf, size_t len, const Network_Addr *addr)
{
return net->funcs->sendto(net->obj, sock, buf, len, addr);
}
int Test_Network::socket(void *obj, int domain, int type, int proto)
Socket Test_Network::socket(void *obj, int domain, int type, int proto)
{
return net->funcs->socket(net->obj, domain, type, proto);
}
int Test_Network::socket_nonblock(void *obj, int sock, bool nonblock)
int Test_Network::socket_nonblock(void *obj, Socket sock, bool nonblock)
{
return net->funcs->socket_nonblock(net->obj, sock, nonblock);
}
int Test_Network::getsockopt(
void *obj, int sock, int level, int optname, void *optval, size_t *optlen)
void *obj, Socket sock, int level, int optname, void *optval, size_t *optlen)
{
return net->funcs->getsockopt(net->obj, sock, level, optname, optval, optlen);
}
int Test_Network::setsockopt(
void *obj, int sock, int level, int optname, const void *optval, size_t optlen)
void *obj, Socket sock, int level, int optname, const void *optval, size_t optlen)
{
return net->funcs->setsockopt(net->obj, sock, level, optname, optval, optlen);
}
Expand Down
26 changes: 13 additions & 13 deletions toxcore/network_test_util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ struct Network_Class {
class Test_Network : public Network_Class {
const Network *net = REQUIRE_NOT_NULL(os_network());

int close(void *obj, int sock) override;
int accept(void *obj, int sock) override;
int bind(void *obj, int sock, const Network_Addr *addr) override;
int listen(void *obj, int sock, int backlog) override;
int recvbuf(void *obj, int sock) override;
int recv(void *obj, int sock, uint8_t *buf, size_t len) override;
int recvfrom(void *obj, int sock, uint8_t *buf, size_t len, Network_Addr *addr) override;
int send(void *obj, int sock, const uint8_t *buf, size_t len) override;
int close(void *obj, Socket sock) override;
Socket accept(void *obj, Socket sock) override;
int bind(void *obj, Socket sock, const Network_Addr *addr) override;
int listen(void *obj, Socket sock, int backlog) override;
int recvbuf(void *obj, Socket sock) override;
int recv(void *obj, Socket sock, uint8_t *buf, size_t len) override;
int recvfrom(void *obj, Socket sock, uint8_t *buf, size_t len, Network_Addr *addr) override;
int send(void *obj, Socket sock, const uint8_t *buf, size_t len) override;
int sendto(
void *obj, int sock, const uint8_t *buf, size_t len, const Network_Addr *addr) override;
int socket(void *obj, int domain, int type, int proto) override;
int socket_nonblock(void *obj, int sock, bool nonblock) override;
void *obj, Socket sock, const uint8_t *buf, size_t len, const Network_Addr *addr) override;
Socket socket(void *obj, int domain, int type, int proto) override;
int socket_nonblock(void *obj, Socket sock, bool nonblock) override;
int getsockopt(
void *obj, int sock, int level, int optname, void *optval, size_t *optlen) override;
void *obj, Socket sock, int level, int optname, void *optval, size_t *optlen) override;
int setsockopt(
void *obj, int sock, int level, int optname, const void *optval, size_t optlen) override;
void *obj, Socket sock, int level, int optname, const void *optval, size_t optlen) override;
int getaddrinfo(void *obj, int family, Network_Addr **addrs) override;
int freeaddrinfo(void *obj, Network_Addr *addrs) override;
};
Expand Down

0 comments on commit 969e3a2

Please sign in to comment.