feisty meow concerns codebase  2.140
test_enum_adapters.cpp
Go to the documentation of this file.
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 
15 #include <basis/astring.h>
16 #include <basis/functions.h>
19 #include <sockets/tcpip_stack.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");
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 
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
Definition: astring.h:440
int length() const
Returns the current reported length of the allocated C array.
Definition: array.h:115
Helpful functions for interacting with TCP/IP stacks.
Definition: tcpip_stack.h:38
An abstraction that represents a stack data structure.
Definition: stack.h:30
An array of strings with some additional helpful methods.
Definition: string_array.h:32
#define deadly_error(c, f, i)
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition: enhance_cpp.h:45
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition: enhance_cpp.h:57
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition: hoople_main.h:61
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
Definition: averager.h:21
Provides access to the operating system's socket methods.
Definition: base_address.h:26
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55
#include <time.h>
Definition: earth_time.cpp:37
Useful support functions for unit testing, especially within hoople.
Definition: unit_base.cpp:35