00001
#include "wvtest.h"
00002
#include "wvtimeutils.h"
00003
00004 #define private public
00005 #define protected public
00006
#include "wvstream.h"
00007
00008
#if WVSTREAMS_UNITTEST_FIXES_BUGS_FOUND_BELOW
00009
00010
WVTEST_MAIN()
00011 {
00012
WvStream s;
00013
char buf[1024];
00014
00015
00016
WVPASS(!s.
isreadable());
00017
WVPASS(!s.
iswritable());
00018
WVFAIL(s.
read(buf, 1024) != 0);
00019
WVPASS(s.
write(buf, 1024) == 1024);
00020
WVPASS(!s.
iswritable());
00021
WVPASS(!s.
isreadable());
00022
WVPASS(s.
isok());
00023
00024
00025
00026
WvTime t1 =
wvtime();
00027 s.
close();
00028
WvTime t2 =
wvtime();
00029
WVPASS(
msecdiff(t2, t1) >= 0);
00030
WVPASS(
msecdiff(t2, t1) < 1000);
00031
00032
00033
WVPASS(!s.
isok());
00034 }
00035
00036
00037
WVTEST_MAIN()
00038 {
00039
WvStream s;
00040
char buf[1024];
00041
00042
00043 s.
nowrite();
00044
WVPASS(s.
isok());
00045
WVFAIL(s.
write(buf, 1024) != 0);
00046 s.
noread();
00047
WVPASS(s.
isok());
00048 }
00049
00050
WVTEST_MAIN()
00051 {
00052
WvStream s;
00053
char buf[1024];
00054
00055
WVPASS(!s.
isreadable());
00056 s.
inbuf.putstr(
"a\n b \r\nline");
00057
WVPASS(s.
isreadable());
00058 s.
noread();
00059
WVPASS(s.
isreadable());
00060
00061
WVPASS(s.
read(buf, 2) == 2);
00062
char *line = s.
getline(0);
00063
WVPASS(line);
00064
WVPASS(line && !strcmp(line,
" b \r"));
00065 line = s.
getline(0);
00066
WVPASS(line);
00067
WVPASS(line && !strcmp(line,
"line"));
00068
WVPASS(!s.
getline(0));
00069
00070
WvTime t1 =
wvtime();
00071
WVPASS(!s.
getline(500));
00072
WvTime t2 =
wvtime();
00073
WVPASS(
msecdiff(t2, t1) >= 0);
00074
WVPASS(
msecdiff(t2, t1) < 400);
00075
00076 ::alarm(5);
00077
00078
00079 ::alarm(0);
00080 }
00081
#endif
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099