Tup.Cobar4Net.Parser.ServerParserTest.TestLastInsertId C# (CSharp) Method

TestLastInsertId() private method

private TestLastInsertId ( ) : void
return void
		public virtual void TestLastInsertId()
		{
			string stmt = " last_insert_iD()";
			int indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt
				, stmt.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.Length, indexAfterLastInsertIdFunc);
			stmt = " last_insert_iD ()";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.Length, indexAfterLastInsertIdFunc);
			stmt = " last_insert_iD ( /**/ )";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.Length, indexAfterLastInsertIdFunc);
			stmt = " last_insert_iD (  )  ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = " last_insert_id(  )";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = "last_iNsert_id(  ) ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = " last_insert_iD";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_i     ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_i    d ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_id (     ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_id(  d)     ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_id(  ) d    ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = " last_insert_id(d)";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_id(#\r\nd) ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(-1, indexAfterLastInsertIdFunc);
			stmt = " last_insert_id(#\n\r) ";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = " last_insert_id (#\n\r)";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = " last_insert_id(#\n\r)";
			indexAfterLastInsertIdFunc = ServerParseSelect.IndexAfterLastInsertIdFunc(stmt, stmt
				.IndexOf('l'));
			NUnit.Framework.Assert.AreEqual(stmt.LastIndexOf(')') + 1, indexAfterLastInsertIdFunc
				);
			stmt = "select last_insert_id(#\n\r)";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r) as id";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r) as `id`";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r) as 'id'";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)  id";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)  `id`";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)  'id'";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r) a";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			// NOTE: this should be invalid, ignore this bug
			stmt = "select last_insert_id(#\n\r) as";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r) asd";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			// NOTE: this should be invalid, ignore this bug
			stmt = "select last_insert_id(#\n\r) as 777";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			// NOTE: this should be invalid, ignore this bug
			stmt = "select last_insert_id(#\n\r)  777";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)as `77``7`";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)ass";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)as 'a'";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)as 'a\\''";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)as 'a'''";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "select last_insert_id(#\n\r)as 'a\"'";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 6));
			stmt = "   select last_insert_id(#\n\r) As 'a\"'";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.LastInsertId, ServerParseSelect
				.Parse(stmt, 9));
			stmt = "select last_insert_id(#\n\r)as 'a\"\\'";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.Other, ServerParseSelect.Parse(
				stmt, 6));
			stmt = "select last_insert_id(#\n\r)as `77``7` ,";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.Other, ServerParseSelect.Parse(
				stmt, 6));
			stmt = "select last_insert_id(#\n\r)as `77`7`";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.Other, ServerParseSelect.Parse(
				stmt, 6));
			stmt = "select last_insert_id(#\n\r) as,";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.Other, ServerParseSelect.Parse(
				stmt, 6));
			stmt = "select last_insert_id(#\n\r) ass a";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.Other, ServerParseSelect.Parse(
				stmt, 6));
			stmt = "select last_insert_id(#\n\r) as 'a";
			NUnit.Framework.Assert.AreEqual(ServerParseSelect.Other, ServerParseSelect.Parse(
				stmt, 6));
		}
	}