--- /dev/null
+#include<test_utils.h>
+
+#include<net.h>
+
+int main();
+static int setup_socket();
+static void net_send_basic_test();
+static void net_wait_basic_test();
+
+int main() {
+ setup_env();
+
+ net_send_basic_test();
+
+ clean_env();
+
+ return EXIT_SUCCESS;
+}
+
+static void net_send_basic_test() {
+ struct peer *info;
+ int sock;
+ char buf[100];
+ char expected[100];
+
+ sock = setup_socket();
+
+ memset(buf,1,100);
+ memset(expected,0,100);
+
+ assert(1==peer_init(&info));
+
+ assert(-1==net_send(-1,NULL,NULL,0));
+ assert(-1==net_send(sock,info,NULL,0));
+
+ assert(1==net_send(sock,info,buf,0));
+ assert(0==read(sock,expected,100));
+
+ assert(1==net_send(sock,info,buf,50));
+ assert(50==read(sock,expected,100));
+
+ assert(1==net_send(sock,info,buf,100));
+ assert(100==read(sock,expected,100));
+
+ close(sock);
+}
+
+static void net_wait_basic_test() {
+ struct peer *info;
+ int sock;
+ char buf[100];
+ char expected[100];
+
+ sock = setup_socket();
+
+ memset(buf,1,100);
+ memset(expected,0,100);
+
+ assert(1==peer_init(&info));
+
+ assert(-1==net_wait(-1,NULL,NULL,0));
+ assert(-1==net_wait(sock,NULL,NULL,0));
+ assert(-1==net_wait(sock,info,NULL,0));
+ assert(-1==net_wait(sock,info,expected,0));
+
+ assert(0==net_wait(sock,info,buf,100));
+
+ assert(50==write(sock,expected,50));
+
+ assert(0==net_wait(sock,info,buf,100));
+ assert(info->in!=NULL);
+ assert(info->in_size==50);
+ assert(memcmp(buf,expected,100)!=0);
+
+ assert(25==write(sock,expected,25));
+ assert(0==net_wait(sock,info,buf,100));
+ assert(info->in!=NULL);
+ assert(info->in_size==75);
+ assert(memcmp(buf,expected,100)!=0);
+
+ assert(25==write(sock,expected,25));
+
+ assert(1==net_wait(sock,info,buf,100));
+ assert(info->in==NULL);
+ assert(info->in_size==0);
+ assert(memcmp(buf,expected,100)==0);
+
+ close(sock);
+}
+
+static int setup_socket() {
+ return -1;
+}