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 
26 using namespace application;
27 using namespace basis;
28 using namespace loggers;
29 using namespace mathematics;
30 using namespace sockets;
31 using namespace structures;
32 using namespace textual;
33 using namespace timely;
34 using namespace unit_test;
35 
36 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
37 
38 class test_enum_adapaters : public virtual unit_base, virtual public application_shell
39 {
40 public:
41  test_enum_adapaters() {}
42  DEFINE_CLASS_NAME("test_enum_adapaters");
43  virtual int execute();
44 };
45 
46 int test_enum_adapaters::execute()
47 {
48  FUNCDEF("execute");
50 
51  string_array ips;
52  bool did_it = stack.enumerate_adapters(ips);
53  if (!did_it)
54  continuable_error(class_name(), func, "could not enumerate adapters");
55 
56  for (int i = 0; i < ips.length(); i++) {
57  log(a_sprintf("%d: ", i+1) + ips[i]);
58  }
59 
60  return final_report();
61 }
62 
63 HOOPLE_MAIN(test_enum_adapaters, )
64 
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 continuable_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