static gboolean do_tun_get_properties (char **argv) { int ifindex = parse_ifindex (*argv++); NMPlatformTunProperties props; if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("mode: %s\n", props.mode); if (props.owner == -1) printf ("owner: none\n"); else printf ("owner: %lu\n", (gulong) props.owner); if (props.group == -1) printf ("group: none\n"); else printf ("group: %lu\n", (gulong) props.group); printf ("no-pi: "); print_boolean (props.no_pi); printf ("vnet-hdr: "); print_boolean (props.vnet_hdr); printf ("multi-queue: "); print_boolean (props.multi_queue); return TRUE; }
/* * Routine: * Purpose: * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ int pr_s_promotion(void *pSrc) { struct W_PROMOTION_TBL *r; if (pSrc == NULL) r = &g_w_promotion; else r = pSrc; print_start(S_PROMOTION); print_varchar(P_PROMO_ID, r->p_promo_id, 1); print_varchar(P_PROMO_NAME, &r->p_promo_name[0], 1); print_date(P_START_DATE_ID, r->p_start_date_id, 1); print_date(P_START_DATE_ID, r->p_end_date_id, 1); print_decimal(P_COST, &r->p_cost, 1); print_integer(P_RESPONSE_TARGET, r->p_response_target, 1); print_boolean(P_CHANNEL_DMAIL, r->p_channel_dmail, 1); print_boolean(P_CHANNEL_EMAIL, r->p_channel_email, 1); print_boolean(P_CHANNEL_CATALOG, r->p_channel_catalog, 1); print_boolean(P_CHANNEL_TV, r->p_channel_tv, 1); print_boolean(P_CHANNEL_RADIO, r->p_channel_radio, 1); print_boolean(P_CHANNEL_PRESS, r->p_channel_press, 1); print_boolean(P_CHANNEL_EVENT, r->p_channel_event, 1); print_boolean(P_CHANNEL_DEMO, r->p_channel_demo, 1); print_varchar(P_CHANNEL_DETAILS, &r->p_channel_details[0], 1); print_varchar(P_PURPOSE, r->p_purpose, 1); print_boolean(P_DISCOUNT_ACTIVE, r->p_discount_active, 0); print_end(S_PROMOTION); return(0); }
/* * Routine: * Purpose: * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ int pr_w_customer(void *row) { struct W_CUSTOMER_TBL *r; if (row == NULL) r = &g_w_customer; else r = row; print_start(CUSTOMER); print_key(C_CUSTOMER_SK, r->c_customer_sk, 1); print_varchar(C_CUSTOMER_ID, r->c_customer_id, 1); print_key(C_CURRENT_CDEMO_SK, r->c_current_cdemo_sk, 1); print_key(C_CURRENT_HDEMO_SK, r->c_current_hdemo_sk, 1); print_key(C_CURRENT_ADDR_SK, r->c_current_addr_sk, 1); print_integer(C_FIRST_SHIPTO_DATE_ID, r->c_first_shipto_date_id, 1); print_integer(C_FIRST_SALES_DATE_ID, r->c_first_sales_date_id, 1); print_varchar(C_SALUTATION, r->c_salutation, 1); print_varchar(C_FIRST_NAME, r->c_first_name, 1); print_varchar(C_LAST_NAME, r->c_last_name, 1); print_boolean(C_PREFERRED_CUST_FLAG, r->c_preferred_cust_flag, 1); print_integer(C_BIRTH_DAY, r->c_birth_day, 1); print_integer(C_BIRTH_MONTH, r->c_birth_month, 1); print_integer(C_BIRTH_YEAR, r->c_birth_year, 1); print_varchar(C_BIRTH_COUNTRY, r->c_birth_country, 1); print_varchar(C_LOGIN, &r->c_login[0], 1); print_varchar(C_EMAIL_ADDRESS, &r->c_email_address[0], 1); print_integer(C_LAST_REVIEW_DATE, r->c_last_review_date, 0); print_end(CUSTOMER); return(0); }
static gboolean do_gre_get_properties (char **argv) { int ifindex = parse_ifindex (*argv++); NMPlatformGreProperties props; char addrstr[INET_ADDRSTRLEN]; if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("parent-ifindex: %u\n", props.parent_ifindex); printf ("input-flags: %u\n", props.input_flags); printf ("output-flags: %u\n", props.input_flags); printf ("input-key: %u\n", props.input_key); printf ("output-key: %u\n", props.output_key); if (props.local) inet_ntop (AF_INET, &props.local, addrstr, sizeof (addrstr)); else strcpy (addrstr, "-"); printf ("local: %s\n", addrstr); if (props.remote) inet_ntop (AF_INET, &props.remote, addrstr, sizeof (addrstr)); else strcpy (addrstr, "-"); printf ("remote: %s\n", addrstr); printf ("ttl: %u\n", props.ttl); printf ("tos: %u\n", props.tos); printf ("path-mtu-discovery: "); print_boolean (props.path_mtu_discovery); return TRUE; }
void print_object (STREAM stream, D instance, BOOL escape_p, int print_depth) { enum dylan_type_enum type = dylan_type(instance); switch (type) { case integer_type: print_integer(stream, instance, escape_p, print_depth); break; case character_type: print_character(stream, instance, escape_p, print_depth); break; case float_type: print_float (stream, instance, escape_p, print_depth); break; case dylan_boolean_type: print_boolean(stream, instance, escape_p, print_depth); break; case string_type: print_string (stream, instance, escape_p, print_depth); break; case vector_type: print_vector(stream, instance, escape_p, print_depth); break; case pair_type: print_pair(stream, instance, escape_p, print_depth); break; case empty_list_type: print_empty_list(stream, instance, escape_p, print_depth); break; case symbol_type: print_symbol(stream, instance, escape_p, print_depth); break; case simple_condition_type: print_simple_condition(stream, instance, escape_p, print_depth); break; case class_type: print_class(stream, instance, escape_p, print_depth); break; case function_type: print_function(stream, instance, escape_p, print_depth); break; case unknown_type: format(stream, "?%lx", instance); break; default: print_user_defined(stream, instance, escape_p, print_depth); break; } }
static gboolean do_vxlan_get_properties (char **argv) { int ifindex = parse_ifindex (*argv++); NMPlatformVxlanProperties props; char addrstr[INET6_ADDRSTRLEN]; if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("parent-ifindex: %u\n", props.parent_ifindex); printf ("id: %u\n", props.id); if (props.group) inet_ntop (AF_INET, &props.group, addrstr, sizeof (addrstr)); else if (props.group6.s6_addr[0]) inet_ntop (AF_INET6, &props.group6, addrstr, sizeof (addrstr)); else strcpy (addrstr, "-"); printf ("group: %s\n", addrstr); if (props.local) inet_ntop (AF_INET, &props.local, addrstr, sizeof (addrstr)); else if (props.local6.s6_addr[0]) inet_ntop (AF_INET6, &props.local6, addrstr, sizeof (addrstr)); else strcpy (addrstr, "-"); printf ("local: %s\n", addrstr); printf ("tos: %u\n", props.tos); printf ("ttl: %u\n", props.ttl); printf ("learning: "); print_boolean (props.learning); printf ("ageing: %u\n", props.ageing); printf ("limit: %u\n", props.limit); printf ("dst-port: %u\n", props.dst_port); printf ("src-port-min: %u\n", props.src_port_min); printf ("src-port-max: %u\n", props.src_port_max); printf ("proxy: "); print_boolean (props.proxy); printf ("rsc: "); print_boolean (props.rsc); printf ("l2miss: "); print_boolean (props.l2miss); printf ("l3miss: "); print_boolean (props.l3miss); return TRUE; }
static gboolean do_link_exists (char **argv) { gboolean value = !!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, argv[0]); print_boolean (value); return TRUE; }
static gboolean do_link_exists (char **argv) { gboolean value = nm_platform_link_exists (argv[0]); print_boolean (value); return TRUE; }
static gboolean do_ip6_route_get (char **argv) { int ifindex = parse_ifindex (*argv++); struct in6_addr network; int plen, metric; parse_ip6_address (*argv++, &network, &plen); metric = strtol (*argv++, NULL, 10); print_boolean (!!nm_platform_ip6_route_get (NM_PLATFORM_GET, ifindex, network, plen, metric)); return TRUE; }
static gboolean do_ip4_route_exists (char **argv) { int ifindex = parse_ifindex (*argv++); in_addr_t network; int plen, metric; parse_ip4_address (*argv++, &network, &plen); metric = strtol (*argv++, NULL, 10); print_boolean (nm_platform_ip4_route_exists (ifindex, network, plen, metric)); return TRUE; }
static gboolean do_macvlan_get_properties (char **argv) { int ifindex = parse_ifindex (*argv++); NMPlatformMacvlanProperties props; if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("parent: %d\n", props.parent_ifindex); printf ("mode: %s\n", props.mode); printf ("no-promisc: "); print_boolean (props.no_promisc); return TRUE; }
/* * Routine: * Purpose: * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ int pr_w_date(void *row) { char sQuarterName[7]; struct W_DATE_TBL *r; if (row == NULL) r = &g_w_date; else r = row; print_start(DATE); print_key(D_DATE_SK, r->d_date_sk, 1); print_varchar(D_DATE_ID, r->d_date_id, 1); /* output the same information in a different format */ print_date(D_DATE_SK, r->d_date_sk, 1); print_integer(D_MONTH_SEQ, r->d_month_seq, 1); print_integer(D_WEEK_SEQ, r->d_week_seq, 1); print_integer(D_QUARTER_SEQ, r->d_quarter_seq, 1); print_integer(D_YEAR, r->d_year, 1); print_integer(D_DOW, r->d_dow, 1); print_integer(D_MOY, r->d_moy, 1); print_integer(D_DOM, r->d_dom, 1); print_integer(D_QOY, r->d_qoy, 1); print_integer(D_FY_YEAR, r->d_fy_year, 1); print_integer(D_FY_QUARTER_SEQ, r->d_fy_quarter_seq, 1); print_integer(D_FY_WEEK_SEQ, r->d_fy_week_seq, 1); print_varchar(D_DAY_NAME, r->d_day_name, 1); sprintf(sQuarterName, "%4dQ%d", r->d_year, r->d_qoy); print_varchar(D_QUARTER_NAME, sQuarterName, 1); print_boolean(D_HOLIDAY, r->d_holiday, 1); print_boolean(D_WEEKEND, r->d_weekend, 1); print_boolean(D_FOLLOWING_HOLIDAY, r->d_following_holiday, 1); print_integer(D_FIRST_DOM, r->d_first_dom, 1); print_integer(D_LAST_DOM, r->d_last_dom, 1); print_integer(D_SAME_DAY_LY, r->d_same_day_ly, 1); print_integer(D_SAME_DAY_LQ, r->d_same_day_lq, 1); print_boolean(D_CURRENT_DAY, r->d_current_day, 1); print_boolean(D_CURRENT_WEEK, r->d_current_week, 1); print_boolean(D_CURRENT_MONTH, r->d_current_month, 1); print_boolean(D_CURRENT_QUARTER, r->d_current_quarter, 1); print_boolean(D_CURRENT_YEAR, r->d_current_year, 0); print_end(DATE); return(0); }
static int print_node(state_t *state, bithenge_node_t *tree) { switch (bithenge_node_type(tree)) { case BITHENGE_NODE_INTERNAL: return print_internal(state, tree); case BITHENGE_NODE_BOOLEAN: return print_boolean(state, tree); case BITHENGE_NODE_INTEGER: return print_integer(state, tree); case BITHENGE_NODE_STRING: return print_string(state, tree); case BITHENGE_NODE_BLOB: return print_blob(state, tree); } return ENOTSUP; }
/* * Routine: * Purpose: * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ int pr_s_customer (void *pSrc) { struct S_CUSTOMER_TBL *r; char szTemp[6]; if (pSrc == NULL) r = &g_s_customer; else r = pSrc; print_start (S_CUSTOMER); print_id (S_CUST_ID, r->kID, 1); print_varchar (S_CUST_SALUTATION, r->pSalutation, 1); print_varchar (S_CUST_LAST_NAME, r->pLastName, 1); print_varchar (S_CUST_FIRST_NAME, r->pFirstName, 1); print_boolean (S_CUST_PREFERRED_FLAG, r->bPreferredFlag, 1); print_date (S_CUST_BIRTH_DATE, r->dtBirthDate.julian, 1); print_varchar (S_CUST_BIRTH_COUNTRY, r->pBirthCountry, 1); print_varchar (S_CUST_LOGIN, r->szLogin, 1); print_varchar (S_CUST_EMAIL, r->szEmail, 1); print_date (S_CUST_LAST_LOGIN, r->dtLastLogin.julian, 1); print_date (S_CUST_FIRST_SHIPTO_DATE, r->dtFirstShipToDate.julian, 1); print_date (S_CUST_FIRST_PURCHASE_DATE, r->dtFirstPurchaseDate.julian, 1); print_date (S_CUST_LAST_REVIEW, r->dtReview.julian, 1); print_varchar (S_CUST_PRIMARY_MACHINE, r->szPrimaryMachine, 1); print_varchar (S_CUST_SECONDARY_MACHINE, r->szSecondaryMachine, 1); print_integer (S_CUST_ADDRESS_STREET_NUM, g_w_customer_address.ca_address.street_num, 1); print_varchar (S_CUST_ADDRESS_SUITE_NUM, g_w_customer_address.ca_address.suite_num, 1); print_varchar (S_CUST_ADDRESS_STREET_NAME1, g_w_customer_address.ca_address.street_name1, 1); print_varchar (S_CUST_ADDRESS_STREET_NAME2, g_w_customer_address.ca_address.street_name2, 1); print_varchar (S_CUST_ADDRESS_STREET_TYPE, g_w_customer_address.ca_address.street_type, 1); print_varchar (S_CUST_ADDRESS_CITY, g_w_customer_address.ca_address.city, 1); sprintf (szTemp, "%05d", g_w_customer_address.ca_address.zip); print_varchar (S_CUST_ADDRESS_ZIP, szTemp, 1); print_varchar (S_CUST_ADDRESS_COUNTY, g_w_customer_address.ca_address.county, 1); print_varchar (S_CUST_ADDRESS_STATE, g_w_customer_address.ca_address.state, 1); print_varchar (S_CUST_ADDRESS_COUNTRY, g_w_customer_address.ca_address.country, 1); print_varchar (S_CUST_LOCATION_TYPE, r->pLocationType, 1); print_varchar (S_CUST_GENDER, r->sGender, 1); print_varchar (S_CUST_MARITAL_STATUS, r->pMaritalStatus, 1); print_varchar (S_CUST_EDUCATION, r->pEducation, 1); print_varchar (S_CUST_CREDIT_RATING, r->pCreditRating, 1); print_integer (S_CUST_PURCHASE_ESTIMATE, r->nPurchaseEstimate, 1); print_varchar (S_CUST_BUY_POTENTIAL, r->pBuyPotential, 1); print_integer (S_CUST_DEPENDENT_CNT, r->nDependents, 1); print_integer (S_CUST_EMPLOYED_CNT, r->nEmployed, 1); print_integer (S_CUST_COLLEGE_CNT, r->nCollege, 1); print_integer (S_CUST_VEHICLE_CNT, r->nVehicle, 1); print_decimal (S_CUST_INCOME, &r->dIncome, 0); print_end (S_CUSTOMER); return (0); }
int main(void) { print_boolean(5, 12); return 0; }
entry print_11() { new_env(1, 0); print_boolean(); null(); ret(); }
int main(void) { IntNode *head = NULL; // An empty linked list. IntNode *empty = NULL; // Another empty linked list. printf("=== Testing insert_front ===\n\n"); printf("Calling insert_front with list: "); print_linked_list(head); printf("\nInserting 3.\n"); head = insert_front(head, 3); printf("Expected list: 3\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("Calling insert_front with list: "); print_linked_list(head); printf("\nInserting 2.\n"); head = insert_front(head, 2); printf("Expected list: 2 -> 3\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("Calling insert_front with list: "); print_linked_list(head); printf("\nInserting 1.\n"); head = insert_front(head, 1); printf("Expected list: 1 -> 2 -> 3\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("=== Testing contains ===\n\n"); _Bool found; printf("Calling contains with list: "); print_linked_list(empty); printf("\nSearching for 1.\n"); found = contains(empty, 1); printf("Expected result: false\n"); printf("Actual result: "); print_boolean(found); printf("\n\n"); printf("Calling contains with list: "); print_linked_list(head); printf("\nSearching for 1.\n"); found = contains(head, 1); printf("Expected result: true\n"); printf("Actual result: "); print_boolean(found); printf("\n\n"); printf("Calling contains with list: "); print_linked_list(head); printf("\nSearching for 3.\n"); found = contains(head, 3); printf("Expected result: true\n"); printf("Actual result: "); print_boolean(found); printf("\n\n"); printf("Calling contains with list: "); print_linked_list(head); printf("\nSearching for 6.\n"); found = contains(head, 6); printf("Expected result: false\n"); printf("Actual result: "); print_boolean(found); printf("\n\n"); printf("=== Testing append_rear ===\n\n"); printf("Calling append_rear with list: "); print_linked_list(head); printf("\nAppending 4.\n"); head = append_rear(head, 4); printf("Expected list: 1 -> 2 -> 3 -> 4\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("=== Testing remove_first ===\n\n"); printf("Calling remove_first with list: "); print_linked_list(head); head = remove_first(head); printf("\nExpected list: 2 -> 3 -> 4\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("=== Testing remove_last ===\n\n"); printf("Calling remove_last with list: "); print_linked_list(head); head = remove_last(head); printf("\nExpected list: 2 -> 3\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("Calling remove_last with list: "); print_linked_list(head); head = remove_last(head); printf("\nExpected list: 2\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); printf("Calling remove_last with list: "); print_linked_list(head); head = remove_last(head); printf("\nExpected list: empty list\n"); printf("Actual list: "); print_linked_list(head); printf("\n\n"); /* Tests for Exercise 1. */ printf("Building linked list 1 -> 1 -> 2 -> 3 -> 3 -> 4 -> 5 -> 5 -> 5\n\n"); head = NULL; head = intnode_construct(5, head); head = intnode_construct(5, head); head = intnode_construct(5, head); head = intnode_construct(4, head); head = intnode_construct(3, head); head = intnode_construct(3, head); head = intnode_construct(2, head); head = intnode_construct(1, head); head = intnode_construct(1, head); // print_linked_list(head); printf("=== Testing count ===\n\n"); int occurrences; printf("Calling count with list: "); print_linked_list(empty); printf("\nCounting 1's.\n"); occurrences = count(empty, 1); printf("Expected result: 0\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(empty); printf("\nCounting 7's.\n"); occurrences = count(empty, 7); printf("Expected result: 0\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(head); printf("\nCounting 1's.\n"); occurrences = count(head, 1); printf("Expected result: 2\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(head); printf("\nCounting 2's.\n"); occurrences = count(head, 2); printf("Expected result: 1\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(head); printf("\nCounting 3's.\n"); occurrences = count(head, 3); printf("Expected result: 2\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(head); printf("\nCounting 4's.\n"); occurrences = count(head, 4); printf("Expected result: 1\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(head); printf("\nCounting 5's.\n"); occurrences = count(head, 5); printf("Expected result: 3\n"); printf("Actual result: %d\n\n", occurrences); printf("Calling count with list: "); print_linked_list(head); printf("\nCounting 7's.\n"); occurrences = count(head, 7); printf("Expected result: 0\n"); printf("Actual result: %d\n\n", occurrences); /* Tests for Exercise 2. */ printf("=== Testing index ===\n\n"); int posn; printf("Calling index with list: "); print_linked_list(empty); printf("\nSearching for 1.\n"); posn = index(empty, 1); printf("Expected result: -1\n"); printf("Actual result: %d\n\n", posn); printf("Calling index with list: "); print_linked_list(head); printf("\nSearching for 1.\n"); posn = index(head, 1); printf("Expected result: 0\n"); printf("Actual result: %d\n\n", posn); printf("Calling index with list: "); print_linked_list(head); printf("\nSearching for 2.\n"); posn = index(head, 2); printf("Expected result: 2\n"); printf("Actual result: %d\n\n", posn); printf("Calling index with list: "); print_linked_list(head); printf("\nSearching for 3.\n"); posn = index(head, 3); printf("Expected result: 3\n"); printf("Actual result: %d\n\n", posn); printf("Calling index with list: "); print_linked_list(head); printf("\nSearching for 4.\n"); posn = index(head, 4); printf("Expected result: 5\n"); printf("Actual result: %d\n\n", posn); printf("Calling index with list: "); print_linked_list(head); printf("\nSearching for 5.\n"); posn = index(head, 5); printf("Expected result: 6\n"); printf("Actual result: %d\n\n", posn); printf("Calling index with list: "); print_linked_list(head); printf("\nSearching for 7.\n"); posn = index(head, 7); printf("Expected result: -1\n"); printf("Actual result: %d\n\n", posn); /* Tests for Exercise 31. */ printf("=== Testing fetch ===\n\n"); /* We can't test these cases, because they should cause the function * to terminate via assert. * * 1. The list is empty; terminate via assert. * 2. index < 0 or index >= # of nodes; terminate via assert. */ int value; printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 0.\n"); value = fetch(head, 0); printf("Expected result: 1\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 1.\n"); value = fetch(head, 1); printf("Expected result: 1\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 2.\n"); value = fetch(head, 2); printf("Expected result: 2\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 3.\n"); value = fetch(head, 3); printf("Expected result: 3\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 4.\n"); value = fetch(head, 4); printf("Expected result: 3\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 5.\n"); value = fetch(head, 5); printf("Expected result: 4\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 6.\n"); value = fetch(head, 6); printf("Expected result: 5\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 7.\n"); value = fetch(head, 7); printf("Expected result: 5\n"); printf("Actual result: %d\n\n", value); printf("Calling fetch with list: "); print_linked_list(head); printf("\nFetching value at index 8.\n"); value = fetch(head, 8); printf("Expected result: 5\n"); printf("Actual result: %d\n\n", value); /* Tests for Exercise 4. */ printf("Building linked list 1 -> 2 -> 3 -> 4\n\n"); IntNode *list = NULL; list = intnode_construct(4, list); list = intnode_construct(3, list); list = intnode_construct(2, list); list = intnode_construct(1, list); printf("=== Testing remove_last_one_pointer ===\n\n"); printf("Calling remove_last_one_pointer with list: "); print_linked_list(list); list = remove_last_one_pointer(list); printf("\nExpected list: 1 -> 2 -> 3\n"); printf("Actual list: "); print_linked_list(list); printf("\n\n"); printf("Calling remove_last_one_pointer with list: "); print_linked_list(list); list = remove_last_one_pointer(list); printf("\nExpected list: 1 -> 2\n"); printf("Actual list: "); print_linked_list(list); printf("\n\n"); printf("Calling remove_last_one_pointer with list: "); print_linked_list(list); list = remove_last_one_pointer(list); printf("\nExpected list: 1\n"); printf("Actual list: "); print_linked_list(list); printf("\n\n"); printf("Calling remove_last_one_pointer with list: "); print_linked_list(list); list = remove_last_one_pointer(list); printf("\nExpected list: empty list\n"); printf("Actual list: "); print_linked_list(list); printf("\n\n"); }