
list tests
 test1
 test2
 test3
 test4
 test5
end

# test using full range
macro test1
 $PASS = 1
 break -auto off

 create x 0 100
 set y = zero (x)
 y[50] = 1

 peak -q x y 0 100

 if ($peakpos != 50)
   $PASS = 0
 end
 if ($peaknum != 51)
   $PASS = 0
 end
 if ($peakval != 1)
   $PASS = 0
 end
end

# test using auto range
macro test2
 $PASS = 1
 break -auto off

 create x 0 100
 set y = zero (x)
 y[50] = 1

 peak -q x y 

 if ($peakpos != 50)
   $PASS = 0
 end
 if ($peaknum != 51)
   $PASS = 0
 end
 if ($peakval != 1)
   $PASS = 0
 end
end

# test using constrained range
macro test3
 $PASS = 1
 break -auto off

 create x 0 100
 set y = zero (x)
 y[60] = 2
 y[50] = 1
 y[40] = 2

 peak -q x y 45 55

 if ($peakpos != 50)
   $PASS = 0
 end
 if ($peaknum != 51)
   $PASS = 0
 end
 if ($peakval != 1)
   $PASS = 0
 end
end

# test memory usage
macro test4
 $PASS = 1
 break -auto off

 create x 0 100
 set y = zero (x)
 y[60] = 2
 y[50] = 1
 y[40] = 2

 echo "peak:"
 exec ps aux | grep mana | grep -v grep
 for i 0 100000
   peak -q x y 45 55
 end
 exec ps aux | grep mana | grep -v grep

 ## HOW do we test this?
end

# test memory usage
macro test5
 $PASS = 1
 break -auto off

 create x 0 100
 set y = zero (x)
 y[60] = 2
 y[50] = 1
 y[40] = 2

 echo "peak:"
 exec ps aux | grep mana | grep -v grep
 for i 0 1000
   peak x y 45 55
 end
 exec ps aux | grep mana | grep -v grep

 ## HOW do we test this?
end

