ObjFW  Diff

Differences From Artifact [979544c90c]:

To Artifact [09e6956470]:


11
12
13
14
15
16
17
18

19
20


21

22
23

24
25
26

27







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
66
67




68
69

70
71
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"


@implementation TestsAppDelegate (OFDNSResolverTests)


- (void)DNSResolverTests

{
	void *pool = objc_autoreleasePoolPush();

	OFDNSResolver *resolver = [OFDNSResolver resolver];
	OFMutableString *staticHosts = [OFMutableString string];


	[OFStdOut setForegroundColor: [OFColor lime]];








	for (OFString *host in resolver.staticHosts) {
		OFString *IPs;

		if (staticHosts.length > 0)
			[staticHosts appendString: @"; "];

		IPs = [[resolver.staticHosts objectForKey: host]
		    componentsJoinedByString: @", "];

		[staticHosts appendFormat: @"%@=(%@)", host, IPs];
	}
	[OFStdOut writeFormat: @"[OFDNSResolver] Static hosts: %@\n",
	    staticHosts];

	[OFStdOut writeFormat: @"[OFDNSResolver] Name servers: %@\n",
	    [resolver.nameServers componentsJoinedByString: @", "]];

	[OFStdOut writeFormat: @"[OFDNSResolver] Local domain: %@\n",
	    resolver.localDomain];

	[OFStdOut writeFormat: @"[OFDNSResolver] Search domains: %@\n",
	    [resolver.searchDomains componentsJoinedByString: @", "]];

	[OFStdOut writeFormat: @"[OFDNSResolver] Timeout: %lf\n",
	    resolver.timeout];

	[OFStdOut writeFormat: @"[OFDNSResolver] Max attempts: %u\n",
	    resolver.maxAttempts];

	[OFStdOut writeFormat:
	    @"[OFDNSResolver] Min number of dots in absolute name: %u\n",
	    resolver.minNumberOfDotsInAbsoluteName];

	[OFStdOut writeFormat: @"[OFDNSResolver] Forces TCP: %u\n",
	    resolver.forcesTCP];


	[OFStdOut writeFormat:
	    @"[OFDNSResolver] Config reload interval: %lf\n",
	    resolver.configReloadInterval];





	objc_autoreleasePoolPop(pool);

}
@end







|
>

|
>
>
|
>

<
>



>
|
>
>
>
>
>
>
>












|
<

|
|
<
<
|
|
<
|

<
|
<
<
|
<
<
|
|
<
<
|
>

<
<
<
>
>
>
>

<
>


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55


56
57

58
59

60


61


62
63


64
65
66



67
68
69
70
71

72
73
74
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "ObjFW.h"
#import "ObjFWTest.h"

@interface OFDNSResolverTests: OTTestCase
@end

@implementation OFDNSResolverTests
+ (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary
{

	OFMutableArray *summary = [OFMutableArray array];
	OFDNSResolver *resolver = [OFDNSResolver resolver];
	OFMutableString *staticHosts = [OFMutableString string];

#define ADD(name, value)						\
	[summary addObject: [OFPair pairWithFirstObject: name		\
					   secondObject: value]];
#define ADD_DOUBLE(name, value)						\
	ADD(name, [OFNumber numberWithDouble: value])
#define ADD_UINT(name, value)						\
	ADD(name, [OFNumber numberWithUnsignedInt: value]);
#define ADD_BOOL(name, value)						\
	ADD(name, [OFNumber numberWithBool: value]);

	for (OFString *host in resolver.staticHosts) {
		OFString *IPs;

		if (staticHosts.length > 0)
			[staticHosts appendString: @"; "];

		IPs = [[resolver.staticHosts objectForKey: host]
		    componentsJoinedByString: @", "];

		[staticHosts appendFormat: @"%@=(%@)", host, IPs];
	}
	ADD(@"Static hosts", staticHosts)


	ADD(@"Name servers",
	    [resolver.nameServers componentsJoinedByString: @", "]);


	ADD(@"Local domain", resolver.localDomain);
	ADD(@"Search domains",

	    [resolver.searchDomains componentsJoinedByString: @", "]);


	ADD_DOUBLE(@"Timeout", resolver.timeout);


	ADD_UINT(@"Max attempts", resolver.maxAttempts);


	ADD_UINT(@"Min number of dots in absolute name",
	    resolver.minNumberOfDotsInAbsoluteName);


	ADD_BOOL(@"Forces TCP", resolver.forcesTCP);
	ADD_DOUBLE(@"Config reload interval", resolver.configReloadInterval);




#undef ADD
#undef ADD_DOUBLE
#undef ADD_UINT
#undef ADD_BOOL


	return summary;
}
@end