changed from scanf to strto* for parsing

This commit is contained in:
zimoch
2010-10-15 09:47:21 +00:00
parent 8dbe3abcdb
commit 318d0e389b

121
streamApp/tests/testDouble Executable file
View File

@ -0,0 +1,121 @@
#!/usr/bin/env tclsh
source streamtestlib.tcl
# Define records, protocol and startup (text goes to files)
# The asynPort "device" is connected to a network TCP socket
# Talk to the socket with send/receive/assure
# Send commands to the ioc shell with ioccmd
set records {
record (ai, "DZ:test1")
{
field (DTYP, "stream")
field (INP, "@test.proto test1 device")
}
record (ai, "DZ:test2")
{
field (DTYP, "stream")
field (INP, "@test.proto test2 device")
}
record (ai, "DZ:test3")
{
field (DTYP, "stream")
field (INP, "@test.proto test3 device")
}
record (ai, "DZ:test4")
{
field (DTYP, "stream")
field (INP, "@test.proto test4 device")
}
}
set protocol {
Terminator = LF;
@mismatch {out "mismatch";}
test1 {in "%f"; out "|%f|%10f|%.2f|%- 10.5f|% f|%+f|%-5.1f|%#f|"; }
test2 {in "%6f%(DESC)s"; out "|%g|%(DESC)s|"; }
test3 {in "% 6f%(DESC)s"; out "|%g|%(DESC)s|"; }
test4 {in "%#f"; out "%f"; }
}
set startup {
}
set debug 0
startioc
ioccmd {dbpf DZ:test1.PROC 1}
send "3.14159265359\n"
assure "|3.141593| 3.141593|3.14| 3.14159 | 3.141593|+3.141593|3.1 |3.141593|\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "-3.14159265359\n"
assure "|-3.141593| -3.141593|-3.14|-3.14159 |-3.141593|-3.141593|-3.1 |-3.141593|\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "0\n"
assure "|0.000000| 0.000000|0.00| 0.00000 | 0.000000|+0.000000|0.0 |0.000000|\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "NAN\n"
assure "|nan| nan|nan| nan | nan|+nan|nan |nan|\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "-Inf\n"
assure "|-inf| -inf|-inf|-inf |-inf|-inf|-inf |-inf|\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "1e6\n"
assure "|1000000.000000|1000000.000000|1000000.00| 1000000.00000| 1000000.000000|+1000000.000000|1000000.0|1000000.000000|\n"
ioccmd {dbpf DZ:test1.PROC 1}
send " - 3.14159265359\n"
assure "mismatch\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "bla\n"
assure "mismatch\n"
ioccmd {dbpf DZ:test1.PROC 1}
send " bla\n"
assure "mismatch\n"
ioccmd {dbpf DZ:test1.PROC 1}
send "-bla\n"
assure "mismatch\n"
ioccmd {dbpf DZ:test2.PROC 1}
send "3.14159265359\n"
assure "|3.1415|9265359|\n"
ioccmd {dbpf DZ:test2.PROC 1}
send " 3.14159265359\n"
assure "|3.1415|9265359|\n"
ioccmd {dbpf DZ:test2.PROC 1}
send " 10blabla\n"
assure "|10|blabla|\n"
ioccmd {dbpf DZ:test2.PROC 1}
send " 1\n"
assure "|1||\n"
ioccmd {dbpf DZ:test3.PROC 1}
send "3.14159265359\n"
assure "|3.1415|9265359|\n"
ioccmd {dbpf DZ:test3.PROC 1}
send " 3.14159265359\n"
assure "|3|.14159265359|\n"
ioccmd {dbpf DZ:test3.PROC 1}
send " 10blabla\n"
assure "|10|blabla|\n"
ioccmd {dbpf DZ:test3.PROC 1}
send " 1\n"
assure "|1||\n"
ioccmd {dbpf DZ:test4.PROC 1}
send "3.14159265359\n"
assure "3.141593\n"
ioccmd {dbpf DZ:test4.PROC 1}
send " -3.14159265359\n"
assure "-3.141593\n"
ioccmd {dbpf DZ:test4.PROC 1}
send " - 3.14159265359\n"
assure "-3.141593\n"
ioccmd {dbpf DZ:test4.PROC 1}
send " + 3.14159265359\n"
assure "3.141593\n"
ioccmd {dbpf DZ:test4.PROC 1}
send " +- 3.14159265359\n"
assure "mismatch\n"
finish