QNet/tests/unit/network.c

50 lines
1.6 KiB
C
Raw Permalink Normal View History

/*
* Copyright (C) Tristan Franssen, <tristanfranssen@strawhats.nl>.
*
* This software is licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License in the file LICENSE or at
* http://www.apache.org/licenses/LICENSE-2.0
*/
#include "unit/network.h"
#include "qnet/network.h"
QNET_TEST_IMPLEMENT(network_create_ip4_address,
struct sockaddr_in address;
QNetNetworkError error = qnet_ip4_address("127.0.0.1", 8080, &address);
if (error != QNET_NETWORK_ERROR_OK) {
return "Failed to create ip4 address, address invalid";
}
return NULL;
)
QNET_TEST_IMPLEMENT(network_create_invalid_ip4_address,
struct sockaddr_in address;
QNetNetworkError error = qnet_ip4_address("3012.23.54546.2.1", 8080, &address);
if (error != QNET_NETWORK_ERROR_INVALID_IP) {
return "Was able to create ip4 address with invalid ip";
}
return NULL;
)
QNET_TEST_IMPLEMENT(network_create_ip6_address,
struct sockaddr_in6 address;
QNetNetworkError error = qnet_ip6_address("0:0:0:0:0:0:0:1", 8080, &address);
if (error != QNET_NETWORK_ERROR_OK) {
return "Failed to create ip6 address, address invalid";
}
return NULL;
)
QNET_TEST_IMPLEMENT(network_create_invalid_ip6_address,
struct sockaddr_in6 address;
QNetNetworkError error = qnet_ip6_address("0:0:0:0:0:0:0:1:3:2:1", 8080, &address);
if (error != QNET_NETWORK_ERROR_INVALID_IP) {
return "Was able to create ip6 address with invalid ip";
}
return NULL;
)