@@ -3035,11 +3035,17 @@ bool do_test_alter(int nclients, int alter_version, bool print_result, bool clea
30353035
30363036// MARK: -
30373037
3038+ int test_report (const char * description , bool result ){
3039+ printf ("%-24s %s\n" , description , (result ) ? "OK" : "FAILED" );
3040+ return result ? 0 : 1 ;
3041+ }
3042+
30383043int main (int argc , const char * argv []) {
30393044 sqlite3 * db = NULL ;
30403045 bool result = false;
30413046 bool print_result = false;
30423047 bool cleanup_databases = true;
3048+ int fail = 0 ;
30433049
30443050 // test in an in-memory database
30453051 int rc = sqlite3_open (":memory:" , & db );
@@ -3050,30 +3056,15 @@ int main(int argc, const char * argv[]) {
30503056
30513057 printf ("Testing CloudSync version %s\n" , CLOUDSYNC_VERSION );
30523058 printf ("===============================\n" );
3053-
3054- result = do_test_pk (db , 10000 , print_result );
3055- printf ("%-24s %s\n" , "PK Test:" , (result ) ? "OK" : "FAILED" );
3056-
3057- result = do_test_uuid (db , 1000 , print_result );
3058- printf ("%-24s %s\n" , "UUID Test:" , (result ) ? "OK" : "FAILED" );
3059-
3060- result = do_test_compare (db , print_result );
3061- printf ("%-24s %s\n" , "Comparison Test:" , (result ) ? "OK" : "FAILED" );
3062-
3063- result = do_test_rowid (50000 , print_result );
3064- printf ("%-24s %s\n" , "RowID Test:" , (result ) ? "OK" : "FAILED" );
3065-
3066- result = do_test_algo_names ();
3067- printf ("%-24s %s\n" , "Algo Names Test:" , (result ) ? "OK" : "FAILED" );
3068-
3069- result = do_test_dbutils ();
3070- printf ("%-24s %s\n" , "DBUtils Test:" , (result ) ? "OK" : "FAILED" );
3071-
3072- result = do_test_others (db );
3073- printf ("%-24s %s\n" , "Minor Test:" , (result ) ? "OK" : "FAILED" );
3074-
3075- result = do_test_error_cases (db );
3076- printf ("%-24s %s\n" , "Test Error Cases:" , (result ) ? "OK" : "FAILED" );
3059+
3060+ fail += test_report ("PK Test:" , do_test_pk (db , 10000 , print_result ));
3061+ fail += test_report ("UUID Test:" , do_test_uuid (db , 1000 , print_result ));
3062+ fail += test_report ("Comparison Test:" , do_test_compare (db , print_result ));
3063+ fail += test_report ("RowID Test:" , do_test_rowid (50000 , print_result ));
3064+ fail += test_report ("Algo Names Test:" , do_test_algo_names ());
3065+ fail += test_report ("DBUtils Test:" , do_test_dbutils ());
3066+ fail += test_report ("Minor Test:" , do_test_others (db ));
3067+ fail += test_report ("Test Error Cases:" , do_test_error_cases (db ));
30773068
30783069 int test_mask = TEST_INSERT | TEST_UPDATE | TEST_DELETE ;
30793070 int table_mask = TEST_PRIKEYS | TEST_NOCOLS ;
@@ -3082,76 +3073,38 @@ int main(int argc, const char * argv[]) {
30823073 #endif
30833074
30843075 // test local changes
3085- result = do_test_local (test_mask , table_mask , db , print_result );
3086- printf ("%-24s %s\n" , "Local Test:" , (result ) ? "OK" : "FAILED" );
3087-
3088- result = do_test_vtab (db );
3089- printf ("%-24s %s\n" , "VTab Test: " , (result ) ? "OK" : "FAILED" );
3090-
3091- result = do_test_functions (db , print_result );
3092- printf ("%-24s %s\n" , "Functions Test:" , (result ) ? "OK" : "FAILED" );
3093-
3094- result = do_test_internal_functions ();
3095- printf ("%-24s %s\n" , "Functions Test (Int):" , (result ) ? "OK" : "FAILED" );
3076+ fail += test_report ("Local Test:" , do_test_local (test_mask , table_mask , db , print_result ));
3077+ fail += test_report ("VTab Test: " , do_test_vtab (db ));
3078+ fail += test_report ("Functions Test:" , do_test_functions (db , print_result ));
3079+ fail += test_report ("Functions Test (Int):" , do_test_internal_functions ());
30963080
30973081 // close local database
30983082 db = close_db (db );
3099-
3100- // simulate remote merge
3101- result = do_test_merge (3 , print_result , cleanup_databases );
3102- printf ("%-24s %s\n" , "Merge Test:" , (result ) ? "OK" : "FAILED" );
3103-
3104- result = do_test_merge_2 (3 , TEST_PRIKEYS , print_result , cleanup_databases );
3105- printf ("%-24s %s\n" , "Merge Test 2:" , (result ) ? "OK" : "FAILED" );
3106-
3107- result = do_test_merge_2 (3 , TEST_NOCOLS , print_result , cleanup_databases );
3108- printf ("%-24s %s\n" , "Merge Test 3:" , (result ) ? "OK" : "FAILED" );
3109-
3110- result = do_test_merge_4 (2 , print_result , cleanup_databases );
3111- printf ("%-24s %s\n" , "Merge Test 4:" , (result ) ? "OK" : "FAILED" );
3112-
3113- result = do_test_merge_5 (2 , print_result , cleanup_databases , false);
3114- printf ("%-24s %s\n" , "Merge Test 5:" , (result ) ? "OK" : "FAILED" );
31153083
3116- result = do_test_merge_alter_schema_1 (2 , print_result , cleanup_databases , false);
3117- printf ("%-24s %s\n" , "Merge Alter Schema 1:" , (result ) ? "OK" : "FAILED" );
3118-
3119- result = do_test_merge_alter_schema_2 (2 , print_result , cleanup_databases , false);
3120- printf ("%-24s %s\n" , "Merge Alter Schema 2:" , (result ) ? "OK" : "FAILED" );
3121-
3122- result = do_test_prikey (2 , print_result , cleanup_databases );
3123- printf ("%-24s %s\n" , "PriKey NULL Test:" , (result ) ? "OK" : "FAILED" );
3124-
3125- result = do_test_double_init (2 , cleanup_databases );
3126- printf ("%-24s %s\n" , "Test Double Init:" , (result ) ? "OK" : "FAILED" );
3084+ // simulate remote merge
3085+ fail += test_report ("Merge Test:" , do_test_merge (3 , print_result , cleanup_databases ));
3086+ fail += test_report ("Merge Test 2:" , do_test_merge_2 (3 , TEST_PRIKEYS , print_result , cleanup_databases ));
3087+ fail += test_report ("Merge Test 3:" , do_test_merge_2 (3 , TEST_NOCOLS , print_result , cleanup_databases ));
3088+ fail += test_report ("Merge Test 4:" , do_test_merge_4 (2 , print_result , cleanup_databases ));
3089+ fail += test_report ("Merge Test 5:" , do_test_merge_5 (2 , print_result , cleanup_databases , false));
3090+ fail += test_report ("Merge Alter Schema 1:" , do_test_merge_alter_schema_1 (2 , print_result , cleanup_databases , false));
3091+ fail += test_report ("Merge Alter Schema 2:" , do_test_merge_alter_schema_2 (2 , print_result , cleanup_databases , false));
3092+ fail += test_report ("PriKey NULL Test:" , do_test_prikey (2 , print_result , cleanup_databases ));
3093+ fail += test_report ("Test Double Init:" , do_test_double_init (2 , cleanup_databases ));
31273094
31283095 // test grow-only set
3129- result = do_test_gos (6 , print_result , cleanup_databases );
3130- printf ("%-24s %s\n" , "Test GrowOnlySet:" , (result ) ? "OK" : "FAILED" );
3131-
3132- result = do_test_network_encode_decode (2 , print_result , cleanup_databases , false);
3133- printf ("%-24s %s\n" , "Test Network Enc/Dec:" , (result ) ? "OK" : "FAILED" );
3134-
3135- result = do_test_network_encode_decode (2 , print_result , cleanup_databases , true);
3136- printf ("%-24s %s\n" , "Test Network Enc/Dec 2:" , (result ) ? "OK" : "FAILED" );
3137-
3138- result = do_test_fill_initial_data (3 , print_result , cleanup_databases );
3139- printf ("%-24s %s\n" , "Test Fill Initial Data:" , (result ) ? "OK" : "FAILED" );
3140-
3141- result = do_test_alter (3 , 1 , print_result , cleanup_databases );
3142- printf ("%-24s %s\n" , "Test Alter Table 1:" , (result ) ? "OK" : "FAILED" );
3143-
3144- result = do_test_alter (3 , 2 , print_result , cleanup_databases );
3145- printf ("%-24s %s\n" , "Test Alter Table 2:" , (result ) ? "OK" : "FAILED" );
3146-
3147- result = do_test_alter (3 , 3 , print_result , cleanup_databases );
3148- printf ("%-24s %s\n" , "Test Alter Table 3:" , (result ) ? "OK" : "FAILED" );
3149-
3096+ fail += test_report ("Test GrowOnlySet:" , do_test_gos (6 , print_result , cleanup_databases ));
3097+ fail += test_report ("Test Network Enc/Dec:" , do_test_network_encode_decode (2 , print_result , cleanup_databases , false));
3098+ fail += test_report ("Test Network Enc/Dec 2:" , do_test_network_encode_decode (2 , print_result , cleanup_databases , true));
3099+ fail += test_report ("Test Fill Initial Data:" , do_test_fill_initial_data (3 , print_result , cleanup_databases ));
3100+ fail += test_report ("Test Alter Table 1:" , do_test_alter (3 , 1 , print_result , cleanup_databases ));
3101+ fail += test_report ("Test Alter Table 2:" , do_test_alter (3 , 2 , print_result , cleanup_databases ));
3102+ fail += test_report ("Test Alter Table 3:" , do_test_alter (3 , 3 , print_result , cleanup_databases ));
31503103
31513104finalize :
31523105 printf ("\n" );
31533106 if (rc != SQLITE_OK ) printf ("%s (%d)\n" , (db ) ? sqlite3_errmsg (db ) : "N/A" , rc );
31543107 db = close_db (db );
31553108
3156- return 0 ;
3109+ return fail ;
31573110}
0 commit comments