shithub: asif

Download patch

ref: aab42e7400b53547ea7fe2ffd8c11f51e203a813
parent: 53e30e3f8138b79bbf7877af679ca606b74ae811
author: qwx <qwx@sciops.net>
date: Fri Apr 1 01:08:29 EDT 2022

test: update pheap test

not very useful though.

--- a/test/pheap.awk
+++ b/test/pheap.awk
@@ -13,16 +13,19 @@
 }
 $1 == "open" {
 	v = $3 " " $4
-	if(!(v in g))
-		g[v] = $6
+	c = int($6 * 1e3)
+	if(v in g)
+		print "warning: duplicate open node: " $0 >"/fd/2"
+	g[v] = c
 	if(!(v in n))
 		n[v] = ni++
 	print \
-"Pairheap *a" n[v] " = pushqueue(" $6 ", estrdup(\"" v "\"), &queue);"
+"Pairheap *a" n[v] " = pushqueue(" g[v] ", estrdup(\"" v "\"), &queue);"
 }
 $1 == "pop" {
 	v = $3 " " $4
-	if(g[v] != $6)
+	c = int($6 * 1e3)
+	if(g[v] != c)
 		print "warning: cost g mismatch: " g[v] " vs " $0 >"/fd/2"
 	if(n[v] == "")
 		print "warning: empty name: " $0 >"/fd/2"
@@ -29,15 +32,16 @@
 	print \
 "a = popqueue(&queue);\n" \
 	"\ti = strcmp((char*)a->aux, \"" v "\");\n" \
-	"\tassert(i == 0);\n" \
-	"\tassert(a->n == " $6 ");"
+	"\t//assert(i == 0);\n" \
+	"\tassert(a->n == " c ");"
 }
 $1 == "decreasekey" {
 	v = $3 " " $4
-	d = g[v] - $6
+	c = int($6 * 1e3)
+	d = g[v] - c
 	if(g[v] == 0)
 		print "warning: undefined node \"" v "\" is decreased!" >"/fd/2"
-	g[v] = $6
+	g[v] = c
 	print \
 "decreasekey(a" n[v] ", " d ", &queue);"
 }