本文整理汇总了C++中CuAssertStrEquals函数的典型用法代码示例。如果您正苦于以下问题:C++ CuAssertStrEquals函数的具体用法?C++ CuAssertStrEquals怎么用?C++ CuAssertStrEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CuAssertStrEquals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestCuStringNew
void TestCuStringNew(CuTest* tc)
{
CuString* str = CuStringNew();
CuAssertTrue(tc, 0 == str->length);
CuAssertTrue(tc, 0 != str->size);
CuAssertStrEquals(tc, "", str->buffer);
}
示例2: TestCuSuiteDetails_MultiplePasses
void TestCuSuiteDetails_MultiplePasses(CuTest* tc)
{
CuSuite ts;
CuTest tc1, tc2;
CuString details;
const char* expected;
CuSuiteInit(&ts);
CuTestInit(&tc1, "TestPasses", TestPasses);
CuTestInit(&tc2, "TestPasses", TestPasses);
CuStringInit(&details);
CuSuiteAdd(&ts, &tc1);
CuSuiteAdd(&ts, &tc2);
CuSuiteRun(&ts);
CuSuiteDetails(&ts, &details);
CuAssertTrue(tc, ts.count == 2);
CuAssertTrue(tc, ts.failCount == 0);
expected =
"OK (2 tests)\n";
CuAssertStrEquals(tc, expected, details.buffer);
}
示例3: test_move_illegal
static void test_move_illegal(CuTest * tc) {
void (*event_cb)(const char *, ...);
unit * u;
region * r, ** path;
svc.reset();
event_cb = svc.add_event;
svc.add_event = record_events;
num_events = 0;
r = svc.regions->create(0, 0);
u = svc.units->create();
svc.regions->add_unit(r, u);
kv_seti(&u->stats, "speed", 1);
path = malloc(sizeof(region *)*2);
path[0] = svc.regions->create(2, 0);
path[1] = 0;
u_set_moves(u, path);
svc.units->set_region(u, r);
do_movement();
CuAssertPtrEquals(tc, r, svc.units->get_region(u));
CuAssertIntEquals(tc, 1, num_events);
CuAssertStrEquals(tc, "illegal_move", events[0]);
svc.add_event = event_cb;
}
示例4: TestReverseWithShortString
void TestReverseWithShortString(CuTest *tc) {
DHString *string = dhstring_new("Hello world!");
dhstring_reverse_in_place(string);
const char *actual = dhstring_to_array(string);
const char *expected = "!dlrow olleH";
CuAssertStrEquals(tc, expected, actual);
}
示例5: TestCuStringAppendNULL
void TestCuStringAppendNULL(CuTest* tc)
{
CuString* str = CuStringNew();
CuStringAppend(str, NULL);
CuAssertIntEquals(tc, 4, str->length);
CuAssertStrEquals(tc, "NULL", str->buffer);
}
示例6: TestReverseWithEmptyString
void TestReverseWithEmptyString(CuTest *tc) {
DHString *string = dhstring_new("");
dhstring_reverse_in_place(string);
const char *actual = dhstring_to_array(string);
const char *expected = "";
CuAssertStrEquals(tc, expected, actual);
}
示例7: testSetNormalise
void testSetNormalise(CuTest *tc) {
char* input;
char* expected;
setStatus ss;
// TODO: Boundary Case - Max number of chars
// TODO: Boundary Case - Max number of members
// Boundary Case - 29 chars - Should be OK
input = strdup("a i a i a i a e a i a a i a i"); expected = "a e i";
ss = setNormalise(input); CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// Boundary Case - 30 chars - ON THE LIMIT - Should return setBadSet
input = strdup("a i a i a i a e a i a a i a ii"); expected = "a i a i a i a e a i a a i a ii"; // "a e i ii";
ss = setNormalise(input); CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setBadSet, ss);
// Boundary Case - 9 members - Should be OK
input = strdup("j i h g e d c b a"); expected = "a b c d e g h i j";
ss = setNormalise(input); CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// Boundary Case - 10 members - Should return setBadSet
input = strdup("j i h g e d c b a z"); expected = "a b c d e g h i j z";
ss = setNormalise(input); CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setBadSet, ss);
input = strdup("a i a i h g f e d c b a i a i"); expected = "a b c d e f g h i"; ss = setNormalise(input);
CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// General Case - duplicates and ordering
input = strdup("i h g f e d c b a"); expected ="a b c d e f g h i";ss = setNormalise(input);
CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// General Case - duplicates and ordering
input = strdup("c c c c c c d a"); expected = "a c d"; ss = setNormalise(input);
CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// General Case - duplicates and ordering
input = strdup("beta alpha beta gamma alpha"); expected = "alpha beta gamma"; ss = setNormalise(input);
CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// Boundary Case - empty set supplied
input = strdup(""); expected = ""; ss = setNormalise(input);
CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setOK, ss);
// Exceptional Case - NULL supplied
input = NULL; expected = NULL; ss = setNormalise(input);
CuAssertStrEquals(tc, expected, input); CuAssertIntEquals(tc, setBadSet, ss);
} //testSetNormalise
示例8: test_uri_norm_scheme_2
test_uri_norm_scheme_2(CuTest *tc)
{
char *seed = strdup("hTTp://www.example.com/test/func.cgi?x=y&z=j");
uriobj_t uri;
uri_parse(&uri, re, seed);
uri_norm_scheme(&uri);
CuAssertStrEquals(tc, *uri.uri_scheme, "http" );
}
示例9: snprintf_underflow
static void snprintf_underflow(CuTest *tc)
{
char buf[20];
int rv;
rv = apr_snprintf(buf, sizeof buf, "%.2f", (double)0.0001);
CuAssertIntEquals(tc, 4, rv);
CuAssertStrEquals(tc, "0.00", buf);
rv = apr_snprintf(buf, sizeof buf, "%.2f", (double)0.001);
CuAssertIntEquals(tc, 4, rv);
CuAssertStrEquals(tc, "0.00", buf);
rv = apr_snprintf(buf, sizeof buf, "%.2f", (double)0.01);
CuAssertIntEquals(tc, 4, rv);
CuAssertStrEquals(tc, "0.01", buf);
}
示例10: test_json_write
static void test_json_write(CuTest * tc) {
char buf[256];
cJSON * json = cJSON_CreateObject();
stream strm;
mstream_init(&strm);
cJSON_AddNumberToObject(json, "turn", 1);
json_write(json, &strm);
strm.api->rewind(strm.handle);
strm.api->readln(strm.handle, buf, sizeof(buf));
CuAssertStrEquals(tc, "{", buf);
strm.api->readln(strm.handle, buf, sizeof(buf));
CuAssertStrEquals(tc, "\t\"turn\":\t1", buf);
strm.api->readln(strm.handle, buf, sizeof(buf));
CuAssertStrEquals(tc, "}", buf);
cJSON_Delete(json);
mstream_done(&strm);
}
示例11: test_spellref
static void test_spellref(CuTest *tc)
{
spellref *ref;
spell *sp;
test_setup();
ref = spellref_create(NULL, "hodor");
CuAssertPtrNotNull(tc, ref);
CuAssertPtrEquals(tc, NULL, ref->sp);
CuAssertStrEquals(tc, "hodor", ref->_name);
CuAssertPtrEquals(tc, NULL, spellref_get(ref));
CuAssertStrEquals(tc, "hodor", spellref_name(ref));
sp = create_spell("hodor");
CuAssertPtrNotNull(tc, sp);
CuAssertPtrEquals(tc, sp, spellref_get(ref));
spellref_free(ref);
test_teardown();
}
示例12: test_codeblock_execute
// -----------------------------------------------------------------------------
// Test: codeblock_execute() -- simple codeblock
// -----------------------------------------------------------------------------
void test_codeblock_execute(CuTest *tc)
{
Codeblock* cb = codeblock_create();
cb->ast = cb_conststr_create("test");
codeblock_execute(cb); // execute codeblock once
CuAssertIntEquals(tc, CB_VT_STRING, cb_value_get_type(cb->result));
CuAssertStrEquals(tc, "test", cb_string_get(cb->result));
codeblock_execute(cb); // execute a second time
CuAssertIntEquals(tc, CB_VT_STRING, cb_value_get_type(cb->result));
CuAssertStrEquals(tc, "test", cb_string_get(cb->result));
codeblock_free(cb);
}
示例13: Test_d_string_insert_printf
void Test_d_string_insert_printf(CuTest* tc) {
char * test = "foo";
DString * result = d_string_new(test);
d_string_insert_printf(result, 2, "%dbar%d", 5, 7);
CuAssertStrEquals(tc, "fo5bar7o", result->str);
CuAssertIntEquals(tc, 8, result->currentStringLength);
d_string_insert_printf(result, -1, "z", 5, 7);
CuAssertStrEquals(tc, "fo5bar7oz", result->str);
CuAssertIntEquals(tc, 9, result->currentStringLength);
d_string_insert_printf(NULL, 0, NULL);
d_string_free(result, true);
}
示例14: Test_d_string_prepend
void Test_d_string_prepend(CuTest* tc) {
char * test = "foo";
DString * result = d_string_new(test);
d_string_prepend(result, "bar");
CuAssertStrEquals(tc, "barfoo", result->str);
CuAssertIntEquals(tc, 6, result->currentStringLength);
d_string_prepend(result, NULL);
CuAssertStrEquals(tc, "barfoo", result->str);
CuAssertIntEquals(tc, 6, result->currentStringLength);
d_string_prepend(NULL, "bar");
d_string_free(result, true);
}
示例15: test_uri_normalize_2
test_uri_normalize_2(CuTest *tc)
{
char *expect = strdup("http://www.example.com/test/func.cgi?x=y&z=j");
uriobj_t uri;
uri_parse(&uri, re, expect);
int err = uri_normalize(&uri);
CuAssertStrEquals(tc,*uri.uri_host,"www.example.com");
}