@@ -548,13 +548,92 @@ void init_graph_6() {
548548// Tests with valid result
549549//====================
550550
551- void test_CFL_reachability_cycle (void ) {
551+ void test_CFL_indexed (void ) {
552+ #if LAGRAPH_SUITESPARSE
553+ setup ();
554+
555+ for (size_t mask = 0 ; mask < 16 ; mask ++ ) {
556+ GrB_Info retval ;
557+
558+ init_indexed_grammar ();
559+ init_graph_5 ();
560+ init_outputs ();
561+
562+ OK (run_algorithm (mask ));
563+ TEST_MSG ("MASK: %zx, ERROR: %s\n" , mask , msg );
564+ char * expected = output_to_str (4 );
565+ TEST_CHECK (strcmp ("(0, 2)" , expected ) == 0 );
566+ TEST_MSG ("Wrong result. Mask: %zx. Actual: %s" , mask , expected );
567+ LAGraph_Free ((void * * )& expected , msg );
568+
569+ free_workspace ();
570+ }
571+
572+ teardown ();
573+ #endif
574+ }
575+
576+ void test_CFL_indexed_simple (void ) {
577+ #if LAGRAPH_SUITESPARSE
578+ setup ();
579+
580+ for (size_t mask = 0 ; mask == 16 ; mask ++ ) {
581+ GrB_Info retval ;
582+
583+ init_indexed_grammar_simple ();
584+ init_graph_6 ();
585+ init_outputs ();
586+
587+ OK (run_algorithm (mask ));
588+ TEST_MSG ("MASK: %zx, ERROR: %s\n" , mask , msg );
589+ // for (size_t i = 0; i < grammar.nonterms_count + grammar.terms_count; i++) {
590+ // GxB_print(outputs[i], 2);
591+ // }
592+
593+ char * expected = output_to_str (3 );
594+ TEST_CHECK (strcmp ("(0, 1)" , expected ) == 0 );
595+ TEST_MSG ("Wrong result. Mask: %zx. Actual: %s" , mask , expected );
596+ LAGraph_Free ((void * * )& expected , msg );
597+
598+ free_workspace ();
599+ }
600+
601+ teardown ();
602+ #endif
603+ }
604+
605+ void test_CFL_indexed_simple_exploded (void ) {
552606#if LAGRAPH_SUITESPARSE
553607 setup ();
554608
555609 for (size_t mask = 0 ; mask < 16 ; mask ++ ) {
556610 GrB_Info retval ;
557611
612+ init_indexed_grammar_simple_exloded ();
613+ init_graph_6 ();
614+ init_outputs ();
615+
616+ OK (run_algorithm (mask ));
617+ TEST_MSG ("MASK: %zx, ERROR: %s\n" , mask , msg );
618+ char * expected = output_to_str (3 );
619+ TEST_CHECK (strcmp ("(0, 1)" , expected ) == 0 );
620+ TEST_MSG ("Wrong result. Mask: %zx. Actual: %s" , mask , expected );
621+ LAGraph_Free ((void * * )& expected , msg );
622+
623+ free_workspace ();
624+ }
625+
626+ teardown ();
627+ #endif
628+ }
629+
630+ void test_CFL_reachability_cycle (void ) {
631+ #if LAGRAPH_SUITESPARSE
632+ setup ();
633+
634+ for (size_t mask = 15 ; mask == 15 ; mask ++ ) {
635+ GrB_Info retval ;
636+
558637 init_grammar_aS ();
559638 init_graph_one_cycle ();
560639 init_outputs ();
@@ -591,6 +670,27 @@ void test_CFL_reachability_two_cycle(void) {
591670#endif
592671}
593672
673+ void test_CFL_reachability_indexed_rules (void ) {
674+ #if LAGRAPH_SUITESPARSE
675+ setup ();
676+
677+ for (size_t mask = 0 ; mask < 16 ; mask ++ ) {
678+ GrB_Info retval ;
679+
680+ init_indexed_grammar ();
681+ init_graph_2 ();
682+ init_outputs ();
683+
684+ OK (run_algorithm (mask ));
685+ check_result ("(0, 1)" );
686+
687+ free_workspace ();
688+ }
689+
690+ teardown ();
691+ #endif
692+ }
693+
594694void test_CFL_reachability_labels_more_than_nonterms (void ) {
595695#if LAGRAPH_SUITESPARSE
596696 setup ();
@@ -739,11 +839,12 @@ void test_CFL_reachability_invalid_rules(void) {
739839 grammar .rules [0 ] =
740840 (LAGraph_rule_EWCNF ){.nonterm = 0 , .prod_A = -1 , .prod_B = 1 , .indexed_count = 0 };
741841 check_error (GrB_INVALID_VALUE , 0 );
742-
842+ printf ( "MSG: %s\n" , msg );
743843 // Rule [_ -> A B]
744844 grammar .rules [0 ] =
745845 (LAGraph_rule_EWCNF ){.nonterm = -1 , .prod_A = 1 , .prod_B = 2 , .indexed_count = 0 };
746846 check_error (GrB_INVALID_VALUE , 0 );
847+ printf ("MSG: %s\n" , msg );
747848
748849 // Rule [C -> A B], where C >= nonterms_count
749850 grammar .rules [0 ] =
@@ -814,18 +915,22 @@ void test_CFL_reachability_null_pointers(void) {
814915#endif
815916}
816917
817- TEST_LIST = {{"CFL_reachability_complex_grammar" , test_CFL_reachability_complex_grammar },
818- {"CFL_reachability_cycle" , test_CFL_reachability_cycle },
819- {"CFL_reachability_two_cycle" , test_CFL_reachability_two_cycle },
820- {"CFL_reachability_labels_more_than_nonterms" ,
821- test_CFL_reachability_labels_more_than_nonterms },
822- {"CFL_reachability_tree" , test_CFL_reachability_tree },
823- {"CFL_reachability_line" , test_CFL_reachability_line },
824- {"CFL_reachability_two_nodes_cycle" , test_CFL_reachability_two_nodes_cycle },
825- {"test_CFL_reachability_with_empty_adj_matrix" ,
826- test_CFL_reachability_with_empty_adj_matrix },
827- {"CFG_reach_basic_invalid_rules" , test_CFL_reachability_invalid_rules },
918+ TEST_LIST = {
919+ {"CFG_reachability_indexed" , test_CFL_indexed },
920+ {"CFL_reachability_complex_grammar" , test_CFL_reachability_complex_grammar },
921+ {"CFG_reachability_indexed_simple" , test_CFL_indexed_simple },
922+ {"CFG_reachability_indexed_simple_exploded" , test_CFL_indexed_simple_exploded },
923+ {"CFL_reachability_cycle" , test_CFL_reachability_cycle },
924+ {"CFL_reachability_two_cycle" , test_CFL_reachability_two_cycle },
925+ {"CFL_reachability_labels_more_than_nonterms" ,
926+ test_CFL_reachability_labels_more_than_nonterms },
927+ {"CFL_reachability_tree" , test_CFL_reachability_tree },
928+ {"CFL_reachability_line" , test_CFL_reachability_line },
929+ {"CFL_reachability_two_nodes_cycle" , test_CFL_reachability_two_nodes_cycle },
930+ {"CFG_reach_basic_invalid_rules" , test_CFL_reachability_invalid_rules },
931+ {"test_CFL_reachability_with_empty_adj_matrix" ,
932+ test_CFL_reachability_with_empty_adj_matrix },
828933#if !defined (GRAPHBLAS_HAS_CUDA )
829- {"CFG_reachability_null_pointers" , test_CFL_reachability_null_pointers },
934+ {"CFG_reachability_null_pointers" , test_CFL_reachability_null_pointers },
830935#endif
831- {NULL , NULL }};
936+ {NULL , NULL }};
0 commit comments