2222 * A feasible solution is guaranteed.
2323 * The last test case has 0 nodes and should be ignored. */
2424
25+ /* check-source does not like me to use scanf, how am I going to read the test
26+ * data otherwise? */
27+ #define myscanf scanf
28+
2529static int next_bit (s64 x )
2630{
2731 int b ;
@@ -37,7 +41,7 @@ static bool solve_case(const tal_t *ctx)
3741 tal_t * this_ctx = tal (ctx , tal_t );
3842
3943 int N_nodes , N_arcs ;
40- scanf ("%d %d\n" , & N_nodes , & N_arcs );
44+ myscanf ("%d %d\n" , & N_nodes , & N_arcs );
4145 printf ("Testcase %d\n" , c );
4246 printf ("nodes %d arcs %d\n" , N_nodes , N_arcs );
4347 if (N_nodes == 0 && N_arcs == 0 )
@@ -49,14 +53,14 @@ static bool solve_case(const tal_t *ctx)
4953 printf ("max nodes %d max arcs %d bit %d\n" , MAX_NODES , MAX_ARCS , DUAL_BIT );
5054
5155 struct graph * graph = graph_new (ctx , MAX_NODES , MAX_ARCS , DUAL_BIT );
52- assert (graph );
56+ CHECK (graph );
5357
5458 s64 * capacity = tal_arrz (ctx , s64 , MAX_ARCS );
5559 s64 * cost = tal_arrz (ctx , s64 , MAX_ARCS );
5660
5761 for (u32 i = 0 ; i < N_arcs ; i ++ ) {
5862 u32 from , to ;
59- scanf ("%" PRIu32 " %" PRIu32 " %" PRIi64 " %" PRIi64 , & from ,
63+ myscanf ("%" PRIu32 " %" PRIu32 " %" PRIi64 " %" PRIi64 , & from ,
6064 & to , & capacity [i ], & cost [i ]);
6165
6266 struct arc arc = {.idx = i };
@@ -70,19 +74,19 @@ static bool solve_case(const tal_t *ctx)
7074 struct node dst = {.idx = 1 };
7175
7276 s64 amount , best_cost ;
73- scanf ("%" PRIi64 " %" PRIi64 , & amount , & best_cost );
77+ myscanf ("%" PRIi64 " %" PRIi64 , & amount , & best_cost );
7478
7579 bool result = simple_mcf (ctx , graph , src , dst , capacity , amount , cost );
76- assert (result );
80+ CHECK (result );
7781
78- assert (node_balance (graph , src , capacity ) == - amount );
79- assert (node_balance (graph , dst , capacity ) == amount );
82+ CHECK (node_balance (graph , src , capacity ) == - amount );
83+ CHECK (node_balance (graph , dst , capacity ) == amount );
8084
8185 for (u32 i = 2 ; i < N_nodes ; i ++ )
82- assert (node_balance (graph , node_obj (i ), capacity ) == 0 );
86+ CHECK (node_balance (graph , node_obj (i ), capacity ) == 0 );
8387
8488 const s64 total_cost = flow_cost (graph , capacity , cost );
85- assert (total_cost == best_cost );
89+ CHECK (total_cost == best_cost );
8690
8791 tal_free (this_ctx );
8892 return true;
@@ -97,7 +101,7 @@ int main(int argc, char *argv[])
97101 common_setup (argv [0 ]);
98102 freopen ("plugins/askrene/test/data/linear_mcf" , "r" , stdin );
99103 tal_t * ctx = tal (NULL , tal_t );
100- assert (ctx );
104+ CHECK (ctx );
101105
102106 /* One test case after another. The last test case has N number of nodes
103107 * and arcs equal to 0 and must be ignored. */
0 commit comments