testString

Check string types in Keys.

testString
(
Keys...
)
(
size_t count
,)
if (
Keys.length != 0
)

Examples

version(showAssertTags) dbg();
   testString!(string)(512, 8);
   testString!(string)(512, 32);

test map to values of type bool

version(showAssertTags) dbg();
   alias Key = uint;
   alias Value = bool;

   auto map = radixTreeMap!(Key, Value);
   assert(map.empty);

   static assert(map.hasValue);
   map.insert(Key.init, Value.init);

test packing of set elements

1 version(showAssertTags) dbg();
2    auto set = radixTreeSet!(ulong);
3    enum N = HeptLeaf1.capacity;
4 
5    foreach (immutable i; 0 .. N)
6    {
7        assert(!set.contains(i));
8 
9        assert(set.insert(i));
10        assert(set.contains(i));
11 
12        assert(!set.insert(i));
13        assert(set.contains(i));
14    }
15 
16    foreach (immutable i; N .. 256)
17    {
18        assert(!set.contains(i));
19 
20        assert(set.insert(i));
21        assert(set.contains(i));
22 
23        assert(!set.insert(i));
24        assert(set.contains(i));
25    }
26 
27    foreach (immutable i; 256 .. 256 + N)
28    {
29        assert(!set.contains(i));
30 
31        assert(set.insert(i));
32        assert(set.contains(i));
33 
34        assert(!set.insert(i));
35        assert(set.contains(i));
36    }
37 
38    foreach (immutable i; 256 + N .. 256 + 256)
39    {
40        assert(!set.contains(i));
41 
42        assert(set.insert(i));
43        assert(set.contains(i));
44 
45        assert(!set.insert(i));
46        assert(set.contains(i));
47    }
1 version(showAssertTags) dbg();
2    auto set = radixTreeSet!(ubyte);
3    alias Set = typeof(set);
4 
5    foreach (immutable i; 0 .. HeptLeaf1.capacity)
6    {
7        assert(!set.contains(i));
8 
9        assert(set.insert(i));
10        assert(set.contains(i));
11 
12        assert(!set.insert(i));
13        assert(set.contains(i));
14 
15        immutable rootRef = set.root.peek!(HeptLeaf1);
16        assert(rootRef);
17    }
18 
19    foreach (immutable i; HeptLeaf1.capacity .. 256)
20    {
21        assert(!set.contains(i));
22 
23        assert(set.insert(i));
24        assert(set.contains(i));
25 
26        assert(!set.insert(i));
27        assert(set.contains(i));
28    }
1 version(showAssertTags) dbg();
2    import std.meta : AliasSeq;
3    foreach (T; AliasSeq!(ushort, uint))
4    {
5        auto set = radixTreeSet!(T);
6        alias Set = typeof(set);
7 
8        foreach (immutable i; 0 .. 256)
9        {
10            assert(!set.contains(i));
11 
12            assert(set.insert(i));
13            assert(set.contains(i));
14 
15            assert(!set.insert(i));
16            assert(set.contains(i));
17        }
18 
19        // 256
20        assert(!set.contains(256));
21 
22        assert(set.insert(256));
23        assert(set.contains(256));
24 
25        assert(!set.insert(256));
26        assert(set.contains(256));
27 
28        // 257
29        assert(!set.contains(257));
30 
31        assert(set.insert(257));
32        assert(set.contains(257));
33 
34        assert(!set.insert(257));
35        assert(set.contains(257));
36 
37        immutable rootRef = set.root.peek!(Set.DefaultBranchType*);
38        assert(rootRef);
39        immutable root = *rootRef;
40        assert(root.prefix.length == T.sizeof - 2);
41 
42    }

Meta