本文整理汇总了C++中TEST_ASSERT_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_ASSERT_EQUAL函数的具体用法?C++ TEST_ASSERT_EQUAL怎么用?C++ TEST_ASSERT_EQUAL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_ASSERT_EQUAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_Reverse_given_PAOBAAOOOH_find_AOOF_should_return_minus1
void test_Reverse_given_PAOBAAOOOH_find_AOOF_should_return_minus1(void)
{
TEST_ASSERT_EQUAL(-1,Reverse("PAOBAAOOH", "AOOF"));
}
示例2: test_channel_tcp
void
test_channel_tcp(void) {
int sock4, sock6;
socklen_t size;
struct sockaddr_in sin;
struct addrunion addr4, addr6;
struct channel_list *chan_list ;
struct channel *chan4, *chan6, *chan = NULL;
lagopus_result_t ret;
int cnt;
printf("test_channel_tcp in\n");
channel_mgr_initialize();
ret = channel_mgr_channels_lookup_by_dpid(dpid, &chan_list );
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_NOT_FOUND, ret);
TEST_ASSERT_EQUAL(NULL, chan_list );
addrunion_ipv4_set(&addr4, "127.0.0.1");
addrunion_ipv6_set(&addr6, "::1");
ret = channel_mgr_channel_add(bridge_name, dpid, &addr4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_mgr_channel_add(bridge_name, dpid, &addr6);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_mgr_channel_add(bridge_name, dpid, &addr4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_ALREADY_EXISTS, ret);
ret = channel_mgr_channel_lookup(bridge_name, &addr4, &chan4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
TEST_ASSERT_EQUAL(0, channel_id_get(chan4));
ret = channel_port_set(chan4, 10022);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_local_port_set(chan4, 20022);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_local_addr_set(chan4, &addr4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_mgr_channel_add(bridge_name, dpid, &addr6);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_ALREADY_EXISTS, ret);
ret = channel_mgr_channel_lookup(bridge_name, &addr6, &chan6);
TEST_ASSERT_EQUAL(1, channel_id_get(chan6));
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_port_set(chan6, 10023);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_local_port_set(chan6, 20023);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_local_addr_set(chan6, &addr6);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_mgr_channel_lookup_by_channel_id(dpid, 1, &chan);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
TEST_ASSERT_NOT_EQUAL(NULL, chan);
ret = channel_mgr_channel_lookup_by_channel_id(dpid, 9999, &chan);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_NOT_FOUND, ret);
TEST_ASSERT_EQUAL(NULL, chan);
cnt = 0;
ret = channel_mgr_channels_lookup_by_dpid(dpid, &chan_list );
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_list_iterate(chan_list , channel_count, &cnt);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
TEST_ASSERT_EQUAL(2, cnt);
cnt = 0;
ret = channel_mgr_dpid_iterate(dpid, channel_count, &cnt);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
TEST_ASSERT_EQUAL(2, cnt);
run = true;
size = sizeof(sin);
printf("accept in\n");
sock4 = accept(s4, (struct sockaddr *)&sin, &size);
TEST_ASSERT_NOT_EQUAL(-1, sock4);
sock6 = accept(s6, (struct sockaddr *)&sin, &size);
TEST_ASSERT_NOT_EQUAL(-1, sock6);
ret = channel_mgr_channel_lookup(bridge_name, &addr4, &chan4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
channel_refs_get(chan4);
ret = channel_mgr_channel_delete(bridge_name, &addr4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
channel_refs_put(chan4);
ret = channel_mgr_channel_delete(bridge_name, &addr4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_mgr_channel_lookup(bridge_name, &addr4, &chan4);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_NOT_FOUND, ret);
ret = channel_mgr_channel_delete(bridge_name, &addr6);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, ret);
ret = channel_mgr_channel_lookup(bridge_name, &addr6, &chan6);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_NOT_FOUND, ret);
TEST_ASSERT_FALSE(channel_mgr_has_alive_channel_by_dpid(dpid));
//.........这里部分代码省略.........
示例3: setUp
void setUp(void)
{
CMock_Guts_MemFreeAll();
StartingSize = CMock_Guts_MemBytesFree();
TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed());
}
示例4: TEST
TEST(vector_operations, vect_val_from_ind_returns_y_value_on_ind_2){
vect->v[1] = 77;
TEST_ASSERT_EQUAL(77, Vect_read(vect, 2));
}
示例5: test_service
void test_service() {
byte default_pins = _BV(BACK_PIN_CHANGE) | _BV(FRONT_PIN_CHANGE);
// Initial state: hall sensors not triggered
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins);
TEST_ASSERT_EQUAL(NotCalibrated, tank_joint.calibration);
// Initiate calibration
assert_correct_status(tank_arm_calibrate(test_device, TANK_JOINT));
TEST_ASSERT_EQUAL(Calibrating, tank_joint.calibration);
// Some fake movement
motor_step_tick();
motor_step_tick();
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_B_PIN_CHANGE));
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_A_PIN_CHANGE) | _BV(ENC_B_PIN_CHANGE));
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_A_PIN_CHANGE));
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins);
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_B_PIN_CHANGE));
TEST_ASSERT_EQUAL(-2, stepMotorPosition(tank_joint.motor));
TEST_ASSERT_EQUAL(-5, encoderState(tank_joint.encoder));
// Trigger back hall sensor.
// Hall sensors are inverted, so only the front sensor pin is up.
invokePinChangeInterrupt(PORT_PIN_CHANGE, _BV(FRONT_PIN_CHANGE));
motor_step_tick();
TEST_ASSERT_EQUAL(Calibrated, tank_joint.calibration);
TEST_ASSERT_EQUAL(0, stepMotorPosition(tank_joint.motor));
TEST_ASSERT_EQUAL(0, encoderState(tank_joint.encoder));
// Initiate movement
assert_correct_status(tank_arm_move(test_device, (TankArmLongParameter) { TANK_JOINT, 100 }));
// 4 motor ticks, 5 encoder ticks (forward)
motor_step_tick();
motor_step_tick();
motor_step_tick();
motor_step_tick();
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_A_PIN_CHANGE));
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_A_PIN_CHANGE) | _BV(ENC_B_PIN_CHANGE));
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_B_PIN_CHANGE));
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins);
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_A_PIN_CHANGE));
TEST_ASSERT_EQUAL(4, stepMotorPosition(tank_joint.motor));
TEST_ASSERT_EQUAL(5, encoderState(tank_joint.encoder));
// Trigger front hall sensor (force stop movement).
invokePinChangeInterrupt(PORT_PIN_CHANGE, _BV(BACK_PIN_CHANGE));
motor_step_tick();
motor_step_tick();
motor_step_tick();
TEST_ASSERT_EQUAL(4, stepMotorPosition(tank_joint.motor)); // Note moving anymore
// Move backwards a bit, since we are already at the front hall-sensor
assert_correct_status(tank_arm_move(test_device, (TankArmLongParameter) { TANK_JOINT, -50 }));
motor_step_tick();
motor_step_tick();
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins);
invokePinChangeInterrupt(PORT_PIN_CHANGE, default_pins | _BV(ENC_B_PIN_CHANGE));
TankArmState state = {0};
assert_correct_status(tank_arm_state(test_device, TANK_JOINT, &state));
TEST_ASSERT_EQUAL(2, state.motorPos);
TEST_ASSERT_EQUAL(3, state.encoderPos);
TEST_ASSERT_EQUAL(Calibrated, state.calibration);
TEST_ASSERT_EQUAL(FALSE, state.frontSensor);
TEST_ASSERT_EQUAL(FALSE, state.backSensor);
TEST_ASSERT_EQUAL(-50, state.targetPos);
// Recalibrate
assert_correct_status(tank_arm_calibrate(test_device, TANK_JOINT));
TEST_ASSERT_EQUAL(Calibrating, tank_joint.calibration);
// Interrupt calibration by movement
assert_correct_status(tank_arm_move(test_device, (TankArmLongParameter) { TANK_JOINT, 10 }));
TEST_ASSERT_EQUAL(NotCalibrated, tank_joint.calibration);
}
示例6: psa_aead_decrypt_test
int32_t psa_aead_decrypt_test(security_t caller)
{
int32_t i, status;
uint8_t plaintext[BUFFER_SIZE];
psa_key_policy_t policy;
size_t plaintext_length;
int num_checks = sizeof(check1)/sizeof(check1[0]);
uint8_t *nonce, *additional_data;
/* Initialize the PSA crypto library*/
status = val->crypto_function(VAL_CRYPTO_INIT);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1));
for (i = 0; i < num_checks; i++)
{
val->print(PRINT_TEST, "[Check %d] ", g_test_count++);
val->print(PRINT_TEST, check1[i].test_desc, 0);
/* Initialize a key policy structure to a default that forbids all
* usage of the key
*/
val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy);
/* Setting up the watchdog timer for each check */
status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT);
TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2));
/* Set the standard fields of a policy structure */
val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage,
check1[i].key_alg);
memset(plaintext, 0, sizeof(plaintext));
/* Allocate a key slot for a transient key */
status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3));
/* Set the usage policy on a key slot */
status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle,
&policy);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4));
/* Import the key data into the key slot */
status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle,
check1[i].key_type, check1[i].key_data, check1[i].key_length);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5));
if (is_buffer_empty(check1[i].nonce, check1[i].nonce_length) == TRUE)
{
nonce = NULL;
check1[i].nonce_length = 0;
}
else
nonce = check1[i].nonce;
if (is_buffer_empty(check1[i].additional_data, check1[i].additional_data_length) == TRUE)
{
additional_data = NULL;
check1[i].additional_data_length = 0;
}
else
additional_data = check1[i].additional_data;
/* Process an authenticated decryption operation */
status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, check1[i].key_handle,
check1[i].key_alg, nonce, check1[i].nonce_length, additional_data,
check1[i].additional_data_length, check1[i].ciphertext, check1[i].ciphertext_size,
plaintext, check1[i].plaintext_size, &plaintext_length);
TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6));
if (check1[i].expected_status != PSA_SUCCESS)
continue;
/* Check if the length matches */
TEST_ASSERT_EQUAL(plaintext_length, check1[i].expected_plaintext_length,
TEST_CHECKPOINT_NUM(7));
/* Check if the data matches */
TEST_ASSERT_MEMCMP(plaintext, check1[i].expected_plaintext, plaintext_length,
TEST_CHECKPOINT_NUM(8));
}
return VAL_STATUS_SUCCESS;
}
示例7: test_findReverseText_given_WORLD_find_RL_should_return_2
void test_findReverseText_given_WORLD_find_RL_should_return_2()
{
TEST_ASSERT_EQUAL(2, findReverseText("WORLD", "RL"));
}
示例8: test_findReverseText_given_PROGRAMMING_find_CD_should_return_minus_2
void test_findReverseText_given_PROGRAMMING_find_CD_should_return_minus_2()
{
TEST_ASSERT_EQUAL(-2, findReverseText("PROGRAMMING", "CD"));
}
示例9: TEST
TEST(LightScheduler, CreateDoesNotChangeTheLights)
{
TEST_ASSERT_EQUAL(NONE, LightControllerSpy_GetLastId());
TEST_ASSERT_EQUAL(NONE, LightControllerSpy_GetLastState());
}
示例10: test_findReverseText_given_HELLO_find_D_should_return_minus_2
void test_findReverseText_given_HELLO_find_D_should_return_minus_2()
{
TEST_ASSERT_EQUAL(-2, findReverseText("HELLO", "D"));
}
示例11: checkLightState
static void checkLightState(int id, int level)
{
TEST_ASSERT_EQUAL(id, LightControllerSpy_GetLastId());
TEST_ASSERT_EQUAL(level, LightControllerSpy_GetLastState());
}
示例12: test_Reverse_given_LOVE_find_O_should_return_1
void test_Reverse_given_LOVE_find_O_should_return_1(void)
{
TEST_ASSERT_EQUAL(1,Reverse("LOVE", "O"));
}
示例13: gender_test
static void gender_test(enum pkmn_game game)
{
enum pkmn_error error = PKMN_ERROR_NONE;
enum pkmn_gender gender = PKMN_GENDER_GENDERLESS;
// Single-gender
struct pkmn_pokemon nidorina = empty_pokemon;
error = pkmn_pokemon_init(
PKMN_SPECIES_NIDORINA,
game,
"",
50,
&nidorina
);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_NOT_NULL(nidorina.p_internal);
error = pkmn_pokemon_get_gender(
&nidorina,
&gender
);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_EQUAL(PKMN_GENDER_FEMALE, gender);
error = pkmn_pokemon_set_gender(
&nidorina,
PKMN_GENDER_FEMALE
);
PKMN_TEST_ASSERT_SUCCESS(error);
error = pkmn_pokemon_set_gender(
&nidorina,
PKMN_GENDER_MALE
);
TEST_ASSERT_EQUAL(PKMN_ERROR_INVALID_ARGUMENT, error);
error = pkmn_pokemon_set_gender(
&nidorina,
PKMN_GENDER_GENDERLESS
);
TEST_ASSERT_EQUAL(PKMN_ERROR_INVALID_ARGUMENT, error);
error = pkmn_pokemon_free(&nidorina);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_NULL(nidorina.p_internal);
struct pkmn_pokemon nidorino = empty_pokemon;
error = pkmn_pokemon_init(
PKMN_SPECIES_NIDORINO,
game,
"",
50,
&nidorino
);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_NOT_NULL(nidorino.p_internal);
error = pkmn_pokemon_get_gender(
&nidorino,
&gender
);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_EQUAL(PKMN_GENDER_MALE, gender);
error = pkmn_pokemon_set_gender(
&nidorino,
PKMN_GENDER_MALE
);
PKMN_TEST_ASSERT_SUCCESS(error);
error = pkmn_pokemon_set_gender(
&nidorino,
PKMN_GENDER_FEMALE
);
TEST_ASSERT_EQUAL(PKMN_ERROR_INVALID_ARGUMENT, error);
error = pkmn_pokemon_set_gender(
&nidorino,
PKMN_GENDER_GENDERLESS
);
TEST_ASSERT_EQUAL(PKMN_ERROR_INVALID_ARGUMENT, error);
error = pkmn_pokemon_free(&nidorino);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_NULL(nidorino.p_internal);
struct pkmn_pokemon magnemite = empty_pokemon;
error = pkmn_pokemon_init(
PKMN_SPECIES_MAGNEMITE,
game,
"",
50,
&magnemite
);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_NOT_NULL(magnemite.p_internal);
error = pkmn_pokemon_get_gender(
&magnemite,
&gender
);
PKMN_TEST_ASSERT_SUCCESS(error);
TEST_ASSERT_EQUAL(PKMN_GENDER_GENDERLESS, gender);
//.........这里部分代码省略.........
示例14: test_findReverseText_given_ABCDEFG_find_EF_should_return_4
void test_findReverseText_given_ABCDEFG_find_EF_should_return_4()
{
TEST_ASSERT_EQUAL(4, findReverseText("ABCDEFG", "EF"));
}
示例15: psa_aead_decrypt_negative_test
int32_t psa_aead_decrypt_negative_test(security_t caller)
{
int32_t i, status;
uint8_t plaintext[BUFFER_SIZE];
psa_key_policy_t policy;
size_t plaintext_length;
int num_checks = sizeof(check2)/sizeof(check2[0]);
uint8_t *nonce, *additional_data;
/* Initialize the PSA crypto library*/
status = val->crypto_function(VAL_CRYPTO_INIT);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1));
for (i = 0; i < num_checks; i++)
{
/* Initialize a key policy structure to a default that forbids all
* usage of the key
*/
val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy);
/* Setting up the watchdog timer for each check */
status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT);
TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2));
/* Set the standard fields of a policy structure */
val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage,
check2[i].key_alg);
if (is_buffer_empty(check2[i].nonce, check2[i].nonce_length) == TRUE)
{
nonce = NULL;
check2[i].nonce_length = 0;
}
else
nonce = check2[i].nonce;
if (is_buffer_empty(check2[i].additional_data, check2[i].additional_data_length) == TRUE)
{
additional_data = NULL;
check2[i].additional_data_length = 0;
}
else
additional_data = check2[i].additional_data;
val->print(PRINT_TEST, "[Check %d] Test psa_aead_decrypt - invalid key handle\n",
g_test_count++);
/* Process an authenticated decryption operation */
status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, check2[i].key_handle,
check2[i].key_alg, nonce, check2[i].nonce_length, additional_data,
check2[i].additional_data_length, check2[i].ciphertext, check2[i].ciphertext_size,
plaintext, check2[i].plaintext_size, &plaintext_length);
TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3));
val->print(PRINT_TEST, "[Check %d] Test psa_aead_decrypt - zero as key handle\n",
g_test_count++);
/* Process an authenticated decryption operation */
status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, 0,
check2[i].key_alg, nonce, check2[i].nonce_length, additional_data,
check2[i].additional_data_length, check2[i].ciphertext, check2[i].ciphertext_size,
plaintext, check2[i].plaintext_size, &plaintext_length);
TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4));
val->print(PRINT_TEST, "[Check %d] Test psa_aead_decrypt - empty key handle\n",
g_test_count++);
/* Allocate a key slot for a transient key */
status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5));
/* Set the usage policy on a key slot */
status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle,
&policy);
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6));
/* Process an authenticated decryption operation */
status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, check2[i].key_handle,
check2[i].key_alg, nonce, check2[i].nonce_length, additional_data,
check2[i].additional_data_length, check2[i].ciphertext, check2[i].ciphertext_size,
plaintext, check2[i].plaintext_size, &plaintext_length);
TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7));
}
return VAL_STATUS_SUCCESS;
}