blob: c60f1fba16793d67079577399e42f7700da0e973 [file] [log] [blame]
iproctor9a41a0c2007-07-16 21:59:24 +00001open Thrift;;
2open ThriftTest_types;;
3
4let s = new TSocket.t "127.0.0.1" 9090;;
5let p = new TBinaryProtocol.t s;;
6let c = new ThriftTest.client p p;;
7let sod = function
8 Some v -> v
9 | None -> raise Thrift_error;;
10
11s#opn;
12print_string (c#testString "bya");
13print_char '\n';
14print_int (c#testByte 8);
15print_char '\n';
16print_int (c#testByte (-8));
17print_char '\n';
18print_int (c#testI32 32);
19print_char '\n';
20print_string (Int64.to_string (c#testI64 64L));
21print_char '\n';
22print_float (c#testDouble 3.14);
23print_char '\n';
24
25let l = [1;2;3;4] in
26 if l = (c#testList l) then print_string "list ok\n" else print_string "list fail\n";;
27let h = Hashtbl.create 5 in
28let a = Hashtbl.add h in
29 for i=1 to 10 do
30 a i (10*i)
31 done;
32 let r = c#testMap h in
33 for i=1 to 10 do
34 try
35 let g = Hashtbl.find r i in
36 print_int i;
37 print_char ' ';
38 print_int g;
39 print_char '\n'
40 with Not_found -> print_string ("Can't find "^(string_of_int i)^"\n")
41 done;;
42
43let s = Hashtbl.create 5 in
44let a = Hashtbl.add s in
45 for i = 1 to 10 do
46 a i true
47 done;
48 let r = c#testSet s in
49 for i = 1 to 10 do
50 try
51 let g = Hashtbl.find r i in
52 print_int i;
53 print_char '\n'
54 with Not_found -> print_string ("Can't find "^(string_of_int i)^"\n")
55 done;;
56try
57 c#testException "Xception"
58with Xception _ -> print_string "testException ok\n";;
59try
60 ignore(c#testMultiException "Xception" "bya")
61with Xception e -> Printf.printf "%d %s\n" (sod e#get_errorCode) (sod e#get_message);;
62
63