示例#1
0
void test_jalp_transform_encryption_info_create_returns_null_with_bad_input()
{
	uint8_t fake[] = { 1, 2, 3, 4 };
	struct jalp_transform_encryption_info *new_info = NULL;
	new_info = jalp_transform_encryption_info_create(NULL, 0, NULL, 0);
	assert_equals((void*) NULL, new_info);
	new_info = jalp_transform_encryption_info_create(NULL, 1, NULL, 0);
	assert_equals((void*) NULL, new_info);
	new_info = jalp_transform_encryption_info_create(NULL, 0, NULL, 1);
	assert_equals((void*) NULL, new_info);
	new_info = jalp_transform_encryption_info_create(NULL, 1, NULL, 1);
	assert_equals((void*) NULL, new_info);

	new_info = jalp_transform_encryption_info_create(fake, 0, NULL, 0);
	assert_equals((void*) NULL, new_info);
	new_info = jalp_transform_encryption_info_create(NULL, 0, fake, 0);
	assert_equals((void*) NULL, new_info);
	new_info = jalp_transform_encryption_info_create(fake, 0, fake, 0);
	assert_equals((void*) NULL, new_info);
}
/**
#TEST:Test for the validation of function sm_afterTest_enter() with state4 as the actual state

This test set the state to st_afterTest_State4 and runs sm_afterTest_enter.
For validation the variables and triggers are tested against the expected values.
*/
void test_sm_afterTest_enter_in_state4()
{
	SM_afterTest_Handle handle;

    /* Test for state 4 */
    /********************/
    specialInit(&handle, st_afterTest_State4);

    afterTest_Iface_setVariable(&handle.ihandle, waitTime, 500);

    /* run the function in question */
	sm_afterTest_enter(&handle.startHandle);

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State4, handle.state);
	assert_equals(0, afterTest_Iface_getVariable(&handle.ihandle, st));
	assert_equals(400, afterTest_Iface_getVariable(&handle.ihandle, waitTime));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

}
void test_app_metadata_to_elem_works_for_custom()
{
	xmlNodePtr new_elem = NULL;
	enum jal_status ret;
	app_meta->type = JALP_METADATA_CUSTOM;
	app_meta->custom = jal_strdup(CUSTOM_XML);
	ret = jalp_app_metadata_to_elem(app_meta, ctx, doc, &new_elem);
	assert_equals(JAL_OK, ret);
	assert_not_equals(NULL, new_elem);

	assert_tag_equals(APP_META_TAG, new_elem);
	xmlDocSetRootElement(doc, new_elem);
	assert_true(0 == validate(doc, __FUNCTION__, TEST_XML_APP_META_TYPES_SCHEMA, 0));

	xmlChar *jid = xmlGetProp(new_elem, xml_jid_attr_name);
	assert_true(0 == strncmp(JID_PREFIX, (char *)jid, strlen(JID_PREFIX)));
	char *uuidstr = (char *)jid + strlen(JID_PREFIX);
	uuid_t uuid;
	assert_true(0 == uuid_parse(uuidstr, uuid));
	xmlFree(jid);

	xmlNodePtr event_id = jal_get_first_element_child(new_elem);
	assert_not_equals(NULL, event_id);
	assert_tag_equals(EVENT_ID_TAG, event_id);
	assert_content_equals(EVENT_ID, event_id);

	xmlNodePtr custom = event_id->next;
	assert_not_equals(NULL, custom);
	assert_tag_equals(CUSTOM_TAG, custom);

	xmlNodePtr foobar = jal_get_first_element_child(custom);
	assert_tag_equals(FOO_TAG, foobar);

	xmlNodePtr should_be_null = custom->next;
	assert_pointer_equals((void*)NULL, should_be_null);
	free(app_meta->custom);
	app_meta->custom = NULL;
}
示例#4
0
static void test_addNodeInTree_DuplicateNode() {
    before();
    char *path = get_absolute_path(testdir_path, "/cepa.jpg");

    VnrFile *vnrfile = vnr_file_create_new(path, "cepa.jpg", FALSE);
    GNode *node = g_node_new(vnrfile);

    GNode *tree = get_tree(SINGLE_FILE, FALSE, FALSE);
    tree = get_root_node(tree);

    add_node_in_tree(tree, node);
    char* expected = KWHT TESTDIRNAME RESET " (3 children)\n\
├─ bepa.png\n\
├─ cepa.jpg\n\
└─ epa.png\n\
";

    assert_equals("Add node in tree ─ Duplicate node: F ─ Recursive: F", expected, print_and_free_tree(tree));

    free(path);
    free_whole_tree(node);
    after();
}
示例#5
0
static void test_addNodeInTree_TreesIn() {
    before();

    GNode *tree = get_tree(SINGLE_FILE, FALSE, FALSE);
    GNode *node = get_tree(SINGLE_FILE, FALSE, FALSE);
    tree = get_root_node(tree);
    node = get_root_node(node);

    add_node_in_tree(tree, node);
    char* expected = KWHT TESTDIRNAME RESET " (4 children)\n\
├─ bepa.png\n\
├─ cepa.jpg\n\
├─ epa.png\n\
└─┬" KWHT TESTDIRNAME RESET " (3 children)\n\
  ├─ bepa.png\n\
  ├─ cepa.jpg\n\
  └─ epa.png\n\
";

    assert_equals("Add node in tree ─ Tree in tree: F ─ Recursive: F", expected, print_and_free_tree(tree));

    after();
}
示例#6
0
static void test_addNodeInTree_TreeIsLeaf() {
    before();
    char *path = append_strings(testdir_path, "/cepa.jpg");

    VnrFile *vnrfile = vnr_file_create_new(path, "cepa.jpg", FALSE);
    GNode *node = g_node_new(vnrfile);

    GNode *tree = get_tree(SINGLE_FILE, FALSE, FALSE);
    tree = get_root_node(tree);
    GNode *bepa = assert_forward_iteration(tree, "bepa.png");

    add_node_in_tree(bepa, node);
    char* expected = KWHT TESTDIRNAME RESET " (3 children)\n\
├─ bepa.png\n\
├─ cepa.jpg\n\
└─ epa.png\n\
";

    assert_equals("Add node in tree ─ Tree is leaf ─ No change", expected, print_and_free_tree(tree));

    free(path);
    free_whole_tree(node);
    after();
}
示例#7
0
void test_jalp_transform_append_deflate_appends_deflate()
{
	struct jalp_transform *deflate_transform;
	struct jalp_transform *deflate_transform2;
	deflate_transform = jalp_transform_append_deflate(NULL);

	assert_not_equals(NULL, deflate_transform);
	assert_equals(JALP_TRANSFORM_DEFLATE, deflate_transform->type);
	assert_equals((void*)NULL, deflate_transform->enc_info);

	deflate_transform2 = jalp_transform_append_deflate(deflate_transform);
	assert_equals(deflate_transform->next, deflate_transform2);
	assert_not_equals(NULL, deflate_transform2);
	assert_equals(JALP_TRANSFORM_DEFLATE, deflate_transform2->type);
	assert_equals((struct jalp_transform *)NULL, deflate_transform2->next);
	assert_equals((void*)NULL, deflate_transform2->enc_info);

	jalp_transform_destroy(&deflate_transform);
}
void test_log_severity_to_elem_success()
{
	xmlNodePtr new_elem = NULL;
	enum jal_status ret = jalp_log_severity_to_elem(severity, new_doc, &new_elem);
	assert_not_equals(NULL, new_elem);
	assert_equals(JAL_OK, ret);
	xmlDocSetRootElement(new_doc, new_elem);

	xmlChar *ret_val = NULL;
	assert_equals(1, new_doc != NULL);
	assert_equals(0, xmlStrcmp(new_doc->xmlChildrenNode->name, BAD_CAST "Severity"));
	ret_val = xmlGetProp(new_doc->xmlChildrenNode, BAD_CAST NAME_ATTR_NAME);
	assert_equals(0, xmlStrcmp(ret_val, BAD_CAST LEVEL_NAME));
	xmlFree(ret_val);
	ret_val = xmlNodeGetContent(new_doc->xmlChildrenNode);
	assert_equals(0, xmlStrcmp(ret_val, BAD_CAST "1"));
	xmlFree(ret_val);
	assert_equals(0, validate(new_doc, __FUNCTION__, TEST_XML_APP_META_TYPES_SCHEMA, 0));
}
void test_log_severity_to_elem_fails_with_bad_input()
{

	xmlNodePtr new_elem = NULL;

	enum jal_status ret = jalp_log_severity_to_elem(severity, NULL, &new_elem);
	assert_equals(JAL_E_XML_CONVERSION, ret);
	assert_equals(1, new_elem == NULL);

	ret = jalp_log_severity_to_elem(severity, new_doc, NULL);
	assert_equals(JAL_E_XML_CONVERSION, ret);

	ret = jalp_log_severity_to_elem(NULL, new_doc, &new_elem);
	assert_equals(JAL_E_XML_CONVERSION, ret);
	assert_equals(1, new_elem == NULL);

	ret = jalp_log_severity_to_elem(severity, new_doc, &new_elem);
	assert_equals(JAL_OK, ret);
	xmlNodePtr temp = new_elem;
	ret = jalp_log_severity_to_elem(severity, new_doc, &new_elem);
	assert_equals(temp, new_elem);
        assert_not_equals(JAL_OK, ret);
}
void test_log_severity_to_elem_works_with_int_max()
{
	severity->level_val = INT_MAX;
	xmlNodePtr new_elem = NULL;
	enum jal_status ret = jalp_log_severity_to_elem(severity, new_doc, &new_elem);
	assert_not_equals(NULL, new_elem);
	assert_equals(JAL_OK, ret);
	xmlDocSetRootElement(new_doc, new_elem);

	xmlChar *ret_val = NULL;
	assert_equals(1, new_doc != NULL);
	assert_equals(0, xmlStrcmp(new_doc->xmlChildrenNode->name, BAD_CAST "Severity"));
	ret_val = xmlGetProp(new_doc->xmlChildrenNode, BAD_CAST NAME_ATTR_NAME);
	assert_equals(0, xmlStrcmp(ret_val, BAD_CAST LEVEL_NAME));
	xmlFree(ret_val);
	ret_val = xmlNodeGetContent(new_doc->xmlChildrenNode);
	char *max = NULL;
	int check = jal_asprintf(&max, "%d", INT_MAX);
	assert_equals(1, check > 0);
	assert_equals(0, xmlStrcmp(ret_val, BAD_CAST max));
	xmlFree(ret_val);
	assert_equals(0, validate(new_doc, __FUNCTION__, TEST_XML_APP_META_TYPES_SCHEMA, 0));
}
示例#11
0
void test_map_keys()
{
	clear(report);
	assert_equals(map_keys(report, "Aasdf", 1), 1);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x04);

	clear(report);
	assert_equals(map_keys(report, "zasdf", 1), 1);
	assert_equals(report[0], 0);
	assert_equals(report[2], 0x1D);

	clear(report);
	assert_equals(map_keys(report, "^asdf", 1), 1);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x23);

	clear(report);
	assert_equals(map_keys(report, "%{bad+B+2}", 1), 1);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x22);

	clear(report);
	assert_equals(map_keys(report, "%{LeftGUI+ }rocketnumbernine.com", 1), 12);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTGUI);
	assert_equals(report[2], 0x2C);

}
示例#12
0
void test_jalp_transform_append_xor_returns_null_when_key_is_zero()
{
	struct jalp_transform *new_transform = NULL;
	new_transform = jalp_transform_append_xor(NULL, 0);
	assert_equals((void*)NULL, new_transform);
}
示例#13
0
void test_jalp_transform_append_aes_inval_key_size()
{
	struct jalp_transform *invalid_aes_transform;
	invalid_aes_transform = jalp_transform_append_aes(NULL, -50, NULL, NULL);
	assert_equals((struct jalp_transform *)NULL, invalid_aes_transform);
}
示例#14
0
void test_broken_foo_makes_fooify_return_subzero() {
  replace_function(&foo, &negative_foo);
  assert_equals(-1, fooify(3));
}
示例#15
0
void hashmap_test_get_unset_key() { 
	hashmap *map = new_hashmap();
	put( map, "foo", "this is foo" );
	assert_equals( NULL, get( map, "bar" ), "get_unset_key" );
	destroy_hashmap(map);
}
示例#16
0
/** This function creates a series of spec files with typos in the standard 
  * keys and checks to see whether the number of typos returned by \
  * check_levenshtein_distances() (run through read_spec()) is as expected.
  */
void levenshtein_tests(){

char *spec1;
asprintf(&spec1, "1.spec");

char *spec2;
asprintf(&spec2, "2.spec");

char *spec3;
asprintf(&spec3, "3.spec");
        
char *spec4;
asprintf(&spec4, "4.spec");
        
char *spec5;
asprintf(&spec5, "5.spec");

     write_a_file(spec1,
     "\n"
     "database: demo.db\n"
     "\n"
     "input {\n"
     "    input file: dc_pums_08.csv\n"
     "    output table: dc \n "
     "    overwrite: y \n "
     "} \n "
     " \n"
     "fields { \n"
     "SCHL: int 0-24 \n"
     "WAGP: real\n"
     "}\n"
     "impute { \n"
     "  min group size: 3\n"
     "  draw count: 3\n"
     "  seed: 2332\n"
     "}\n"
     );

     write_a_file(spec2,
     "\n"
     "database: demo.db\n"
     "\n"
     "input {\n"
     "inpt file: dc_pums_08.csv\n"
     "output table: dc \n "
     "overwrite: y \n "
     "} \n "
     " \n"
     "fields { \n"
     "AGEP: int 0-116} \n"
     "\n"
     "recodes{\n"
     "CATAGE {\n"
     "1|AGEP between 0 and 15\n"
     "2|AGEP between 16 and 64\n"
     "3|} \n"
     "}"
     );

     write_a_file(spec3,
     "\n"
     "database: demo.db\n"
     "\n"
     "input{\n"
     "input file: dc_pums_08.csv\n"
     "outpt table: dc \n "
     "ovewrite: y} \n "
     " \n"
     "fields { \n"
     "SCHL: int 0-24 \n"
     "WAGP: real\n"
     "}\n"
     "impute {\n"
     "  sed: 2332:\n"
     "  min gruop size: 3\n"
     "  draw count: 3\n"
     "}\n"
     );


     write_a_file(spec4,
     "\n"
     "databas: demo.db\n"
     "\n"
     "input {\n"
     "input file: dc_pums_08.csv\n"
     "output table: dc \n "
     "ovewrite: y \n "
     "} \n "
     " \n"
     "fields { \n"
     "AGEP: int 0-116} \n"
     "\n"
     "checks {\n"
     "AGEP < 0 \n"
     "\n"
     "AGEP > 95 => AGEP = 95 }\n"
     );


     write_a_file(spec5,
     "database: demo.db\n"
     "\n"
     "database: demo.db\n"
     "impute {\n"
     "inupt tabl: dc \n"
     "draw counn: 3\n"
     "seed:2332\n"
     "methd: hot deck\n}"
     );

    
char *db_dummy;

     read_spec(&spec1, &db_dummy);
     int num_typos_spec1 = get_num_typos();
     printf("There were %d typos when reading %s\n", num_typos_spec1, spec1);
     assert_equals(get_num_typos(), 0);

     read_spec(&spec2, &db_dummy);
     int num_typos_spec2 = get_num_typos();
     printf("There were %d typos when reading %s\n", num_typos_spec2, spec2);
     assert_equals(get_num_typos(), 1);

     read_spec(&spec3, &db_dummy);
     int num_typos_spec3 = get_num_typos();
     printf("There were %d typos when reading %s\n", num_typos_spec3, spec3);
     assert_equals(get_num_typos(), 4);
     
     read_spec(&spec4, &db_dummy);
     int num_typos_spec4 = get_num_typos();
     printf("There were %d typos when reading %s\n", num_typos_spec4, spec4);
     assert_equals(get_num_typos(), 1);

     read_spec(&spec5, &db_dummy);
     int num_typos_spec5 = get_num_typos();
     printf("There were %d typos when reading %s\n", num_typos_spec5, spec5);
     assert_equals(get_num_typos(), 3);
}
示例#17
0
/**
 * Test a hash algorithm on given message by comparing calculated result with
 * expected one. Report error on fail.
 *
 * @param message the message to hash
 * @param expected_hash the expected hash balue
 * @param hash_id id of the algorithm to test
 */
static void test_str(const char* message, const char* expected_hash, unsigned hash_id)
{
    char* obtained = calc_sum(message, hash_id);
    assert_equals(obtained, expected_hash, rhash_get_name(hash_id), message);
}
/**
#TEST: Test for the validation of function sm_afterTest_runCycle() with the run to completion ability

This test set the state to st_afterTest_State3 and runs sm_afterTest_runCycle(). It is expected, that
at the first run the function returns FALSE to indicate that the statemachine has not entered a stable
state. As there is a unconditioned transition to state 1. This state is reached after the first run.
Therefor the variable st is set to 1. The variable waitTime is not touched in any kind, as the state 3
is not entered, nor is state 4 entered.

The second call of the function sm_afterTest_runCycle() returns TRUE, as there is no trigger for
a transition.
*/
void test_sm_afterTest_runCycle_inState3_RTC()
{
	AfterTest_Handle handle;

    /* Initialize once and follow the different stages */
    specialInit(&handle, st_afterTest_State3);

    /* run the state machine loop -> the state machine should be finished
       Return value is TRUE */
    assert_equals(FALSE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

    /* run the state machine loop -> the state machine should be finished
       Return value is TRUE */
    assert_equals(TRUE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

}
示例#19
0
void test_that_setup_works() {
  assert_equals(A_VALUE, a);
}
示例#20
0
      CPUNIT_TEST(FixtureTest::nesting::InnerFixTest, test_set_up) {
	assert_not_null("Inner set-up has not done its job!", message);
	assert_equals("Inner message value not correctly set.", expected_inner, *message);
      }
示例#21
0
void test_map_extension_block()
{
	// simple modifiers
	clear(report);
	assert_equals(map_extension_block(report, "%{LeftControl}"), 14);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTCTRL);

	clear(report);
	assert_equals(map_extension_block(report, "%{RightGUI}"), 11);
	assert_equals(report[0], KEYBOARD_MODIFIER_RIGHTGUI);


	// modifier + key
	clear(report);
	assert_equals(map_extension_block(report, "%{LeftGUI+a}"), 12);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTGUI);
	assert_equals(report[2], 0x04);

	// modifier + implicit shift (B = b + leftshift)
	clear(report);
	assert_equals(map_extension_block(report, "%{LeftGUI+B}"), 12);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTGUI | KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x05);

	// multiple
	clear(report);
	assert_equals(map_extension_block(report, "%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}"), 42);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_LEFTALT | KEYBOARD_MODIFIER_LEFTGUI);
	assert_equals(report[2], 0x05);

	// multiple characters
	clear(report);
	assert_equals(map_extension_block(report, "%{.+LeftGUI+B+2}"), 16);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTGUI | KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x37);
	assert_equals(report[3], 0x05);
	assert_equals(report[4], 0x1F);


	// non such token - the % will be consumed
	clear(report);
	assert_equals(map_extension_block(report, "%{bad+B+2}"), 1);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x22);

	// hex
	clear(report);
	assert_equals(map_extension_block(report, "%{LeftShift+0x31}"), 17);
	assert_equals(report[0], KEYBOARD_MODIFIER_LEFTSHIFT);
	assert_equals(report[2], 0x31);
}
示例#22
0
void
test_assert_equals() {
  assert_equals(0, 0);
}
示例#23
0
/**
 * Test a hash algorithm against a message of given length and consisting
 * of repeated chunks.
 * Report error if calculated hash doesn't coincide with expected value.
 *
 * @param hash_id id of the algorithm to test
 * @param chunk the message chunk as a null-terminated string
 * @param size the length of message of zeroes in bytes
 * @param expected_hash the expected hash balue
 */
static void test_long_msg(unsigned hash_id, const char* chunk, size_t size, const char* expected_hash)
{
    size_t chunk_length = strlen(chunk);
    char* obtained = calc_sums_c(chunk, chunk_length, size, hash_id);
    assert_equals(obtained, expected_hash, rhash_get_name(hash_id), chunk);
}
示例#24
0
void test_jalp_transform_append_other_returns_null_when_uri_is_null()
{
	assert_equals((struct jalp_transform *)NULL, jalp_transform_append_other(NULL, NULL, "value"));
}
/**
#TEST: Testing for state machine behavior when trigger1 is raised

The test expects that state 3 is left to reach state 1 independent of the trigger, that is set.
As the trigger is not used for the transition. It is still set after the call to runCycle().

Furthermore the variable st is set to 1 and the variable waitTime is not touched.
*/
void test_sm_afterTest_runCycle_inState3_trigger1()
{
	AfterTest_Handle handle;

    /* Initialize once and follow the different stages */
    specialInit(&handle, st_afterTest_State3);

    afterTest_Iface_raiseTrigger(&handle.ihandle, trigger1);

    /* at this point, the run has not completed */
    assert_equals(FALSE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(TRUE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

    /* at this point, the run has completed */
    assert_equals(TRUE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(TRUE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

}
示例#26
0
static void assert_child_is_equal(char* description, GNode* tree, char* expected) {
    VnrFile *vnrfile = tree != NULL ? tree->data : NULL;
    assert_equals(description, expected, vnrfile != NULL ? vnrfile->path : "NULL");
}
void test_that_fails() {
	char test[5] = "test";
	/* Uses the function passed as last parameter to compare arguments */
	assert_equals("This test should never pass.", test, example, comparing);
}
示例#28
0
void
test_unittest_abs() {
  assert_equals(UNITTEST_ABS(-4.0), 4.0);
  assert_equals(UNITTEST_ABS(4.0), 4.0);
}
示例#29
0
文件: mesg.c 项目: loudambiance/rirc
static void
test_send_connect(void)
{
	/* /connect [(host) | (host:port) | (host port)] */

	/* No args, connected, should issue an error message */
	server_connect__called__ = 0;
	server_connect__host__ = NULL;
	server_connect__port__ = NULL;
	*err = 0;

	mock_s.soc = 1; /* Non-negative socket implies connected */

	char str1[] = "";
	send_connect(err, str1, c);

	assert_equals(server_connect__called__, 0);
	assert_strcmp(err, "Error: Already connected or reconnecting to server");


	/* No args, not connected, should attempt to reconnect on the current server */
	server_connect__called__ = 0;
	server_connect__host__ = NULL;
	server_connect__port__ = NULL;

	mock_s.soc = -1; /* -1 socket implies not connected */

	char str2[] = "";
	send_connect(err, str2, c);

	assert_equals(server_connect__called__, 1);
	assert_strcmp(server_connect__host__, "mock-host");
	assert_strcmp(server_connect__port__, "mock-port");


	/* <server> */
	server_connect__called__ = 0;
	server_connect__host__ = NULL;
	server_connect__port__ = NULL;

	char str3[] = "server.tld";
	send_connect(err, str3, c);

	assert_equals(server_connect__called__, 1);
	assert_strcmp(server_connect__host__, "server.tld");
	assert_strcmp(server_connect__port__, "6667");


	/* <server>:<port> */
	server_connect__called__ = 0;
	server_connect__host__ = NULL;
	server_connect__port__ = NULL;

	char str4[] = "server.tld:123";
	send_connect(err, str4, c);

	assert_equals(server_connect__called__, 1);
	assert_strcmp(server_connect__host__, "server.tld");
	assert_strcmp(server_connect__port__, "123");


	/* <server> <port> */
	server_connect__called__ = 0;
	server_connect__host__ = NULL;
	server_connect__port__ = NULL;

	char str5[] = "server.tld 123";
	send_connect(err, str5, c);

	assert_equals(server_connect__called__, 1);
	assert_strcmp(server_connect__host__, "server.tld");
	assert_strcmp(server_connect__port__, "123");
}