Esempio n. 1
0
TEST(TryingMessageBuildTestGroup, TryingMessageCallIdTest)
{
    MESSAGE *invite = CreateMessage();
    ParseMessage(INCOMMING_INVITE_MESSAGE, invite);
    MESSAGE *trying = BuildResponse(invite, STATUS_CODE_TRYING);

    struct CallIdHeader *inviteCallId = (struct CallIdHeader *)MessageGetHeader(HEADER_NAME_CALLID, invite);
    struct CallIdHeader *tryingCallId = (struct CallIdHeader *)MessageGetHeader(HEADER_NAME_CALLID, trying);
    
    CHECK_TRUE(CallIdHeaderMatched(inviteCallId, tryingCallId));
    
    DestroyMessage(&trying);
    DestroyMessage(&invite);    
}
Esempio n. 2
0
value_t space_for_each_object(space_t *space, value_visitor_o *visitor) {
    address_t current = space->start;
    while (current < space->next_free) {
        value_t value = new_heap_object(current);
        TRY(value_visitor_visit(visitor, value));
        heap_object_layout_t layout;
        heap_object_layout_init(&layout);
        get_heap_object_layout(value, &layout);
        size_t size = layout.size;
        CHECK_TRUE("object heap size alignment", is_size_aligned(kValueSize, size));
        current += size;
    }
    return success();
}
Esempio n. 3
0
static void
test_netaddr_create_host(void) {
  struct netaddr netmask, host, result;
  struct netaddr_str buf1, buf2, buf3;
  char buffer1[17], buffer2[17];
  size_t i;

  memset(buffer1, 255, sizeof(buffer1));
  memset(buffer2, 0, sizeof(buffer2));

  START_TEST();

  for (i=0; i<ARRAYSIZE(_create_host_test); i++) {
    CHECK_TRUE(netaddr_from_string(&netmask, _create_host_test[i].netmask) == 0,
        "error in parsing netmask %"PRINTF_SIZE_T_SPECIFIER" %s", i, _create_host_test[i].netmask);
    CHECK_TRUE(netaddr_from_string(&result, _create_host_test[i].result) == 0,
        "error in parsing result %"PRINTF_SIZE_T_SPECIFIER" %s", i, _create_host_test[i].result);

    if (_create_host_test[i].buf_len >= 0) {
      CHECK_TRUE(netaddr_create_host_bin(&host, &netmask, buffer1, _create_host_test[i].buf_len) == 0,
          "error in creating host %"PRINTF_SIZE_T_SPECIFIER" %s with length %d",
          i, netaddr_to_string(&buf1,  &netmask), _create_host_test[i].buf_len);
    }
    else {
      CHECK_TRUE(netaddr_create_host_bin(&host, &netmask, buffer2, -_create_host_test[i].buf_len) == 0,
          "error in creating host %"PRINTF_SIZE_T_SPECIFIER" %s with length %d",
          i, netaddr_to_string(&buf1,  &netmask), _create_host_test[i].buf_len);
    }

    CHECK_TRUE(netaddr_cmp(&host, &result) == 0,
        "Error, host %"PRINTF_SIZE_T_SPECIFIER" %s != result %s (netmask %s, len=%d)",
        i, netaddr_to_string(&buf1, &host), netaddr_to_string(&buf2, &result),
        netaddr_to_string(&buf3, &netmask), _create_host_test[i].buf_len);
  }

  END_TEST();
}
Esempio n. 4
0
static void
test_netaddr_is_in_subnet(void) {
  struct netaddr_str str1, str2;
  size_t a, s;
  START_TEST();

  for (s = 0; s < sizeof(in_subnet_subnets) / sizeof(*in_subnet_subnets); s++) {
    for (a = 0; a < sizeof(in_subnet_addrs) / sizeof(*in_subnet_addrs); a++) {
      CHECK_TRUE(
          in_subnet_results[a][s] == netaddr_binary_is_in_subnet(&in_subnet_subnets[s], &in_subnet_addrs[a], 4, AF_INET),
          "%s is not in %s",
          netaddr_to_string(&str1, &in_subnet_addrs[a]),
          netaddr_to_string(&str2, &in_subnet_subnets[s]));

      CHECK_TRUE(
          in_subnet_results[a][s] == netaddr_is_in_subnet(&in_subnet_subnets[s], &in_subnet_addrs[a]),
          "%s is not in %s",
          netaddr_to_string(&str1, &in_subnet_addrs[a]),
          netaddr_to_string(&str2, &in_subnet_subnets[s]));
    }
  }

  END_TEST();
}
Esempio n. 5
0
static void
test_delta_modify_two_sections(void) {
  START_TEST();

  handler_1.cb_delta_handler = handler_modify_two_sections;

  cfg_db_add_entry(db_pre, SECTION_TYPE_1, NAME_1, KEY_1, value_1.value);
  cfg_db_add_entry(db_pre, SECTION_TYPE_1, NAME_1, KEY_2, value_2.value);

  cfg_db_add_entry(db_pre, SECTION_TYPE_1, NAME_2, KEY_2, value_2.value);
  cfg_db_add_entry(db_pre, SECTION_TYPE_1, NAME_2, KEY_3, value_3.value);

  cfg_db_add_entry(db_post, SECTION_TYPE_1, NAME_1, KEY_1, value_2.value);
  cfg_db_add_entry(db_post, SECTION_TYPE_1, NAME_1, KEY_2, value_3.value);

  cfg_db_add_entry(db_post, SECTION_TYPE_1, NAME_2, KEY_2, value_1.value);
  cfg_db_add_entry(db_post, SECTION_TYPE_1, NAME_2, KEY_3, value_2.value);

  CHECK_TRUE(cfg_schema_handle_db_changes(db_pre, db_post) == 0,
      "delta calculation failed");

  CHECK_TRUE(callback_counter == 2, "Callback counter was called %d times", callback_counter);
  END_TEST();
}
Esempio n. 6
0
TEST(TryingMessageBuildTestGroup, TryingMessageToWithTagTest)
{
    MESSAGE *invite = CreateMessage();
    ParseMessage(INCOMMING_INVITE_MESSAGE_WITH_TO_TAG, invite);
    
    MESSAGE *trying = BuildResponse(invite, STATUS_CODE_TRYING);

    CONTACT_HEADER *inviteTo = (CONTACT_HEADER *)MessageGetHeader(HEADER_NAME_TO, invite);
    CONTACT_HEADER *tryingTo = (CONTACT_HEADER *)MessageGetHeader(HEADER_NAME_TO, trying);

    CHECK_TRUE(ContactHeaderMatched(inviteTo, tryingTo));

    DestroyMessage(&trying);
    DestroyMessage(&invite);    
}
IMPLEMENT_TEST(SQLiteObjectDbiUnitTests, canUndoRedo_oneUserStep) {
    U2OpStatusImpl os;
    U2ObjectDbi* objDbi = SQLiteObjectDbiTestData::getSQLiteObjectDbi();

    // Create test msa
    U2DataId msaId = SQLiteObjectDbiTestData::createTestMsa(true, os);
    CHECK_NO_ERROR(os);

    // Do action twice inside one UserStep
    {
        U2UseCommonUserModStep userStep(objDbi->getRootDbi(), msaId, os);
        CHECK_NO_ERROR(os);
        Q_UNUSED(userStep);

        SQLiteObjectDbiTestData::addTestRow(msaId, os);
        CHECK_NO_ERROR(os);
        SQLiteObjectDbiTestData::addTestRow(msaId, os);
        CHECK_NO_ERROR(os);
    }

    // Verify canUndo/canRedo
    bool undoState = objDbi->canUndo(msaId, os); CHECK_NO_ERROR(os);
    bool redoState = objDbi->canRedo(msaId, os); CHECK_NO_ERROR(os);
    CHECK_TRUE(undoState, "undo state before undo");
    CHECK_FALSE(redoState, "redo state before undo");

    // Undo UserStep
    objDbi->undo(msaId, os);
    CHECK_NO_ERROR(os);

    // Verify canUndo/canRedo
    undoState = objDbi->canUndo(msaId, os); CHECK_NO_ERROR(os);
    redoState = objDbi->canRedo(msaId, os); CHECK_NO_ERROR(os);
    CHECK_FALSE(undoState, "undo state after undo");
    CHECK_TRUE(redoState, "redo state after undo");
}
Esempio n. 8
0
TEST(TryingMessageBuildTestGroup, TryingMessageStatusLineTest)
{
    MESSAGE *invite = CreateMessage();
    ParseMessage(INCOMMING_INVITE_MESSAGE, invite);

    MESSAGE *trying = BuildResponse(invite, STATUS_CODE_TRYING);
    struct StatusLine *status = MessageGetStatusLine(trying);
    
    CHECK_TRUE(status != NULL);
    STRCMP_EQUAL(SIP_VERSION, StatusLineGetSipVersion(status));
    CHECK_EQUAL(100, StatusLineGetStatusCode(status));
    STRCMP_EQUAL("Trying", StatusLineGetReasonPhrase(status));

    DestroyMessage(&trying);
    DestroyMessage(&invite);
}
TEST(GameOfLifeEngine, AnyLiveCellWithThreeNeighboursLivesOnToNextGeneration) //AnyLiveCellWithTwoOrThreeNeighboursLivesOnToNextGeneration
{
  int noOfXCells = 3;
  int noOfYCells = 3;
    
  GameOfLife game(noOfXCells, noOfYCells);

  game.GiveCellLife(2,2);
  game.GiveCellLife(1,1);
  game.GiveCellLife(0,0);
  game.GiveCellLife(0,2);

  game.TriggerNextGeneration();

  CHECK_TRUE(game.IsCellAlive(1,1)); 
}
Esempio n. 10
0
static void addAddresses(struct rfc5444_writer *wr) {
  struct netaddr ip;
  struct rfc5444_writer_address *addr;
  char value0 =  0, value1 = 1;
  uint16_t metric;

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.11.1"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_LOCAL_IF], &value1, 1, false);

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.11.2"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_LOCAL_IF], &value1, 1, false);

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.11.3"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_LOCAL_IF], &value0, 1, false);

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.10.1"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_OTHERNEIGH], &value1, 1, false);
  metric = htons(0x2024);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC1], &metric, sizeof(metric), true);
  metric = htons(0x1013);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC2], &metric, sizeof(metric), true);

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.12.1"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_OTHERNEIGH], &value1, 1, false);
  metric = htons(0x202f);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC1], &metric, sizeof(metric), true);
  metric = htons(0x1013);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC2], &metric, sizeof(metric), true);

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.12.2"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_OTHERNEIGH], &value1, 1, false);
  metric = htons(0x202f);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC1], &metric, sizeof(metric), true);
  metric = htons(0x1013);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC2], &metric, sizeof(metric), true);

  CHECK_TRUE(0 == netaddr_from_string(&ip, "10.5.12.3"), "failed to initialize ip");
  addr = rfc5444_writer_add_address(wr, cpr.creator, &ip, false);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_OTHERNEIGH], &value1, 1, false);
  metric = htons(0x202f);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC1], &metric, sizeof(metric), true);
  metric = htons(0x1013);
  rfc5444_writer_add_addrtlv(wr, addr, &addrtlvs[IDX_METRIC2], &metric, sizeof(metric), true);
}
Esempio n. 11
0
TEST(GameOfLifeEngine, AnyDeadCellWithExactlyThreeLiveNeighboursBecomesALiveCell) //Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
{
  GameOfLife game(4,5);

  game.GiveCellLife(0,1); //----------------
  game.GiveCellLife(1,0); //    |   |   |
  game.GiveCellLife(1,1); //----------------
                          //  * | * |   |
                          //----------------
                          //    | * |   |
                          //----------------

  game.TriggerNextGeneration();
  CHECK_TRUE(game.IsCellAlive(0,0));
  
}
Esempio n. 12
0
static void push_stack_piece_bottom_frame(runtime_t *runtime, value_t stack_piece,
    value_t arg_map) {
  frame_t bottom = frame_empty();
  value_t code_block = ROOT(runtime, stack_piece_bottom_code_block);
  // The transferred arguments are going to appear as if they were arguments
  // passed from this frame so we have to "allocate" enough room for them on
  // the stack.
  open_stack_piece(stack_piece, &bottom);
  size_t arg_count = get_array_length(arg_map);
  bool pushed = try_push_new_frame(&bottom,
      get_code_block_high_water_mark(code_block) + arg_count,
      ffSynthetic | ffStackPieceBottom, false);
  CHECK_TRUE("pushing bottom frame", pushed);
  frame_set_code_block(&bottom, code_block);
  frame_set_argument_map(&bottom, arg_map);
  close_frame(&bottom);
}
Esempio n. 13
0
    void writeOnesBlocks(unsigned int startBlock, unsigned int blockCount)
    {
        unsigned int   totalSize = blockCount * DISK_IMAGE_BLOCK_SIZE;
        unsigned char* pBlockData = (unsigned char*)malloc(totalSize);
        CHECK_TRUE(pBlockData != NULL);
        memset(pBlockData, 0xff, totalSize);
        
        DiskImageInsert insert;
        insert.sourceOffset = 0;
        insert.length = totalSize;
        insert.type = DISK_IMAGE_INSERTION_BLOCK;
        insert.block = startBlock;
        insert.intraBlockOffset = 0;

        __try_and_catch( BlockDiskImage_InsertData(m_pDiskImage, pBlockData, &insert) );
        free(pBlockData);
    }
Esempio n. 14
0
    void ShardDefinition::AddShard(size_t minPostingCount, double density)
    {
        CHECK_LT(m_shards.size(), c_maxShardIdCount)
            << "Shard count limit exceeded.";

        CHECK_TRUE(m_shards.size() > 0 || minPostingCount == 0)
            << "First shard must have minPostingCount of zero.";

        m_shards.push_back(std::make_pair(minPostingCount, density));
        size_t i = m_shards.size() - 1;

        while (i > 0 && m_shards[i].first < m_shards[i - 1].first)
        {
            std::swap(m_shards[i], m_shards[i - 1]);
            --i;
        }
    }
Esempio n. 15
0
void test_number_list() {
	struct number_list* head = 0;

	_add_number_list(&head, 23);
	_add_number_list(&head, 42);
	_add_number_list(&head, 17);
	_add_number_list(&head, 32);
	_add_number_list(&head, 1);

	START_TEST();

	int prev = 0;
	struct number_list* node;
	simple_list_for_each (head, node) {
		CHECK_TRUE(node->value >= prev, "%d < %d", node->value, prev);
		prev = node->value;
	}
Esempio n. 16
0
IMPLEMENT_TEST(SQLiteObjectDbiUnitTests, canUndoRedo_lastState) {
    U2OpStatusImpl os;
    U2ObjectDbi* objDbi = SQLiteObjectDbiTestData::getSQLiteObjectDbi();

    // Create test msa
    U2DataId msaId = SQLiteObjectDbiTestData::createTestMsa(true, os);
    CHECK_NO_ERROR(os);

    // Do action
    SQLiteObjectDbiTestData::addTestRow(msaId, os);
    CHECK_NO_ERROR(os);

    // Verify canUndo/canRedo
    bool undoState = objDbi->canUndo(msaId, os); CHECK_NO_ERROR(os);
    bool redoState = objDbi->canRedo(msaId, os); CHECK_NO_ERROR(os);
    CHECK_TRUE(undoState, "undo state");
    CHECK_FALSE(redoState, "redo state");
}
Esempio n. 17
0
static void
test_default_unnamed_named_section_set(void) {
  const struct const_strarray *value;
  START_TEST();

  cfg_db_overwrite_entry(db, CFG_SECTION, CFG_SECTION_NAME, CFG_ENTRY_DEF, CFG_NAMED_VALUE);
  cfg_db_overwrite_entry(db, CFG_SECTION, CFG_SECTION_NAME, CFG_ENTRY_NODEF, CFG_NAMED_VALUE);

  cfg_db_overwrite_entry(db, CFG_SECTION, NULL, CFG_ENTRY_DEF, CFG_UNNAMED_VALUE);
  cfg_db_overwrite_entry(db, CFG_SECTION, NULL, CFG_ENTRY_NODEF, CFG_UNNAMED_VALUE);

  value = cfg_db_get_entry_value(db, CFG_SECTION, CFG_SECTION_NAME, CFG_ENTRY_DEF);
  CHECK_TRUE(value != NULL, "No value found for named section entry with default");
  if (value) {
      CHECK_TRUE(value->value != NULL && strcmp(value->value, CFG_NAMED_VALUE) == 0,
          "Did not got the named_section value with default: %s", value->value);
  }

  value = cfg_db_get_entry_value(db, CFG_SECTION, CFG_SECTION_NAME, CFG_ENTRY_NODEF);
  CHECK_TRUE(value != NULL, "No value found for named section entry without default");
  if (value) {
      CHECK_TRUE(value->value != NULL && strcmp(value->value, CFG_NAMED_VALUE) == 0,
          "Did not got the named_section value without default: %s", value->value);
  }

  value = cfg_db_get_entry_value(db, CFG_SECTION, NULL, CFG_ENTRY_DEF);
  CHECK_TRUE(value != NULL, "No value found for unnamed section entry with default");
  if (value) {
      CHECK_TRUE(value->value != NULL && strcmp(value->value, CFG_UNNAMED_VALUE) == 0,
          "Did not got the unnamed_section value with default: %s", value->value);
  }

  value = cfg_db_get_entry_value(db, CFG_SECTION, NULL, CFG_ENTRY_NODEF);
  CHECK_TRUE(value != NULL, "No value found for unnamed section entry without default");
  if (value) {
      CHECK_TRUE(value->value != NULL && strcmp(value->value, CFG_UNNAMED_VALUE) == 0,
          "Did not got the unnamed_section value without default: %s", value->value);
  }

  END_TEST();
}
Esempio n. 18
0
value_t push_stack_frame(runtime_t *runtime, value_t stack, frame_t *frame,
    size_t frame_capacity, value_t arg_map) {
  CHECK_FAMILY(ofStack, stack);
  value_t top_piece = get_stack_top_piece(stack);
  CHECK_FALSE("stack piece closed", is_stack_piece_closed(top_piece));
  if (!try_push_new_frame(frame, frame_capacity, ffOrganic, false)) {
    // There wasn't room to push this frame onto the top stack piece so
    // allocate a new top piece that definitely has room.
    size_t default_capacity = get_stack_default_piece_capacity(stack);
    size_t transfer_arg_count = get_array_length(arg_map);
    size_t required_capacity
        = frame_capacity          // the new frame's locals
        + kFrameHeaderSize        // the new frame's header
        + 1                       // the synthetic bottom frame's one local
        + kFrameHeaderSize        // the synthetic bottom frame's header
        + transfer_arg_count;     // any arguments to be copied onto the piece
    size_t new_capacity = max_size(default_capacity, required_capacity);

    // Create and initialize the new stack segment. The frame struct is still
    // pointing to the old frame.
    TRY_DEF(new_piece, new_heap_stack_piece(runtime, new_capacity, top_piece,
        stack));
    push_stack_piece_bottom_frame(runtime, new_piece, arg_map);
    transfer_top_arguments(new_piece, frame, transfer_arg_count);
    set_stack_top_piece(stack, new_piece);

    // Close the previous stack piece, recording the frame state.
    close_frame(frame);

    // Finally, create a new frame on the new stack which includes updating the
    // struct. The required_capacity calculation ensures that this call will
    // succeed.
    open_stack_piece(new_piece, frame);
    bool pushed_stack_piece = try_push_new_frame(frame, frame_capacity,
        ffOrganic, false);
    if (!pushed_stack_piece)
      try_push_new_frame(frame, frame_capacity,
              ffOrganic, false);
    CHECK_TRUE("pushing on new piece failed", pushed_stack_piece);
  }
  frame_set_argument_map(frame, arg_map);
  return success();
}
		TEST(NetworkComponent, SetDirtyDelegatesToVariables)
		{
			NetworkComponent networkComponent1("", nullptr);
			NetworkComponent networkComponent2("", nullptr);
			Integer comp1var = 1;
			Integer comp2var = 2;

			networkComponent1.addVariable("var", &comp1var);
			networkComponent2.addVariable("var", &comp2var);

			comp1var.setDirty(true);
			networkComponent1.setDirty(false);

			comp2var.setDirty(false);
			networkComponent2.setDirty(true);

			CHECK_FALSE(comp1var.isDirty());
			CHECK_TRUE(comp2var.isDirty());
		}
Esempio n. 20
0
IMPLEMENT_TEST(AnnotationGroupUnitTest, getSet_Name) {
    const U2DbiRef dbiRef(getDbiRef());
    SharedAnnotationData anData = createTestAnnotationData();
    const QString groupName = "subgroup";

    AnnotationTableObject ft("aname_table", dbiRef);
    ft.addAnnotations(QList<SharedAnnotationData>() << anData, groupName);

    AnnotationGroup *rootGroup = ft.getRootGroup();
    CHECK_TRUE(rootGroup->hasValidId(), "Invalid root group ID");
    const QList<AnnotationGroup *> subgroups = rootGroup->getSubgroups();
    CHECK_EQUAL(1, subgroups.size(), "Count of subgroups");

    AnnotationGroup *group = subgroups.first();
    CHECK_EQUAL(groupName, group->getName(), "annotation group name");

    const QString newName = "misc_feature";
    group->setName(newName);
    CHECK_EQUAL(newName, group->getName(), "annotation group name");
}
		TEST(NetworkComponent, CorrectlyWritesDirtyReplications)
		{
			NetworkComponent networkComponent("", nullptr);
			Integer var1 = 1;
			Integer var2 = 2;
			networkComponent.addVariable("var1", &var1);
			networkComponent.addVariable("var2", &var2);

			var1.setDirty(false);
			var2.setDirty(true);

			Buffer buffer;

			networkComponent.writeReplications(&buffer, true);

			ParameterContainer c(&buffer);

			CHECK_FALSE(c.has("var1"));
			CHECK_TRUE(c.has("var2"));
		}
TEST(MEKFGyroAccMagTestGroup, vect_measurement_jacobian)
{
    Eigen::Quaternionf att(Eigen::AngleAxisf(M_PI/2, Eigen::Vector3f::UnitZ()));
    Eigen::Vector3f v_i(0, 1, 0); // expectation of v in inertial frame
    // expectation of v is along [0,1,0] in inertial and [1,0,0] in body frame,
    // because the body frame is oriented +90deg yaw
    k.reset(att);
    Eigen::Vector3f v_b = att.conjugate()._transformVector(v_i); // [1,0,0]
    Eigen::Matrix3f b_to_m = k.vect_measurement_basis_b_frame(v_i);
    //std::cout << std::endl << v_b << std::endl;
    Eigen::Matrix<float, 2, 3> Ha = MEKFGyroAccMag::vect_measurement_jacobian(b_to_m, v_b);
    Eigen::Matrix<float, 2, 3> Ha_exp;
    // sensitivity of z (= last 2 components of v_m) with respect to a:
    //  with respect to a1 (=roll right) = [0, 0]' (v_b is [1, 0, 0], along roll axis)
    //  with respect to a2 (=pitch up) = [0, 1]' (v_b goes down (positive))
    //  with respect to a3 (=yaw right) = [-1, 0]' (v_b goes left (negative))
    Ha_exp << 0, 0, -1,
              0, 1,  0;
    //std::cout << std::endl << Ha << std::endl;
    CHECK_TRUE(Ha.isApprox(Ha_exp));
}
Esempio n. 23
0
int wlan_set_credentials(WLanCredentials* halCred) {
    if (!isSupportedSecurityType((WLanSecurityType)halCred->security) ||
            (halCred->security != WLanSecurityType::WLAN_SEC_UNSEC && halCred->password_len == 0) ||
            halCred->ssid_len == 0) {
        return SYSTEM_ERROR_INVALID_ARGUMENT;
    }
    WifiCredentials cred;
    if (halCred->security != WLanSecurityType::WLAN_SEC_UNSEC) {
        const auto pwd = CString::wrap(strndup(halCred->password, halCred->password_len));
        cred.type(WifiCredentials::PASSWORD);
        cred.password(pwd);
    }
    const auto ssid = CString::wrap(strndup(halCred->ssid, halCred->ssid_len));
    WifiNetworkConfig conf;
    conf.ssid(ssid);
    conf.security(toWifiSecurity(halCred->security));
    conf.credentials(std::move(cred));
    const auto mgr = wifiNetworkManager();
    CHECK_TRUE(mgr, SYSTEM_ERROR_UNKNOWN);
    CHECK(mgr->setNetworkConfig(std::move(conf)));
    return 0;
}
Esempio n. 24
0
// Adds mappings in the namespace and imports in the methodspace for everything
// imported by the given fragment.
static value_t bind_module_fragment_imports(binding_context_t *context,
    value_t imports, value_t bound_fragment) {
  // Import the modules spaces into this fragment and create bindings in the
  // importspace.
  value_t methodspace = get_module_fragment_methodspace(bound_fragment);
  value_t importspace = get_module_fragment_imports(bound_fragment);
  runtime_t *runtime = get_ambience_runtime(context->ambience);
  for (size_t i = 0; i < get_array_buffer_length(imports); i++) {
    // Look up the imported module.
    value_t import_ident = get_array_buffer_at(imports, i);
    value_t import_path = get_identifier_path(import_ident);
    value_t import_head = get_path_head(import_path);
    value_t import_stage = get_identifier_stage(import_ident);
    value_t import_module = get_id_hash_map_at(context->bound_module_map, import_path);
    value_t import_fragment = get_module_fragment_at(import_module, import_stage);
    CHECK_TRUE("import not bound", is_module_fragment_bound(import_fragment));
    value_t import_methods = get_module_fragment_methodspace(import_fragment);
    TRY(add_methodspace_import(runtime, methodspace, import_methods));
    TRY(set_id_hash_map_at(runtime, importspace, import_head,
        import_fragment));
  }
  return success();
}
Esempio n. 25
0
void on_derived_object_exit(value_t self) {
  CHECK_DOMAIN(vdDerivedObject, self);
  genus_descriptor_t *descriptor = get_derived_object_descriptor(self);
  CHECK_TRUE("derived object not scoped", descriptor->on_scope_exit != NULL);
  (descriptor->on_scope_exit)(self);
}
Esempio n. 26
0
// Returns the next byte from the given byte stream.
byte_t byte_stream_read(byte_stream_t *stream) {
  CHECK_TRUE("byte stream empty", byte_stream_has_more(stream));
  byte_t result = blob_byte_at(stream->blob, stream->cursor);
  stream->cursor++;
  return result;
}
Esempio n. 27
0
static void
handler_modify_two_sections(void) {
  bool n1, n2;

  CHECK_TRUE(callback_counter < 2, "Callback was called %d times!", callback_counter+1);
  callback_counter++;

  if (callback_counter > 2) {
    return;
  }
  CHECK_TRUE(handler_1.pre != NULL, "No pre named-section found.");
  CHECK_TRUE(handler_1.post != NULL, "No post named-section found.");

  if (handler_1.pre == NULL || handler_1.post == NULL) {
    return;
  }

  n1 = handler_1.pre->name != NULL && strcmp(handler_1.pre->name, NAME_1) == 0
      && handler_1.post->name != NULL && strcmp(handler_1.post->name, NAME_1) == 0;
  n2 = handler_1.pre->name != NULL && strcmp(handler_1.pre->name, NAME_2) == 0
      && handler_1.pre->name != NULL && strcmp(handler_1.pre->name, NAME_2) == 0;
  CHECK_TRUE(n1 || n2, "Illegal name of changed section: %s %s", handler_1.pre->name, handler_1.post->name);

  if (n1) {
    CHECK_TRUE(!callback_marker[0], "section with first name triggered twice");
    callback_marker[0] = true;

    CHECK_TRUE( entries_1[0].delta_changed, "Key 1 did not change!");
    CHECK_TRUE( entries_1[1].delta_changed, "Key 2 did not change!");
    CHECK_TRUE(!entries_1[2].delta_changed, "Key 3 did change!");

    CHECK_TRUE(strarray_cmp_c(entries_1[0].pre, &value_1) == 0,
        "Unknown pre data for key 1: %s", entries_1[0].pre->value);
    CHECK_TRUE(strarray_cmp_c(entries_1[1].pre, &value_2) == 0,
        "Unknown pre data for key 2: %s", entries_1[1].pre->value);

    CHECK_TRUE(strarray_cmp_c(entries_1[0].post, &value_2) == 0,
        "Unknown post data for key 1: %s", entries_1[0].post->value);
    CHECK_TRUE(strarray_cmp_c(entries_1[1].post, &value_3) == 0,
        "Unknown post data for key 2: %s", entries_1[1].post->value);
  }
  else if (n2) {
    CHECK_TRUE(!callback_marker[1], "section with second name triggered twice");
    callback_marker[1] = true;

    CHECK_TRUE(!entries_1[0].delta_changed, "Key 1 did change!");
    CHECK_TRUE( entries_1[1].delta_changed, "Key 2 did not change!");
    CHECK_TRUE( entries_1[2].delta_changed, "Key 3 did not change!");

    CHECK_TRUE(strarray_cmp_c(entries_1[1].pre, &value_2) == 0,
        "Unknown pre data for key 2: %s", entries_1[0].pre->value);
    CHECK_TRUE(strarray_cmp_c(entries_1[2].pre, &value_3) == 0,
        "Unknown pre data for key 3: %s", entries_1[1].pre->value);

    CHECK_TRUE(strarray_cmp_c(entries_1[1].post, &value_1) == 0,
        "Unknown post data for key 2: %s", entries_1[0].post->value);
    CHECK_TRUE(strarray_cmp_c(entries_1[2].post, &value_2) == 0,
        "Unknown post data for key 3: %s", entries_1[1].post->value);
  }
}
Esempio n. 28
0
static void
handler_modify_section(void) {
  callback_counter++;

  CHECK_TRUE(callback_counter == 1, "Callback was called %d times!", callback_counter);
  if (callback_counter > 1) {
    return;
  }
  CHECK_TRUE(handler_1.pre != NULL, "No pre named-section found.");
  CHECK_TRUE(handler_1.post != NULL, "No post named-section found.");

  if (handler_1.post == NULL || handler_1.pre == NULL) {
    return;
  }

  CHECK_TRUE(handler_1.pre->name != NULL && strcmp(handler_1.pre->name, NAME_1) == 0,
      "Illegal name of changed pre section: %s", handler_1.pre->name);

  CHECK_TRUE(handler_1.post->name != NULL && strcmp(handler_1.post->name, NAME_1) == 0,
      "Illegal name of changed post section: %s", handler_1.post->name);

  CHECK_TRUE( entries_1[0].delta_changed, "Key 1 did not change!");
  CHECK_TRUE( entries_1[1].delta_changed, "Key 2 did not change!");
  CHECK_TRUE(!entries_1[2].delta_changed, "Key 3 did change!");

  CHECK_TRUE(strarray_cmp_c(entries_1[0].pre, &value_2) == 0,
      "Unknown pre data for key 1: %s", entries_1[0].pre->value);
  CHECK_TRUE(strarray_cmp_c(entries_1[1].pre, &value_3) == 0,
      "Unknown pre data for key 1: %s", entries_1[1].pre->value);

  CHECK_TRUE(strarray_cmp_c(entries_1[0].post, &value_1) == 0,
      "Unknown post data for key 1: %s", entries_1[0].post->value);
  CHECK_TRUE(strarray_cmp_c(entries_1[1].post, &value_2) == 0,
      "Unknown post data for key 1: %s", entries_1[1].post->value);
}
Esempio n. 29
0
TEST(mockIComm, IsGdbConnected_ShouldDefaultToReturnTrue)
{
    CHECK_TRUE(IComm_IsGdbConnected(mockIComm_Get()));
}
Esempio n. 30
0
TEST(mockIComm, IsGdbConnected_SetToReturnTrue)
{
    mockIComm_SetIsGdbConnectedFlag(1);
    CHECK_TRUE(IComm_IsGdbConnected(mockIComm_Get()));
}