IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2006, 9:02:30 AM (19 years ago)
Author:
eugene
Message:

updated tests from mark pitts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.basic/test/sprintf.sh

    r6231 r10311  
    1 
    21list tests
    32 test1
    4  test2
    5  test3
    6  test4
     3 memtest1
    74end
    85
     6# Does sprintf work?
    97macro test1
    10  sprintf line "test %03d" 50
    11  if ("$line" == "test 050")
    12    $PASS = 1
    13  else
    14    $PASS = 0
     8 $PASS = 1
     9
     10 local test_var
     11
     12 sprint test_var "%7s %5.2f %9.3e" float 34.5 12630000
     13
     14 if ("$test_var" != "  float 34.50 1.263e+07")
     15  $PASS = 0
    1516 end
     17
    1618end
    1719
    18 macro test2
    19  sprintf line "test %6.3f" 123.45678
    20  if ("$line" == "test 123.457")
    21    $PASS = 1
    22  else
     20# Memory test
     21macro memtest1
     22
     23 local i
     24
     25 list word -x "ps -p $PID -o rss"
     26 $startmem = $word:1
     27
     28 for i 0 10000
     29  sprint test_var "%7s %5.2f %9.3e" float 34.5 12630000
     30 end   
     31 
     32 list word -x "ps -p $PID -o rss"
     33 $endmem = $word:1
     34
     35 $PASS = 1
     36
     37 if ($endmem - $startmem > 10)
    2338   $PASS = 0
     39   echo "growth: {$endmem-$startmem}"
     40   echo "kB/loop: {($endmem-$startmem)/10000}"
    2441 end
     42
    2543end
    26 
    27 macro test3
    28  sprintf line "test %x" 32
    29  if ("$line" == "test 20")
    30    $PASS = 1
    31  else
    32    $PASS = 0
    33  end
    34 end
    35 
    36 macro test4
    37  sprintf line "test %10s" foobar
    38  if ("$line" == "test     foobar")
    39    $PASS = 1
    40  else
    41    $PASS = 0
    42  end
    43 end
Note: See TracChangeset for help on using the changeset viewer.