public void SelectParsing()
{
DataTable T = new DataTable("test");
DataColumn C = new DataColumn("name");
T.Columns.Add(C);
C = new DataColumn("age");
C.DataType = typeof(int);
T.Columns.Add(C);
C = new DataColumn("id");
T.Columns.Add(C);
DataSet Set = new DataSet("TestSet");
Set.Tables.Add(T);
DataRow Row = null;
for (int i = 0; i < 100; i++)
{
Row = T.NewRow();
Row[0] = "human" + i;
Row[1] = i;
Row[2] = i;
T.Rows.Add(Row);
}
Row = T.NewRow();
Row[0] = "h*an";
Row[1] = 1;
Row[2] = 1;
T.Rows.Add(Row);
Assert.Equal(12, T.Select("age<=10").Length);
Assert.Equal(12, T.Select("age\n\t<\n\t=\t\n10").Length);
try
{
T.Select("name = 1human ");
Assert.False(true);
}
catch (SyntaxErrorException e)
{
// missing operand after 'human' operand
Assert.Equal(typeof(SyntaxErrorException), e.GetType());
}
try
{
T.Select("name = 1");
Assert.False(true);
}
catch (EvaluateException e)
{
// Cannot perform '=' operation between string and Int32
Assert.Equal(typeof(EvaluateException), e.GetType());
}
Assert.Equal(1, T.Select("age = '13'").Length);
}