/* * TEST OPERATIONS */ static void test_activate(test_bench_t *bench, int32_t id) { polynomial_t *p; printf("[%"PRIu32"]: TEST_ACTIVATE: x%"PRId32"\n", ctr, id); add_active_poly(&bench->act, bench->ptable, id); push_record_poly(&bench->stack, id); p = bench->ptable->poly[id]; record_offset_poly(&bench->manager, id, id, p); ctr ++; }
// Used assert_true instead of assert to prevent compiler warnings int main(void) { uint32_t i; bool ok; init_rationals(); build_polys(); show_polys(); init_offset_manager(&mngr, NULL, notify_equality); /* * FIRST TESTS */ for (i=0; i<NPOLYS; i++) { record_offset_poly(&mngr, term[i], var[i], poly[i]); } printf("\n*** Initial state ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); offset_manager_increase_decision_level(&mngr); test_equality(var[3], var[4], 0, 123); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); offset_manager_backtrack(&mngr, 0); printf("\n*** After backtracking to level 0 ***\n"); print_ptable(&mngr); print_vtable(&mngr); offset_manager_increase_decision_level(&mngr); test_equality(var[3], -1, 1, 234); test_equality(var[3], var[4], 0, 123); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); offset_manager_backtrack(&mngr, 0); ok = offset_manager_propagate(&mngr); printf("\n*** After backtracking to level 0 ***\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); /* * SECOND TEST */ reset_offset_manager(&mngr); printf("\n*** After reset ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); for (i=0; i<NPOLYS/2; i++) { record_offset_poly(&mngr, term[i], var[i], poly[i]); } offset_manager_push(&mngr); printf("\n*** After push ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); while (i < NPOLYS) { record_offset_poly(&mngr, term[i], var[i], poly[i]); i ++; } printf("\n*** After adding all polys ****\n"); print_ptable(&mngr); print_vtable(&mngr); test_equality(var[5], var[3], 10, 111); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); offset_manager_pop(&mngr); printf("\n*** After pop ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); test_equality(var[4], var[3], 10, 111); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); /* * THIRD TEST */ reset_offset_manager(&mngr); printf("\n*** After reset ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); for (i=0; i<6; i++) { record_offset_poly(&mngr, term[i], var[i], poly[i]); } test_equality(var[5], var[3], 10, 111); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); offset_manager_push(&mngr); printf("\n*** After push ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); while (i < NPOLYS) { record_offset_poly(&mngr, term[i], var[i], poly[i]); i ++; } printf("\n*** After adding all polys ****\n"); print_ptable(&mngr); print_vtable(&mngr); test_equality(var[4], var[3], 10, 111); test_equality(-1, var[3], 56, 122); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); offset_manager_pop(&mngr); printf("\n*** After pop ****\n"); print_var2poly(&mngr); print_var2offset_var(&mngr); print_ptable(&mngr); print_vtable(&mngr); ok = offset_manager_propagate(&mngr); printf("\n*** After propagate ****\n"); print_ptable(&mngr); print_vtable(&mngr); assert_true(ok); delete_offset_manager(&mngr); delete_polys(); cleanup_rationals(); return 0; }