diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/fstrstd.cpp | 9 | ||||
-rw-r--r-- | src/tests/socketblock.cpp | 50 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/tests/fstrstd.cpp b/src/tests/fstrstd.cpp new file mode 100644 index 0000000..8dffcb6 --- /dev/null +++ b/src/tests/fstrstd.cpp | |||
@@ -0,0 +1,9 @@ | |||
1 | #include <iostream> | ||
2 | #include "bu/fstring.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | Bu::FString s("Hey there, dude.\n"); | ||
7 | |||
8 | std::cout << s << 5; | ||
9 | } | ||
diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp new file mode 100644 index 0000000..443b07e --- /dev/null +++ b/src/tests/socketblock.cpp | |||
@@ -0,0 +1,50 @@ | |||
1 | #include "bu/ito.h" | ||
2 | #include "bu/socket.h" | ||
3 | #include "bu/serversocket.h" | ||
4 | #include <stdio.h> | ||
5 | |||
6 | class TstServer : public Bu::Ito | ||
7 | { | ||
8 | public: | ||
9 | TstServer() : | ||
10 | s( 55678 ) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | virtual void *run() | ||
15 | { | ||
16 | Bu::Socket c = s.accept( 45, 0 ); | ||
17 | printf("TstServer: Accetped connection.\n"); fflush( stdout ); | ||
18 | |||
19 | sleep( 1 ); | ||
20 | printf("TstServer: Trying to read 10 bytes...\n"); fflush( stdout ); | ||
21 | |||
22 | char buf[10]; | ||
23 | size_t nRead = c.read( buf, 10 ); | ||
24 | printf("TstServer: Got %d bytes...\n", nRead ); fflush( stdout ); | ||
25 | |||
26 | printf("TstServer: Closing connection...\n"); fflush( stdout ); | ||
27 | c.close(); | ||
28 | |||
29 | return NULL; | ||
30 | } | ||
31 | |||
32 | Bu::ServerSocket s; | ||
33 | }; | ||
34 | |||
35 | int main() | ||
36 | { | ||
37 | TstServer ts; | ||
38 | |||
39 | ts.start(); | ||
40 | |||
41 | printf("main: Connecting to server.\n"); fflush( stdout ); | ||
42 | Bu::Socket s( "localhost", 55678 ); | ||
43 | |||
44 | printf("main: Sending 4 bytes.\n"); fflush( stdout ); | ||
45 | s.write( "aoeu", 4 ); | ||
46 | |||
47 | printf("main: Sleeping 10 seconds for good measure.\n"); fflush( stdout ); | ||
48 | sleep( 10 ); | ||
49 | } | ||
50 | |||