public void GetNextAsBigint() { Tokenizer testSubject = new Tokenizer(long.MinValue.ToString()); long expected = long.MinValue; long actual = testSubject.GetNextAsBigint(); Assert.AreEqual(expected, actual); }
public void WrongDataType() { try { throw Tokenizer.WrongDataType(HsqlProviderType.JavaObject); } catch (HsqlDataSourceException hdse) { Assert.AreEqual(org.hsqldb.Trace.WRONG_DATA_TYPE, -hdse.ErrorCode); // TODO //Assert.IsTrue(hdse.Message.Contains("JAVA_OBJECT"), "message contains JAVA_OBJECT: " + hdse.Message); } Tokenizer testSubject = new Tokenizer("'foo'"); try { testSubject.GetNextAsBigint(); Assert.Fail("Failed to throw wrong data type exception getting 'foo' as BigInt"); } catch (AssertionException) { throw; } catch (HsqlDataSourceException hdse) { Assert.AreEqual(org.hsqldb.Trace.WRONG_DATA_TYPE, -hdse.ErrorCode); } testSubject = new Tokenizer("1.0"); try { testSubject.GetNextAsBigint(); Assert.Fail("Failed to throw wrong data type exception getting 1.0 as BigInt"); } catch (AssertionException) { throw; } catch (HsqlDataSourceException hdse) { Assert.AreEqual(org.hsqldb.Trace.WRONG_DATA_TYPE, -hdse.ErrorCode); } testSubject = new Tokenizer(long.MinValue.ToString()); try { testSubject.GetNextAsBigint(); } catch (HsqlDataSourceException hdse) { if (org.hsqldb.Trace.WRONG_DATA_TYPE == -hdse.ErrorCode) { Assert.Fail(""); } } }
/// <summary> /// Parses the given value by treating it as an HSQLDB SQL BIGINT literal. /// </summary> /// <param name="value">The value to parse.</param> /// <returns>a <c>System.Int64</c> representation of the string</returns> /// <exception cref="HsqlDataSourceException"> /// When a number format exception is encountered. /// </exception> public static long ParseBigInt(string value) { Tokenizer tokenizer = new Tokenizer(value); return tokenizer.GetNextAsBigint(); }