summaryrefslogtreecommitdiff
path: root/extension/rwarray.awk
blob: 1057b396ce326f62c96b833b98efaf22f3241c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
BEGIN {
	extension("./rwarray.so","dlload")

	while ((getline word < "/usr/share/dict/words") > 0)
		dict[word] = word word

	for (i in dict)
		printf("dict[%s] = %s\n", i, dict[i]) > "orig.out"
	close("orig.out");

	writea("orig.bin", dict)

	reada("orig.bin", dict)

	for (i in dict)
		printf("dict[%s] = %s\n", i, dict[i]) > "new.out"
	close("new.out");

	ret = system("cmp orig.out new.out")

	if (ret == 0)
		print "old and new are equal - GOOD"
	else
		print "old and new are not equal - BAD"

	if (ret == 0 && !("keepit" in ENVIRON))
		system("rm orig.bin orig.out new.out")
}