Commits

Alexey Kishkin committed 3362862

add set_i32 test

Comments (0)

Files changed (1)

       assert_equal "\000" (let cargo = Buffer.create 1 in (set_i8 cargo 0; Buffer.contents cargo)); 
       assert_equal "\010" (let cargo = Buffer.create 1 in (set_i8 cargo 10; Buffer.contents cargo)); 
       assert_equal "\255" (let cargo = Buffer.create 1 in (set_i8 cargo 255; Buffer.contents cargo));
- (*     assert_raises (Invalid_argument _) (fun () -> let cargo = Buffer.create 1 in ignore(set_i8 cargo 256) ); *)
       );
    "set_i16" >:: (fun() ->  
-       assert_equal "\000\000" (let cargo = Buffer.create 1 in (set_i16 cargo 0; Buffer.contents cargo)); 
-       assert_equal "\000\010" (let cargo = Buffer.create 1 in (set_i16 cargo 10; Buffer.contents cargo)); 
-       assert_equal "\000\255" (let cargo = Buffer.create 1 in (set_i16 cargo 255; Buffer.contents cargo));
-       assert_equal "\001\000" (let cargo = Buffer.create 1 in (set_i16 cargo 256; Buffer.contents cargo));
-       assert_equal "\255\255" (let cargo = Buffer.create 1 in (set_i16 cargo 0xFFFF; Buffer.contents cargo));
-(*       assert_raises (Invalid_argument _) (fun () -> let cargo = Buffer.create 1 in ignore(set_i16 cargo 256) ); *)
+       assert_equal "\000\000" (let cargo = Buffer.create 2 in (set_i16 cargo 0; Buffer.contents cargo)); 
+       assert_equal "\000\010" (let cargo = Buffer.create 2 in (set_i16 cargo 10; Buffer.contents cargo)); 
+       assert_equal "\000\255" (let cargo = Buffer.create 2 in (set_i16 cargo 255; Buffer.contents cargo));
+       assert_equal "\001\000" (let cargo = Buffer.create 2 in (set_i16 cargo 256; Buffer.contents cargo));
+       assert_equal "\255\255" (let cargo = Buffer.create 2 in (set_i16 cargo 0xFFFF; Buffer.contents cargo));
+      );
+   "set_i32" >:: (fun() ->  
+       assert_equal "\000\000\000\000" (let cargo = Buffer.create 4 in (set_i32 cargo 0; Buffer.contents cargo)); 
+       assert_equal "\000\000\000\010" (let cargo = Buffer.create 4 in (set_i32 cargo 10; Buffer.contents cargo)); 
+       assert_equal "\000\000\000\255" (let cargo = Buffer.create 4 in (set_i32 cargo 255; Buffer.contents cargo));
+       assert_equal "\000\000\001\000" (let cargo = Buffer.create 4 in (set_i32 cargo 256; Buffer.contents cargo));
+       assert_equal "\000\000\255\255" (let cargo = Buffer.create 4 in (set_i32 cargo 0xFFFF; Buffer.contents cargo));
+       assert_equal "\000\001\000\000" (let cargo = Buffer.create 4 in (set_i32 cargo 0x10000; Buffer.contents cargo));
+       assert_equal "\000\255\255\255" (let cargo = Buffer.create 4 in (set_i32 cargo 0xFFFFFF; Buffer.contents cargo));
+       assert_equal "\001\000\000\000" (let cargo = Buffer.create 4 in (set_i32 cargo 0x1000000; Buffer.contents cargo));
       )
    ];;