Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. SQLiteConnection connection = ...;
  2.  
  3. using (SQLiteCommand command = new SQLiteCommand("SELECT ?, 0x10FFFFFFF, 0x1FFFFFFFF;", connection)) {
  4.  
  5.     // Add a command parameter with the value 0xFFFFFFFF
  6.     SQLiteParameter parameter = new SQLiteParameter();
  7.     parameter.Value = 0xFFFFFFFF;
  8.     command.Parameters.Add(parameter);
  9.  
  10.     SQLiteDataReader reader = command.ExecuteReader();
  11.     reader.Read();
  12.  
  13.     // Test getting 0xFFFFFFFF as Int64
  14.     // EXPECTED: 0xFFFFFFFF
  15.     // ACTUAL: -1
  16.     // Test FAILS
  17.     Assert.AreEqual(0xFFFFFFFF, reader.GetInt64(0));
  18.  
  19.     // Test getting 0x10FFFFFFF as Int16
  20.     // EXPECTED: OverflowException
  21.     // ACTUAL: OverflowException
  22.     // Test PASSES
  23.     try {
  24.         short value = reader.GetInt16(1);
  25.         Assert.Fail();
  26.     } catch (OverflowException) { }
  27.  
  28.     // Test getting 0x1FFFFFFFF as Int16
  29.     // EXPECTED: OverflowException
  30.     // ACTUAL: -1
  31.     // Test FAILS
  32.     try {
  33.         short value = reader.GetInt16(2);
  34.         Assert.Fail();
  35.     } catch (OverflowException) { }
  36.  
  37.     // Test getting 0x10FFFFFFF as Int32
  38.     // EXPECTED: OverflowException
  39.     // ACTUAL: 0xFFFFFFF
  40.     // Test FAILS
  41.     try {
  42.         int value = reader.GetInt32(1);
  43.         Assert.Fail();
  44.     } catch (OverflowException) { }
  45.  
  46.     // Test getting 0x1FFFFFFFF as Int32
  47.     // EXPECTED: OverflowException
  48.     // ACTUAL: -1
  49.     // Test FAILS
  50.     try {
  51.         int value = reader.GetInt32(2);
  52.         Assert.Fail();
  53.     } catch (OverflowException) { }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement