void test_List_addLast_should_add_last_third_element(){

	linkedList *list;
	
	// initialize the list
	list = create_linkedList();
	
	//Test fixture
  
  Element elemArray1 = {.next = NULL, .data = 2};
	Element elemArray0 = {.next = NULL, .data = 1};
  Element elemArrayA = {.next = NULL, .data = 4};
  Element elemArrayB = {.next = NULL, .data = 7};  
	// list->head = &elemArray0;
	// list->tail = &elemArray0;
	// list->length = 1;
	
  
  List_addLast(list,&elemArray0);
  TEST_ASSERT_NULL(elemArray0.next);
  TEST_ASSERT_EQUAL_PTR(&elemArray0,list->head);
  TEST_ASSERT_EQUAL_PTR(&elemArray0,list->tail);
  TEST_ASSERT_EQUAL(1,elemArray0.data);
  TEST_ASSERT_EQUAL(1,list->length);
  
  List_addLast(list,&elemArray1);
  TEST_ASSERT_NULL(elemArray1.next);
  TEST_ASSERT_EQUAL_PTR(&elemArray0,list->head);
  TEST_ASSERT_EQUAL_PTR(&elemArray1,list->tail);
  TEST_ASSERT_EQUAL(1,elemArray0.data);
  TEST_ASSERT_EQUAL(2,elemArray1.data);
  TEST_ASSERT_EQUAL(2,list->length);
  
  List_removeFirst(list);
  TEST_ASSERT_NULL(elemArray1.next);
  TEST_ASSERT_EQUAL_PTR(&elemArray1,list->head);
  TEST_ASSERT_EQUAL_PTR(&elemArray1,list->tail);
  TEST_ASSERT_EQUAL(2,elemArray1.data);
  TEST_ASSERT_EQUAL(1,list->length);
}
예제 #2
0
void
setUp(void) {
  size_t s;
  uint8_t *p;

  /* Make the root flowinfo. */
  TEST_ASSERT_NULL(flowinfo);
  flowinfo = new_flowinfo_vlan_vid();
  TEST_ASSERT_NOT_NULL(flowinfo);

  TEST_ASSERT_FLOWINFO_FLOW_NUM(flowinfo, 0, __func__);

  /*
   * Make the test flows.
   *
   * IPv6 matches have prerequisite.
   */
  for (s = 0; s < ARRAY_LEN(test_flow); s++) {
    TEST_ASSERT_NULL(test_flow[s]);
    test_flow[s] = allocate_test_flow(10 * sizeof(struct match));
    TEST_ASSERT_NOT_NULL(test_flow[s]);
    test_flow[s]->priority = (int)s;
    FLOW_ADD_IPV6_PREREQUISITE(test_flow[s]);
  }

  /* Make the test addresses. */
  for (s = 0; s < ARRAY_LEN(test_flow); s++) {
    addrunion_ipv6_set(&testsrc[s], testsrcstr);
    p = (uint8_t *)&testsrc[s].addr6.s6_addr;
    p[sizeof(testsrc[s].addr6.s6_addr) - 1] = (uint8_t)(TEST_IPV6_ADDR_LSB(
          s) & 0xff);

    addrunion_ipv6_set(&testdst[s], testdststr);
    p = (uint8_t *)&testdst[s].addr6.s6_addr;
    p[sizeof(testsrc[s].addr6.s6_addr) - 1] = (uint8_t)(TEST_IPV6_ADDR_LSB(
          s) & 0xff);

    addrunion_ipv6_set(&testmask[s], testmaskstr);
  }
}
예제 #3
0
void test_uartInit_should_throw_error_if_no_COMPORT_is_found_else_hSerial_shouldnt_null(void)
{
  CEXCEPTION_T err;
  void *hSerial = NULL;
  
  Try {
    uartInit(&hSerial);
    TEST_ASSERT_NOT_NULL(hSerial);
  } Catch(err) {
    displayErrorMessage(err);
    TEST_ASSERT_NULL(hSerial);
  }
}
예제 #4
0
파일: tests-pktbuf.c 프로젝트: A-Paul/RIOT
static void test_pktbuf_realloc_data__memenough(void)
{
    gnrc_pktsnip_t *pkt;

    pkt = gnrc_pktbuf_add(NULL, NULL, sizeof(TEST_STRING16), GNRC_NETTYPE_TEST);

    TEST_ASSERT_NOT_NULL(pkt);
    TEST_ASSERT_EQUAL_INT(0, gnrc_pktbuf_realloc_data(pkt, sizeof(TEST_STRING8)));
    TEST_ASSERT_NULL(pkt->next);
    TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), pkt->size);
    TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_TEST, pkt->type);
    TEST_ASSERT_EQUAL_INT(1, pkt->users);
}
예제 #5
0
void test_KineticAllocator_NewOperation_should_return_null_and_free_operation_if_calloc_returns_null_for_request(void)
{
    KineticOperation op;
    op.session = &Session;

    KineticCalloc_ExpectAndReturn(1, sizeof(KineticOperation), &op);
    KineticCalloc_ExpectAndReturn(1, sizeof(KineticRequest), NULL);
    KineticFree_Expect(&op);

    KineticOperation * operation = KineticAllocator_NewOperation(&Session);

    TEST_ASSERT_NULL(operation);
}
예제 #6
0
void map_jump_and_fire_to_buttons(){
  
  int setup_result = 0;
  struct linked_list__node_t* iter = NULL;
  const struct control_mapping_t* mapping = NULL;
  const char* mapping_file = setup(&setup_result, 
				   "2\n"
				   "jump joystick 5 button 3\n"
				   "fire joystick 5 button 10\n");
  TEST_ASSERT_SUCCESS(setup_result);

  mapping = 
    (const struct control_mapping_t*)
    linked_list__begin(&js_button_mappings[5][3], &iter);

  TEST_ASSERT_NOT_NULL( mapping );
  TEST_ASSERT_INT( mapping->type, BINARY );
  TEST_ASSERT_FLOAT( mapping->min_input, 0.0f );
  TEST_ASSERT_FLOAT( mapping->max_input, 0.0f );
  TEST_ASSERT_NOT_NULL( control__get_state(2) );
  TEST_ASSERT_PTR( mapping->control_type.binary, &control__get_state(2)->jump );

  TEST_ASSERT_NULL( linked_list__next(&iter) );


  mapping = 
    (const struct control_mapping_t*)
    linked_list__begin(&js_button_mappings[5][10], &iter);

  TEST_ASSERT_NOT_NULL( mapping );
  TEST_ASSERT_INT( mapping->type, BINARY );
  TEST_ASSERT_FLOAT( mapping->min_input, 0.0f );
  TEST_ASSERT_FLOAT( mapping->max_input, 0.0f );
  TEST_ASSERT_PTR( mapping->control_type.binary, &control__get_state(2)->fire );

  TEST_ASSERT_NULL( linked_list__next(&iter) );

  teardown(mapping_file);
}
예제 #7
0
static void test_pkt_hlist_remove__header_NULL(void)
{
    pkt_hlist_t hdr1 = _INIT_ELEM(0, NULL, NULL);
    pkt_hlist_t hdr2 = _INIT_ELEM(0, NULL, &hdr1);
    pkt_hlist_t *list = &hdr2;

    pkt_hlist_remove(&list, NULL);

    TEST_ASSERT(list == &hdr2);
    TEST_ASSERT_NOT_NULL(list->next);
    TEST_ASSERT(list->next == &hdr1);
    TEST_ASSERT_NULL(list->next->next);
}
void test_evaluatePrefixesAndNumber_should_push_prefix_operator_and_number_into_operator_and_number_stack(void){
	Token *token;
	Stack *numberStack=createStack();
	Stack *operatorStack=createStack();
	
	Text *newText=textNew("-12");
	String *tokenizer = stringNew(newText);
	token=getToken(tokenizer);
	evaluatePrefixesAndNumber(tokenizer,token,numberStack,operatorStack);
	TEST_ASSERT_EQUAL_OPERATOR(MINUS_OP,stackPop(operatorStack));
	TEST_ASSERT_NULL(stackPop(operatorStack));
	TEST_ASSERT_EQUAL_NUMBER(12,stackPop(numberStack));
}
예제 #9
0
static void test_queue_add_head_one(void)
{
    queue_node_t *root = &(q[0]), *elem = &(q[1]);

    elem->data = 44011;

    queue_add_head(root, elem);

    TEST_ASSERT(root->next == elem);
    TEST_ASSERT_EQUAL_INT(44011, root->next->data);

    TEST_ASSERT_NULL(root->next->next);
}
예제 #10
0
static void test_ipv6_nc_get_next_router__first_entry(void)
{
    gnrc_ipv6_nc_t *entry = NULL;

    /* adds DEFAULT_TEST_IPV6_ADDR and OTHER_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
    test_ipv6_nc_get_next__2_entries();
    TEST_ASSERT_NOT_NULL((entry = gnrc_ipv6_nc_get_next(NULL)));
    entry->flags = (GNRC_IPV6_NC_STATE_REACHABLE << GNRC_IPV6_NC_STATE_POS);
    entry->flags |= GNRC_IPV6_NC_IS_ROUTER;

    TEST_ASSERT_NOT_NULL((entry = gnrc_ipv6_nc_get_next_router(NULL)));
    TEST_ASSERT_NULL(gnrc_ipv6_nc_get_next_router(entry));
}
예제 #11
0
static void test_ipv6_netif_remove_addr__not_allocated(void)
{
    ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
    ng_ipv6_addr_t other_addr = OTHER_TEST_IPV6_ADDR;

    test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
                                          * DEFAULT_TEST_NETIF */

    ng_ipv6_netif_remove_addr(DEFAULT_TEST_NETIF, &other_addr);

    TEST_ASSERT_NULL(ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &other_addr));
    TEST_ASSERT_NOT_NULL(ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr));
}
예제 #12
0
static void test_ipv6_nc_add__full(void)
{
    ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;

    for (int i = 0; i < GNRC_IPV6_NC_SIZE; i++) {
        TEST_ASSERT_NOT_NULL(gnrc_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr, TEST_STRING4,
                                              sizeof(TEST_STRING4), 0));
        addr.u16[7].u16++;
    }

    TEST_ASSERT_NULL(gnrc_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr, TEST_STRING4,
                                      sizeof(TEST_STRING4), 0));
}
예제 #13
0
static void test_queue_add_tail_one(void)
{
    queue_node_t *root = &(q[0]), *elem = &(q[1]);

    elem->data = 33893;

    queue_add_tail(root, elem);

    TEST_ASSERT(root->next == elem);
    TEST_ASSERT_EQUAL_INT(33893, root->next->data);

    TEST_ASSERT_NULL(root->next->next);
}
예제 #14
0
void
setUp(void) {
  datastore_bridge_info_t info;

  memset(&info, 0, sizeof(info));
  info.dpid = dpid;
  info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  TEST_ASSERT_NULL(bridge);
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
  TEST_ASSERT_EQUAL(dp_bridge_create(bridge_name, &info), LAGOPUS_RESULT_OK);
  bridge = dp_bridge_lookup(bridge_name);
  TEST_ASSERT_NOT_NULL(bridge);
}
예제 #15
0
파일: tests-pktbuf.c 프로젝트: A-Paul/RIOT
static void test_pktbuf_add__pkt_NOT_NULL__data_NOT_NULL__size_0(void)
{
    gnrc_pktsnip_t *pkt;
    gnrc_pktsnip_t *next = gnrc_pktbuf_add(NULL, TEST_STRING4, sizeof(TEST_STRING4),
                                           GNRC_NETTYPE_TEST);

    TEST_ASSERT_NOT_NULL(next);

    TEST_ASSERT_NOT_NULL((pkt = gnrc_pktbuf_add(next, TEST_STRING8, 0, GNRC_NETTYPE_TEST)));

    TEST_ASSERT(pkt->next = next);
    TEST_ASSERT_NULL(pkt->data);
    TEST_ASSERT_EQUAL_INT(0, pkt->size);
    TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_TEST, pkt->type);
    TEST_ASSERT_NULL(next->next);
    TEST_ASSERT_EQUAL_STRING(TEST_STRING4, next->data);
    TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING4), next->size);
    TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_TEST, next->type);

    TEST_ASSERT(gnrc_pktbuf_is_sane());
    TEST_ASSERT(!gnrc_pktbuf_is_empty());
}
예제 #16
0
static void test_pkt_remove_first_header(void)
{
    pkt_hlist_t hdr1 = _INIT_ELEM(0, NULL, NULL);
    pkt_hlist_t hdr2 = _INIT_ELEM(0, NULL, NULL);
    pkt_t pkt = _INIT_ELEM(0, NULL, NULL);

    pkt_add_header(&pkt, &hdr1);
    pkt_add_header(&pkt, &hdr2);

    TEST_ASSERT(&hdr2 == pkt_remove_first_header(&pkt));
    TEST_ASSERT(&hdr1 == pkt.headers);
    TEST_ASSERT_NULL(pkt.headers->next);
}
예제 #17
0
static void test_pktbuf_add__pkt_NULL__data_NOT_NULL__size_0(void)
{
    ng_pktsnip_t *pkt;

    TEST_ASSERT_NOT_NULL((pkt = ng_pktbuf_add(NULL, TEST_STRING8, 0, NG_NETTYPE_UNDEF)));

    TEST_ASSERT_NULL(pkt->next);
    TEST_ASSERT_NOT_NULL(pkt->data);
    TEST_ASSERT_EQUAL_INT(0, pkt->size);
    TEST_ASSERT_EQUAL_INT(NG_NETTYPE_UNDEF, pkt->type);

    TEST_ASSERT(!ng_pktbuf_is_empty());
}
예제 #18
0
파일: list_test.c 프로젝트: NRTopping/NDS
TEST(NDSlist, listFlush_nonEmpty) { 
  TEST_ASSERT_EQUAL_INT(0, nds_list_size(list));
  nds_list_insert_head(list, (nds_element_t) 1);
  nds_list_insert_head(list, (nds_element_t) 2);
  nds_list_insert_head(list, (nds_element_t) 3);
  TEST_ASSERT_EQUAL_INT(3, nds_list_size(list));

  nds_list_flush(list);
  TEST_ASSERT_EQUAL_INT(0, nds_list_size(list));
  TEST_ASSERT_NULL(nds_list_get_head(list));
  TEST_ASSERT_NULL(nds_list_get_tail(list));

  nds_list_insert_head(list, (nds_element_t) 1);
  nds_list_insert_tail(list, (nds_element_t) 2);
  TEST_ASSERT_EQUAL_INT(2, nds_list_size(list));
  TEST_ASSERT_EQUAL_INT(1, nds_list_get_head(list));
  TEST_ASSERT_EQUAL_INT(2, nds_list_get_tail(list));
  nds_list_flush(list);
  TEST_ASSERT_EQUAL_INT(0, nds_list_size(list));
  TEST_ASSERT_NULL(nds_list_get_head(list));
  TEST_ASSERT_NULL(nds_list_get_tail(list));
}
예제 #19
0
static void test_ipv6_nc_get_next__2_entries(void)
{
    ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
    gnrc_ipv6_nc_t *entry = NULL;

    test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
    TEST_ASSERT_NOT_NULL(gnrc_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr, TEST_STRING8,
                                          sizeof(TEST_STRING8) - 1, 0));


    TEST_ASSERT_NOT_NULL((entry = gnrc_ipv6_nc_get_next(NULL)));
    TEST_ASSERT_NOT_NULL((entry = gnrc_ipv6_nc_get_next(entry)));
    TEST_ASSERT_NULL(gnrc_ipv6_nc_get_next(entry));
}
예제 #20
0
void test_mapFind_given_Ali_and_ali_is_not_in_the_Map_should_return_NULL_since_no_Ali_object_in_Map2(){
  Person *Ali = personNew("Ali",25,70.3);
  Person *person;
  List *list = listNew(Ali, NULL);
	Map *map = mapNew(5);
	
	// map->bucket[5] = list; // no add
  hash_ExpectAndReturn(Ali,5);
  // comparePerson(Ali,Ali);
  
  person = mapFind(map , Ali ,comparePerson, hash);

  TEST_ASSERT_NULL(person);
}
예제 #21
0
/**  plist = p1,p2,p3,p4
  *
  *  population = 50  (refer to the maximum seat in school, the session can not have student Number exceed this)
  *
  *  Because each paper has 50 person, session only can have 1 paper, should create 4 session
  *
  *----------------output-------------------
  *
  *   Table:  s1  s2  s3  s4
  *           p1  p2  p3  p4
  * 
*/
void test_buildTable_given_populatoin_is_50_should_create_4_session(void){
  pList = linkListNew(&p4);
  addDataToHead(&pList, &p3);
  addDataToHead(&pList, &p2);
  addDataToHead(&pList, &p1); 
  //-------------------------------------------------------------------------------------------

  table = buildTable( pList, 50);
 // printfTable( table);
  TEST_ASSERT_NOT_NULL(S1);
  TEST_ASSERT_NOT_NULL(S2);
  TEST_ASSERT_NOT_NULL(S3);
  TEST_ASSERT_NOT_NULL(S4);
  TEST_ASSERT_NULL(S5);
  TEST_ASSERT_EQUAL_PTR(&p1, S1_1->data);
  TEST_ASSERT_EQUAL_PTR(&p2, S2_1->data);
  TEST_ASSERT_EQUAL_PTR(&p3, S3_1->data);
  TEST_ASSERT_EQUAL_PTR(&p4, S4_1->data); 
  TEST_ASSERT_NULL(S1_2);
  TEST_ASSERT_NULL(S2_2);
  TEST_ASSERT_NULL(S3_2);
  TEST_ASSERT_NULL(S4_2);
}
예제 #22
0
void verify_open_qhd(ehci_qhd_t *p_qhd, uint8_t endpoint_addr, uint16_t max_packet_size)
{
  TEST_ASSERT_EQUAL(dev_addr, p_qhd->device_address);
  TEST_ASSERT_FALSE(p_qhd->non_hs_period_inactive_next_xact);
  TEST_ASSERT_EQUAL(endpoint_addr & 0x0F, p_qhd->endpoint_number);
  TEST_ASSERT_EQUAL(usbh_devices[dev_addr].speed, p_qhd->endpoint_speed);
  TEST_ASSERT_EQUAL(max_packet_size, p_qhd->max_package_size);
  TEST_ASSERT_EQUAL(0, p_qhd->nak_count_reload); // TDD NAK Reload disable

  TEST_ASSERT_EQUAL(hub_addr, p_qhd->hub_address);
  TEST_ASSERT_EQUAL(hub_port, p_qhd->hub_port);
  TEST_ASSERT_EQUAL(1, p_qhd->mult); // TDD operation model for mult

  TEST_ASSERT_FALSE(p_qhd->qtd_overlay.halted);
  TEST_ASSERT(p_qhd->qtd_overlay.next.terminate);
  TEST_ASSERT(p_qhd->qtd_overlay.alternate.terminate);

  //------------- HCD -------------//
  TEST_ASSERT(p_qhd->used);
  TEST_ASSERT_FALSE(p_qhd->is_removing);
  TEST_ASSERT_NULL(p_qhd->p_qtd_list_head);
  TEST_ASSERT_NULL(p_qhd->p_qtd_list_tail);
}
예제 #23
0
static void test_clist_find_before(void)
{
    list_node_t *list = &test_clist;

    test_clist_add_three();

    TEST_ASSERT(clist_find_before(list, &(tests_clist_buf[0])) == &(tests_clist_buf[2]));

    for (int i = 1; i < 3; i++) {
        TEST_ASSERT(clist_find_before(list, &(tests_clist_buf[i])) == &(tests_clist_buf[i-1]));
    }

    TEST_ASSERT_NULL(clist_find_before(list, &(tests_clist_buf[3])));
}
예제 #24
0
static void test_queue_remove_one(void)
{
    queue_node_t *root = &(q[0]), *elem1 = &(q[1]), *elem2 = &(q[2]);
    queue_node_t *elem3 = &(q[3]);

    queue_add_head(root, elem1);
    queue_add_head(root, elem2);
    queue_add_head(root, elem3);
    queue_remove(root, elem2);

    TEST_ASSERT(root->next == elem3);
    TEST_ASSERT(root->next->next == elem1);
    TEST_ASSERT_NULL(root->next->next->next);
}
예제 #25
0
static void test_7(void)
{
    // test jemMallocCode until it is full

    int i;
    int size = domain->code_bytes - 1;

    for (i=0; i<getJVMConfig(codeFragments); i++) {
        ref_3 = jemMallocCode(domain, size);
        TEST_ASSERT_NOT_NULL(ref_3);
    }
    ref_3 = jemMallocCode(domain, size);
    TEST_ASSERT_NULL(ref_3);
}
예제 #26
0
static void test_set(void)
{
	TEST_ASSERT_NULL(evcpe_cookies_find(&cookies, "foo"));
	TEST_ASSERT(0 != evcpe_cookies_set(&cookies, NULL, NULL));
	TEST_ASSERT(0 != evcpe_cookies_set(&cookies, "foo", NULL));

	TEST_ASSERT_EQUAL_INT(0, evcpe_cookies_set(&cookies, "foo", "bar"));
	TEST_ASSERT_NOT_NULL((cookie = evcpe_cookies_find(&cookies, "foo")));
	TEST_ASSERT_EQUAL_STRING("bar", cookie->value);

	TEST_ASSERT_EQUAL_INT(0, evcpe_cookies_set(&cookies, "foo", "bar1"));
	TEST_ASSERT_NOT_NULL((cookie = evcpe_cookies_find(&cookies, "foo")));
	TEST_ASSERT_EQUAL_STRING("bar1", cookie->value);
}
예제 #27
0
static void test_GetLast(void)
{
    const test_struct data[] = {{8, 9}, {-3, -4}, {21, 56}, {0, 0}};
    const int nr_elements = sizeof(data)/sizeof(data[0]);

    TEST_ASSERT_NULL(list_get_last(mylist));
    for(int i = 0; i < nr_elements; i++)
    {
        TEST_ASSERT_EQUAL(0, list_add_tail(mylist, &(data[i])));
        test_struct* ptr = list_get_last(mylist);
        TEST_ASSERT_NOT_NULL(ptr);
        TEST_ASSERT_EQUAL(0, memcmp(&(data[i]), ptr, sizeof(*ptr)));
    }
}
예제 #28
0
static void test_queue_remove_one(void)
{
    queue_t *root = &q;
    queue_node_t *elem1 = &(qe[1]), *elem2 = &(qe[2]), *elem3 = &(qe[3]);

    queue_priority_add(root, elem1);
    queue_priority_add(root, elem2);
    queue_priority_add(root, elem3);
    queue_remove(root, elem2);

    TEST_ASSERT(root->first == elem1);
    TEST_ASSERT(root->first->next == elem3);
    TEST_ASSERT_NULL(root->first->next->next);
}
예제 #29
0
void test_KineticSession_Connect_should_report_a_failure_to_receive_initialization_info_from_device(void)
{
    const uint8_t hmacKey[] = {1, 6, 3, 5, 4, 8, 19};
    KineticSession expected = {
        .config = (KineticSessionConfig) {
            .host = "valid-host.com",
            .port = 1234,
            .clusterVersion = 17,
            .identity = 12,
            .hmacKey = {
                .data = expected.config.keyData,
                .len = sizeof(hmacKey)},
        },
        .connected = true,
        .socket = 24,
    };
    memcpy(expected.config.hmacKey.data,
        hmacKey, expected.config.hmacKey.len);

    KineticSession session = {
        .config = (KineticSessionConfig) {
            .host = "valid-host.com",
            .port = expected.config.port,
            .clusterVersion = expected.config.clusterVersion,
            .identity = expected.config.identity,
            .hmacKey = {
                .data = Session.config.keyData,
                .len = sizeof(hmacKey)},
        },
        .connected = true,
        .socket = 24,
    };
    memcpy(session.config.hmacKey.data,
        hmacKey, expected.config.hmacKey.len);

    KineticSocket_Connect_ExpectAndReturn(expected.config.host, expected.config.port, expected.socket);
    Bus_RegisterSocket_ExpectAndReturn(NULL, BUS_SOCKET_PLAIN,
        expected.socket, &session, true);
    KineticResourceWaiter_WaitTilAvailable_ExpectAndReturn(&session.connectionReady,
        KINETIC_CONNECTION_TIMEOUT_SECS, false);
    KineticSocket_Close_Expect(expected.socket);

    KineticStatus status = KineticSession_Connect(&session);

    TEST_ASSERT_EQUAL(KINETIC_STATUS_CONNECTION_ERROR, status);
    TEST_ASSERT_FALSE(session.connected);
    TEST_ASSERT_EQUAL(KINETIC_SOCKET_DESCRIPTOR_INVALID, session.socket);
    TEST_ASSERT_NULL(session.si);
}
예제 #30
0
파일: tests-pktbuf.c 프로젝트: A-Paul/RIOT
static void test_pktbuf_add__pkt_NULL__data_NULL__size_not_0(void)
{
    gnrc_pktsnip_t *pkt;

    TEST_ASSERT_NOT_NULL((pkt = gnrc_pktbuf_add(NULL, NULL, sizeof(TEST_STRING8),
                                GNRC_NETTYPE_TEST)));
    TEST_ASSERT_NULL(pkt->next);
    TEST_ASSERT_NOT_NULL(pkt->data);
    TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), pkt->size);
    TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_TEST, pkt->type);
    TEST_ASSERT_EQUAL_INT(1, pkt->users);

    TEST_ASSERT(gnrc_pktbuf_is_sane());
    TEST_ASSERT(!gnrc_pktbuf_is_empty());
}