1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // used as mixin(import("test.d"));
19 void doTest(int sz
, string HashName
) (string
str, ulong hh
) {
22 enum HashStruct
= HashName
;
23 enum HashFn
= cast(char)(HashName
[0]+32)~HashName
[1..$]~sz
.stringof
;
24 enum HashRes
= ".result"~sz
.stringof
;
26 if (mixin(HashFn
~"(str)") != hh
) {
27 writeln(HashFn
, sz
, " fucked!");
30 foreach_reverse (immutable len
; 0..str.length
) {
32 auto hs
= mixin(HashStruct
~"()");
34 foreach (immutable pos
; len
..str.length
) hs
.put(str[pos
]);
35 auto res
= mixin("hs"~HashRes
);
37 writeln(HashStruct
, sz
, "(", len
, ") fucked!");
42 auto h0
= mixin(HashFn
~"(str[0..len])");
43 auto h1
= mixin(HashStruct
~"()");
44 foreach (immutable pos
; 0..len
) h1
.put(str[pos
]);
45 if (mixin("h1"~HashRes
) != h0
) {
46 writeln(HashStruct
, sz
, "ByOne(", len
, ") fucked!");