1 module rfc4506;
2 
3 public static import xdr;
4 
5 version (unittest)
6 {
7 	void safelog(string msg) @trusted @nogc nothrow
8 	{
9 		import core.stdc.stdio : printf;
10 
11 		printf("%.*s\n", msg.length, &msg[0]);
12 	}
13 
14 	import std.range.primitives : isOutputRange;
15 
16 	struct NullSink
17 	{
18 		void put(scope const(ubyte)[] bytes) @safe @nogc nothrow {}
19 	}
20 
21 	static assert(isOutputRange!(NullSink, ubyte));
22 
23 	void testFunctionality()()
24 	{
25 		NullSink nullSink;
26 
27 		xdr.put(nullSink, 4);
28 	}
29 
30 	unittest
31 	{
32 		testFunctionality();
33 		safelog("package works");
34 	}
35 
36 	@safe unittest
37 	{
38 		static if (__traits(compiles, testFunctionality()))
39 		{
40 			pragma(msg, "package is @safe");
41 		}
42 		else
43 		{
44 			pragma(msg, "package is not @safe");
45 		}
46 	}
47 
48 	@nogc unittest
49 	{
50 		static if (__traits(compiles, testFunctionality()))
51 		{
52 			pragma(msg, "package is @nogc");
53 		}
54 		else
55 		{
56 			pragma(msg, "package is not @nogc");
57 		}
58 	}
59 
60 	nothrow unittest
61 	{
62 		static if (__traits(compiles, testFunctionality()))
63 		{
64 			pragma(msg, "package is nothrow");
65 		}
66 		else
67 		{
68 			pragma(msg, "package is not nothrow");
69 		}
70 	}
71 }