first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / octopi / library / tests_sockets / test_enum_adapters.cpp
1 /*
2 *  Name   : test_enumerate_adapters                                           *
3 *  Author : Chris Koeritz                                                     *
4 *  Purpose: Makes sure that the adapter enumerator function is working properly.
5 **
6 * Copyright (c) 2003-$now By Author.  This program is free software; you can  *
7 * redistribute it and/or modify it under the terms of the GNU General Public  *
8 * License as published by the Free Software Foundation; either version 2 of   *
9 * the License or (at your option) any later version.  This is online at:      *
10 *     http://www.fsf.org/copyleft/gpl.html                                    *
11 * Please send any updates to: fred@gruntose.com                               *
12 */
13
14 #include <application/hoople_main.h>
15 #include <basis/astring.h>
16 #include <basis/functions.h>
17 #include <loggers/critical_events.h>
18 #include <loggers/program_wide_logger.h>
19 #include <sockets/tcpip_stack.h>
20 #include <structures/static_memory_gremlin.h>
21 #include <structures/string_array.h>
22 #include <unit_test/unit_base.h>
23
24 #include <stdio.h>
25 //#include <string.h>
26
27 using namespace application;
28 using namespace basis;
29 using namespace loggers;
30 using namespace mathematics;
31 using namespace sockets;
32 using namespace structures;
33 using namespace textual;
34 using namespace timely;
35 using namespace unit_test;
36
37 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
38
39 class test_enum_adapaters : public virtual unit_base, virtual public application_shell
40 {
41 public:
42   test_enum_adapaters() {}
43   DEFINE_CLASS_NAME("test_enum_adapaters");
44   virtual int execute();
45 };
46
47 int test_enum_adapaters::execute()
48 {
49   FUNCDEF("execute");
50   tcpip_stack stack;
51
52   string_array ips;
53   bool did_it = stack.enumerate_adapters(ips);
54   if (!did_it)
55     deadly_error(class_name(), func, "could not enumerate adapters");
56
57   for (int i = 0; i < ips.length(); i++) {
58     log(a_sprintf("%d: ", i+1) + ips[i]);
59   }
60
61   return final_report();
62 }
63
64 HOOPLE_MAIN(test_enum_adapaters, )
65