summaryrefslogtreecommitdiff
path: root/src/tests/xb_test_expression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/xb_test_expression.cpp')
-rwxr-xr-xsrc/tests/xb_test_expression.cpp62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/tests/xb_test_expression.cpp b/src/tests/xb_test_expression.cpp
index ac1cde7..52c0b5c 100755
--- a/src/tests/xb_test_expression.cpp
+++ b/src/tests/xb_test_expression.cpp
@@ -384,6 +384,8 @@ int main( int argCnt, char **av )
{ "CHAR2", XB_CHAR_FLD, 7, 0 },
{ "DATE1", XB_DATE_FLD, 8, 0 },
{ "DATE2", XB_DATE_FLD, 8, 0 },
+ { "NULLDATE1", XB_DATE_FLD, 8, 0 },
+ { "NULLDATE2", XB_DATE_FLD, 8, 0 },
{ "NUM1", XB_NUMERIC_FLD, 9, 2 },
{ "",0,0,0 }
};
@@ -391,6 +393,10 @@ int main( int argCnt, char **av )
xbXBase x;
xbDbf * MyFile;
xbDate d;
+ xbDate dtTest1( "19890303" );
+ xbDate dtTest2( "20120708" );
+
+
#ifdef XB_LOGGING_SUPPORT
x.SetLogDirectory( PROJECT_LOG_DIR );
@@ -412,8 +418,6 @@ int main( int argCnt, char **av )
std::cout << "Default Data Directory is [" << x.GetDataDirectory().Str() << "]" << std::endl;
}
-// return 0;
-
#ifdef XB_DBF4_SUPPORT
MyFile = new xbDbf4( &x ); /* version 4 dbf file */
#else
@@ -421,13 +425,8 @@ int main( int argCnt, char **av )
#endif
-
-// return 0;
-
rc2 = MyFile->CreateTable( "ExpTest.DBF", "ExpTest", MyRecord, XB_OVERLAY, XB_MULTI_USER );
-// return 0;
-
iRc += TestMethod( po, "CreateTable()", rc2, XB_NO_ERROR );
iRc += TestMethod( po, "PutField()", MyFile->PutField( "CHAR1", "TEST" ), XB_NO_ERROR );
iRc += TestMethod( po, "PutField()", MyFile->PutField( "CHAR2", "TEST7B" ), XB_NO_ERROR );
@@ -437,8 +436,6 @@ int main( int argCnt, char **av )
iRc += TestMethod( po, "AppendRecord()", MyFile->AppendRecord(), XB_NO_ERROR );
-// return 0;
-
iRc += TestTokenMethod( &x, po, "EOX Test1", "", "", "", '?', XB_EXP_UNKNOWN, XB_NO_ERROR, XB_END_OF_EXPRESSION );
iRc += TestTokenMethod( &x, po, "EOX Test2 ", " ", "", "", '?', XB_EXP_UNKNOWN, XB_NO_ERROR, XB_END_OF_EXPRESSION );
@@ -634,49 +631,64 @@ int main( int argCnt, char **av )
iRc += TestMethod( &x, MyFile, po, "FuncTest41", "VAL( \"89\" )", (xbDouble) 89 );
iRc += TestMethod( &x, MyFile, po, "FuncTest42", "VAL( \"22.13 and some text\" )", (xbDouble) 22.13 );
iRc += TestMethod( &x, MyFile, po, "FuncTest43", "YEAR( STOD( \"20171017\" ))", (xbDouble) 2017 );
+ iRc += TestMethod( &x, MyFile, po, "FuncTest44", "CTOD( \"07\\08\\12\" )", dtTest2 );
+ xbDate dtToday;
+ dtToday.Sysdate();
+ iRc += TestMethod( &x, MyFile, po, "FuncTest45", "DATE()", dtToday );
+ dtTest2 = "28870625";
+ iRc += TestMethod( &x, MyFile, po, "FuncTest46", "DESCEND( DATE2 )", dtTest2 );
+ iRc += TestMethod( &x, MyFile, po, "FuncTest47", "STOD( \"19890303\" )", dtTest1 );
+
// date logic tests
- xbDate dtTest1( "19890303" );
- xbDate dtTest2( "20120708" );
+
iRc += TestMethod( &x, MyFile, po, "DateTest1", "ExpTest->DATE1", dtTest1 );
iRc += TestMethod( &x, MyFile, po, "DateTest2", "DATE1", dtTest1 );
+ dtTest2.Set( "20120708" );
iRc += TestMethod( &x, MyFile, po, "DateTest3", "ExpTest->DATE2", dtTest2 );
iRc += TestMethod( &x, MyFile, po, "DateTest4", "DATE2", dtTest2 );
iRc += TestMethod( &x, MyFile, po, "DateTest5", "DATE2 - DATE1", (xbDouble) 8528 );
+
dtTest1.Set( "20120705" );
iRc += TestMethod( &x, MyFile, po, "DateTest6", "DATE2 - 3", dtTest1 );
-
iRc += TestMethod( &x, MyFile, po, "DateTest7", "DATE2 -= 3", dtTest1 );
-
dtTest1.Set( "20120718" );
iRc += TestMethod( &x, MyFile, po, "DateTest8", "DATE2 + 10", dtTest1 );
iRc += TestMethod( &x, MyFile, po, "DateTest9", "DATE2 += 10", dtTest1 );
-
dtTest1.Set( "20120709" );
iRc += TestMethod( &x, MyFile, po, "DateTest10", "++DATE2", dtTest1 );
dtTest1.Set( "20120707" );
iRc += TestMethod( &x, MyFile, po, "DateTest11", "--DATE2", dtTest1 );
-
dtTest1.Set( "20120708" );
iRc += TestMethod( &x, MyFile, po, "DateTest12", "DATE2++", dtTest1 );
iRc += TestMethod( &x, MyFile, po, "DateTest13", "DATE2--", dtTest1 );
-
iRc += TestMethod( &x, MyFile, po, "DateTest14", "{07/08/12}", dtTest1 );
iRc += TestMethod( &x, MyFile, po, "DateTest15", "{07/08/2012}", dtTest1 );
-
iRc += TestMethod( &x, MyFile, po, "DateTest16", "{07/11/12} -3", dtTest1 );
iRc += TestMethod( &x, MyFile, po, "DateTest17", "{07/06/2012} + 2", dtTest1 );
- iRc += TestMethod( &x, MyFile, po, "FuncTest44", "CTOD( \"07\\08\\12\" )", dtTest1 );
-
- xbDate dtToday;
- iRc += TestMethod( &x, MyFile, po, "FuncTest45", "DATE()", dtToday );
-
- dtTest2 = "28870625";
- iRc += TestMethod( &x, MyFile, po, "FuncTest46", "DESCEND( DATE2 )", dtTest2 );
- iRc += TestMethod( &x, MyFile, po, "FuncTest47", "STOD( \"20120708\" )", dtTest1 );
+ iRc += TestMethod( &x, MyFile, po, "DateTest18", "ExpTest->NULLDATE1 = {07/06/2012}", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest19", "ExpTest->NULLDATE1 != {07/06/2012}", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest20", "ExpTest->NULLDATE1 < {07/06/2012}", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest21", "ExpTest->NULLDATE1 <= {07/06/2012}", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest22", "ExpTest->NULLDATE1 > {07/06/2012}", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest23", "ExpTest->NULLDATE1 >= {07/06/2012}", (xbBool) xbFalse );
+
+ iRc += TestMethod( &x, MyFile, po, "DateTest24", "{07/06/2012} = ExpTest->NULLDATE1", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest25", "{07/06/2012} != ExpTest->NULLDATE1", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest26", "{07/06/2012} < ExpTest->NULLDATE1", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest27", "{07/06/2012} <= ExpTest->NULLDATE1", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest28", "{07/06/2012} > ExpTest->NULLDATE1", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest29", "{07/06/2012} >= ExpTest->NULLDATE1", (xbBool) xbTrue );
+
+ iRc += TestMethod( &x, MyFile, po, "DateTest18", "ExpTest->NULLDATE1 = ExpTest->NULLDATE2", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest19", "ExpTest->NULLDATE1 != ExpTest->NULLDATE2", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest20", "ExpTest->NULLDATE1 < ExpTest->NULLDATE2", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest21", "ExpTest->NULLDATE1 <= ExpTest->NULLDATE2", (xbBool) xbTrue );
+ iRc += TestMethod( &x, MyFile, po, "DateTest22", "ExpTest->NULLDATE1 > ExpTest->NULLDATE2", (xbBool) xbFalse );
+ iRc += TestMethod( &x, MyFile, po, "DateTest23", "ExpTest->NULLDATE1 >= ExpTest->NULLDATE2", (xbBool) xbTrue );
// boolean logic tests
iRc += TestMethod( &x, MyFile, po, "LogicTest1", "3=5", (xbBool) xbFalse );