本文整理汇总了C++中CU_ASSERT_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ CU_ASSERT_EQUAL函数的具体用法?C++ CU_ASSERT_EQUAL怎么用?C++ CU_ASSERT_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CU_ASSERT_EQUAL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: testAircraftHandling
static void testAircraftHandling (void)
{
const vec2_t destination = { 10, 10 };
campaign_t *campaign;
base_t *base;
aircraft_t *aircraft;
aircraft_t *newAircraft;
aircraft_t *aircraftTemplate;
int firstIdx;
int initialCount;
int count;
int newFound;
ResetCampaignData();
campaign = GetCampaign();
base = CreateBase("unittestaircraft", destination);
CU_ASSERT_PTR_NOT_NULL_FATAL(base);
/** @todo we should not assume that initial base has aircraft. It's a campaign parameter */
aircraft = AIR_GetFirstFromBase(base);
CU_ASSERT_PTR_NOT_NULL_FATAL(aircraft);
/* aircraft should have a template */
aircraftTemplate = aircraft->tpl;
CU_ASSERT_PTR_NOT_NULL_FATAL(aircraftTemplate);
firstIdx = aircraft->idx;
initialCount = AIR_BaseCountAircraft(base);
/* test deletion (part 1) */
AIR_DeleteAircraft(aircraft);
count = AIR_BaseCountAircraft(base);
CU_ASSERT_EQUAL(count, initialCount - 1);
/* test addition (part 1) */
newAircraft = AIR_NewAircraft(base, aircraftTemplate);
CU_ASSERT_PTR_NOT_NULL_FATAL(newAircraft);
count = AIR_BaseCountAircraft(base);
CU_ASSERT_EQUAL(count, initialCount);
/* new aircraft assigned to the right base */
CU_ASSERT_EQUAL(newAircraft->homebase, base);
newFound = 0;
AIR_Foreach(aircraft) {
/* test deletion (part 2) */
CU_ASSERT_NOT_EQUAL(firstIdx, aircraft->idx);
/* for test addition (part 2) */
if (aircraft->idx == newAircraft->idx)
newFound++;
}
/* test addition (part 2) */
CU_ASSERT_EQUAL(newFound, 1);
/* check if AIR_Foreach iterates through all aircraft */
AIR_Foreach(aircraft) {
AIR_DeleteAircraft(aircraft);
}
aircraft = AIR_GetFirstFromBase(base);
CU_ASSERT_PTR_NULL_FATAL(aircraft);
count = AIR_BaseCountAircraft(base);
CU_ASSERT_EQUAL(count, 0);
/* cleanup for the following tests */
E_DeleteAllEmployees(NULL);
base->founded = qfalse;
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:70,代码来源:test_campaign.c
示例2: test_VIDIOC_G_FREQUENCY
void test_VIDIOC_G_FREQUENCY() {
int ret_get, errno_get;
__u32 tuner;
struct v4l2_frequency freq;
tuner = 0;
memset(&freq, 0xff, sizeof(freq));
freq.tuner = tuner;
ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &freq);
errno_get = errno;
dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i\n",
__FILE__, __LINE__, ret_get, errno_get);
if (ret_get == 0) {
CU_ASSERT_EQUAL(ret_get, 0);
CU_ASSERT_EQUAL(freq.tuner, tuner);
//CU_ASSERT(freq.type, ???);
//CU_ASSERT_EQUAL(freq.frequency, ???);
CU_ASSERT_EQUAL(freq.reserved[0], 0);
CU_ASSERT_EQUAL(freq.reserved[1], 0);
CU_ASSERT_EQUAL(freq.reserved[2], 0);
CU_ASSERT_EQUAL(freq.reserved[3], 0);
CU_ASSERT_EQUAL(freq.reserved[4], 0);
CU_ASSERT_EQUAL(freq.reserved[5], 0);
CU_ASSERT_EQUAL(freq.reserved[6], 0);
CU_ASSERT_EQUAL(freq.reserved[7], 0);
dprintf("\tfreq = { "
".tuner = %u, "
".type = 0x%X, "
".frequency = %u "
".reserved[]={ 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0x%X } }\n",
freq.tuner,
freq.type,
freq.frequency,
freq.reserved[0],
freq.reserved[1],
freq.reserved[2],
freq.reserved[3],
freq.reserved[4],
freq.reserved[5],
freq.reserved[6],
freq.reserved[7]
);
} else {
CU_ASSERT_EQUAL(ret_get, -1);
CU_ASSERT_EQUAL(errno_get, EINVAL);
}
}
开发者ID:sanyaade-research-hub,项目名称:ltp,代码行数:55,代码来源:test_VIDIOC_FREQUENCY.c
示例3: test_compareandwrite_miscompare
void
test_compareandwrite_miscompare(void)
{
int i, ret;
unsigned j;
unsigned char *buf = alloca(2 * 256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
"start of the LUN. One Byte miscompare in the final block.");
for (i = 1; i < 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
memset(buf, 'A', 2 * i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE16 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
buf[i * block_size - 27] = 'C';
memset(buf + i * block_size, 'B', i * block_size);
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:0 (if they all contain 'A')", i);
ret = compareandwrite_miscompare(iscsic, tgt_lun, 0,
buf, 2 * i * block_size, block_size, 0, 0, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support "
"COMPARE_AND_WRITE. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
"they are still unchanged as 'A'", i);
ret = read16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) {
if (buf[j] != 'A') {
logging(LOG_VERBOSE, "[FAILED] Data changed "
"eventhough there was a miscompare");
CU_FAIL("Block was written to");
return;
}
}
}
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
"end of the LUN");
for (i = 1; i < 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
i, num_blocks - i);
memset(buf, 'A', 2 * i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(iscsic, tgt_lun, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
buf[i * block_size - 27] = 'C';
memset(buf + i * block_size, 'B', i * block_size);
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:%" PRIu64 " (if they all contain 'A')",
i, num_blocks - i);
ret = compareandwrite_miscompare(iscsic, tgt_lun,
num_blocks - i,
buf, 2 * i * block_size, block_size, 0, 0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
"they are still unchanged as 'A'",
i, num_blocks - i);
ret = read16(iscsic, tgt_lun, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) {
if (buf[j] != 'A') {
logging(LOG_VERBOSE, "[FAILED] Data changed "
//.........这里部分代码省略.........
开发者ID:Swind,项目名称:libiscsi,代码行数:101,代码来源:test_compareandwrite_miscompare.c
示例4: test_packet_output_ipv6_to_gre
static void
test_packet_output_ipv6_to_gre(void)
{
odp_packet_t pkt = ODP_PACKET_INVALID;
odp_event_t ev;
int res;
struct ofp_ether_header *eth;
struct ofp_ip6_hdr *ip6, *ip6_orig;
struct ofp_ip *ip;
struct ofp_greip *greip;
(void)tcp_frame;
(void)icmp_frame;
(void)arp_frame;
(void)icmp6_frame;
if (create_odp_packet_ip6(&pkt, ip6udp_frame, sizeof(ip6udp_frame))) {
CU_FAIL("Fail to create packet");
return;
}
ip6 = odp_packet_l3_ptr(pkt, NULL);
ofp_set_route6_params(OFP_ROUTE6_ADD, 0 /*vrf*/, 100 /*vlan*/, GRE_PORTS,
ip6->ip6_dst.__u6_addr.__u6_addr8, 64 /*masklen*/,
0 /*gw*/, OFP_RTF_NET /* flags */);
res = ofp_ip6_output(pkt, NULL);
CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);
res = ofp_send_pending_pkt();
CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);
ev = odp_queue_deq(dev->outq_def);
CU_ASSERT_NOT_EQUAL_FATAL(ev, ODP_EVENT_INVALID);
pkt = odp_packet_from_event(ev);
CU_ASSERT_EQUAL_FATAL(odp_packet_len(pkt),
sizeof(ip6udp_frame) + 20 + 4);
eth = odp_packet_l2_ptr(pkt, NULL);
if (memcmp(eth->ether_dhost, tun_rem_mac, OFP_ETHER_ADDR_LEN))
CU_FAIL("Bad destination mac address.");
if (memcmp(eth->ether_shost, dev->mac, OFP_ETHER_ADDR_LEN))
CU_FAIL("Bad source mac address.");
ip = odp_packet_l3_ptr(pkt, NULL);
CU_ASSERT_EQUAL(ip->ip_src.s_addr, dev_ip);
CU_ASSERT_EQUAL(ip->ip_dst.s_addr, tun_rem_ip);
CU_ASSERT_EQUAL(ip->ip_p, OFP_IPPROTO_GRE);
greip = (struct ofp_greip *)ip;
CU_ASSERT_EQUAL(greip->gi_g.flags, 0);
CU_ASSERT_EQUAL(greip->gi_g.ptype,
odp_cpu_to_be_16(OFP_ETHERTYPE_IPV6));
/* inner ip */
ip6 = (struct ofp_ip6_hdr *)(greip + 1);
ip6_orig = (struct ofp_ip6_hdr *)
(&orig_pkt_data[OFP_ETHER_HDR_LEN]);
if (memcmp(ip6, ip6_orig,
odp_be_to_cpu_16(ip6_orig->ofp_ip6_plen) + sizeof(*ip6)))
CU_FAIL("Inner IP packet error.");
}
开发者ID:bogdanPricope,项目名称:ofp,代码行数:64,代码来源:ofp_test_packet_output.c
示例5: test_VIDIOC_S_FREQUENCY
void test_VIDIOC_S_FREQUENCY() {
int ret_get, errno_get;
int ret_set, errno_set;
__u32 tuner;
struct v4l2_frequency orig_freq;
struct v4l2_frequency freq;
struct v4l2_frequency new_freq;
tuner = 0;
/* fetch the current frequency setting */
memset(&orig_freq, 0xff, sizeof(orig_freq));
orig_freq.tuner = tuner;
ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &orig_freq);
errno_get = errno;
dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i\n",
__FILE__, __LINE__, ret_get, errno_get);
if (ret_get == 0) {
CU_ASSERT_EQUAL(orig_freq.tuner, tuner);
/* try to set the frequency again to the actual value */
memset(&freq, 0xff, sizeof(freq));
freq.tuner = tuner;
freq.frequency = orig_freq.frequency;
freq.type = V4L2_TUNER_ANALOG_TV;
ret_set = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &orig_freq);
errno_set = errno;
dprintf("\t%s:%u: VIDIOC_S_FREQUENCY, ret_set=%i, errno_set=%i\n",
__FILE__, __LINE__, ret_set, errno_set);
CU_ASSERT_EQUAL(ret_set, 0);
if (ret_set == 0) {
/* check wheteher the frequency has not been changed */
memset(&new_freq, 0xff, sizeof(new_freq));
new_freq.tuner = tuner;
ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq);
errno_get = errno;
dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i\n",
__FILE__, __LINE__, ret_get, errno_get);
CU_ASSERT_EQUAL(ret_get, 0);
if (ret_get == 0) {
dprintf("\t%s:%u: current frequency=%u (expected %u)\n",
__FILE__, __LINE__,
new_freq.frequency, orig_freq.frequency);
CU_ASSERT_EQUAL(new_freq.frequency, orig_freq.frequency);
}
}
} else {
CU_ASSERT_EQUAL(ret_get, -1);
CU_ASSERT_EQUAL(errno_get, EINVAL);
/* VIDIOC_G_FREQUENCY not supported, so shall be VIDIOC_S_FREQUENCY */
memset(&freq, 0, sizeof(freq));
freq.tuner = tuner;
freq.type = V4L2_TUNER_ANALOG_TV;
freq.frequency = 0;
ret_set = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq);
errno_set = errno;
dprintf("\t%s:%u: VIDIOC_S_FREQUENCY, ret_set=%i, errno_set=%i\n",
__FILE__, __LINE__, ret_set, errno_set);
CU_ASSERT_EQUAL(ret_set, -1);
CU_ASSERT_EQUAL(errno_set, EINVAL);
}
}
开发者ID:sanyaade-research-hub,项目名称:ltp,代码行数:77,代码来源:test_VIDIOC_FREQUENCY.c
示例6: test_parser
void test_parser(void)
{
CALC_ELEMENT *e1 = NULL, *e2 = NULL;
double a, b;
strcpy(in_line, "(3+(4-1))*5");
line_len = 11;
CU_ASSERT_EQUAL(parse_line(&e1, &e2), 0);
CU_ASSERT_PTR_NOT_NULL(e1);
CU_ASSERT_PTR_NULL(e2);
CU_ASSERT_EQUAL(canonical_form(&e1), 0);
CU_ASSERT_EQUAL(e1->calc_t, CALC_NUM);
CU_ASSERT_EQUAL(e1->value, 30);
free_calc_element(e1);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "2 * x + 0.5 = 1");
line_len = 15;
CU_ASSERT_EQUAL(parse_line(&e1, &e2), 0);
CU_ASSERT_PTR_NOT_NULL(e1);
CU_ASSERT_PTR_NOT_NULL(e2);
CU_ASSERT_EQUAL(canonical_form(&e1), 0);
CU_ASSERT_EQUAL(canonical_form(&e2), 0);
CU_ASSERT_EQUAL(get_ax_b(e1, &a, &b), 0);
CU_ASSERT_EQUAL(a, 2);
CU_ASSERT_EQUAL(b, 0.5);
CU_ASSERT_EQUAL(e2->calc_t, CALC_NUM);
CU_ASSERT_EQUAL(e2->value, 1);
free_calc_element(e1);
free_calc_element(e2);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "2x + 1 = 2(1-x)");
line_len = 15;
CU_ASSERT_EQUAL(parse_line(&e1, &e2), 0);
CU_ASSERT_PTR_NOT_NULL(e1);
CU_ASSERT_PTR_NOT_NULL(e2);
CU_ASSERT_EQUAL(canonical_form(&e1), 0);
CU_ASSERT_EQUAL(canonical_form(&e2), 0);
CU_ASSERT_EQUAL(get_ax_b(e1, &a, &b), 0);
CU_ASSERT_EQUAL(a, 2);
CU_ASSERT_EQUAL(b, 1);
CU_ASSERT_EQUAL(get_ax_b(e2, &a, &b), 0);
CU_ASSERT_EQUAL(a, -2);
CU_ASSERT_EQUAL(b, 2);
free_calc_element(e1);
free_calc_element(e2);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "14.9 + 1 - 2 3.44");
line_len = 17;
CU_ASSERT_NOT_EQUAL(parse_line(&e1, &e2), 0);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "((12)");
line_len = 5;
CU_ASSERT_NOT_EQUAL(parse_line(&e1, &e2), 0);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "3x + -");
line_len = 6;
CU_ASSERT_NOT_EQUAL(parse_line(&e1, &e2), 0);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "60/5/3*8/4");
line_len = 10;
CU_ASSERT_EQUAL(parse_line(&e1, &e2), 0);
CU_ASSERT_EQUAL(canonical_form(&e1), 0);
CU_ASSERT_EQUAL(e1->calc_t, CALC_NUM);
CU_ASSERT_EQUAL(e1->value, 8);
free_calc_element(e1);
clear_line();
e1 = NULL;
e2 = NULL;
/* log torturing */
strcpy(in_line, "log 5)");
line_len = 6;
CU_ASSERT_NOT_EQUAL(parse_line(&e1, &e2), 0);
clear_line();
e1 = NULL;
e2 = NULL;
strcpy(in_line, "log(9 ");
line_len = 6;
CU_ASSERT_NOT_EQUAL(parse_line(&e1, &e2), 0);
clear_line();
e1 = NULL;
e2 = NULL;
//.........这里部分代码省略.........
开发者ID:nikola-jelic,项目名称:calculator,代码行数:101,代码来源:suite.c
示例7: test_inquiry_block_limits
void
test_inquiry_block_limits(void)
{
int ret;
struct scsi_inquiry_block_limits *bl;
struct scsi_task *bl_task = NULL;
struct scsi_inquiry_logical_block_provisioning *lbp = NULL;
struct scsi_task *lbp_task = NULL;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test of the INQUIRY Block Limits");
CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Block device. Verify that we can read Block Limits VPD");
ret = inquiry(iscsic, tgt_lun,
1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,
64, &bl_task);
CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) {
logging(LOG_NORMAL, "[FAILURE] failed to send inquiry.");
goto finished;
}
bl = scsi_datain_unmarshall(bl_task);
if (bl == NULL) {
logging(LOG_NORMAL, "[FAILURE] failed to unmarshall inquiry "
"datain blob.");
CU_FAIL("[FAILURE] failed to unmarshall inquiry "
"datain blob.");
goto finished;
}
logging(LOG_VERBOSE, "Verify that the PageLength matches up with the size of the DATA-IN buffer.");
CU_ASSERT_EQUAL(bl_task->datain.size, bl_task->datain.data[3] + 4);
if (bl_task->datain.size != bl_task->datain.data[3] + 4) {
logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned. "
"Was %d but expected %d",
bl_task->datain.data[3], bl_task->datain.size - 4);
} else {
logging(LOG_VERBOSE, "[SUCCESS] PageLength matches DataIn buffer size");
}
logging(LOG_VERBOSE, "Verify that the PageLength matches SCSI-level.");
/* if it is not SBC3 then we assume it must be SBC2 */
if (sbc3_support) {
logging(LOG_VERBOSE, "Device claims SBC-3. Verify that " "PageLength == 0x3C");
} else {
logging(LOG_VERBOSE, "Device is not SBC-3. Verify that "
"PageLength == 0x0C (but allow 0x3C too. Some SBC-2 "
"devices support some SBC-3 features.");
}
switch (bl_task->datain.data[3]) {
case 0x3c:
/* accept 0x3c (==SBC-3) for all levels */
if (!sbc3_support) {
logging(LOG_NORMAL, "[WARNING] SBC-3 pagelength (0x3C) "
"returned but SBC-3 support was not claimed "
"in the standard inquiry page.");
}
break;
case 0x0c:
/* only accept 0x0c for levels < SBC-3 */
if (!sbc3_support) {
break;
}
/* fallthrough */
default:
CU_FAIL("[FAILED] Invalid pagelength returned");
logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned.");
}
if (bl_task->datain.data[3] != 0x3c) {
goto finished;
}
/*
* MAXIMUM UNMAP LBA COUNT
* MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT
*/
logging(LOG_VERBOSE, "Try reading the logical block provisioning VPD");
ret = inquiry(iscsic, tgt_lun,
1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
64, &lbp_task);
if (ret == 0) {
lbp = scsi_datain_unmarshall(lbp_task);
if (lbp == NULL) {
logging(LOG_NORMAL, "[FAILURE] failed to unmarshall "
"inquiry datain blob.");
}
}
if (lbp && lbp->lbpu) {
/* We support UNMAP so MAXIMUM UNMAP LBA COUNT and
* MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT.
* They must be > 0.
* It can be 0xffffffff which means no limit, but if there is
* an explicit limit set, then we check that it looks sane.
//.........这里部分代码省略.........
开发者ID:Swind,项目名称:libiscsi,代码行数:101,代码来源:test_inquiry_block_limits.c
示例8: test_string_lenth
void test_string_lenth(void){
string test = "Hello";
int len = string_lenth(test);
CU_ASSERT_EQUAL(len,5);
}
开发者ID:chenjinlei,项目名称:tools,代码行数:5,代码来源:testcase.c
示例9: test_raster_to_gdal
static void test_raster_to_gdal() {
rt_pixtype pixtype = PT_64BF;
rt_raster raster = NULL;
rt_band band = NULL;
uint32_t x;
uint32_t width = 100;
uint32_t y;
uint32_t height = 100;
char srs[] = "PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6370997,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-100],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"2163\"]]";
uint64_t gdalSize;
uint8_t *gdal = NULL;
raster = rt_raster_new(width, height);
CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
band = cu_add_band(raster, pixtype, 1, 0);
CU_ASSERT(band != NULL);
rt_raster_set_offsets(raster, -500000, 600000);
rt_raster_set_scale(raster, 1000, -1000);
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
}
}
gdal = rt_raster_to_gdal(raster, srs, "GTiff", NULL, &gdalSize);
/*printf("gdalSize: %d\n", (int) gdalSize);*/
CU_ASSERT(gdalSize);
/*
FILE *fh = NULL;
fh = fopen("/tmp/out.tif", "w");
fwrite(gdal, sizeof(uint8_t), gdalSize, fh);
fclose(fh);
*/
if (gdal) CPLFree(gdal);
cu_free_raster(raster);
raster = rt_raster_new(width, height);
CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
band = cu_add_band(raster, pixtype, 1, 0);
CU_ASSERT(band != NULL);
rt_raster_set_offsets(raster, -500000, 600000);
rt_raster_set_scale(raster, 1000, -1000);
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
rt_band_set_pixel(band, x, y, x, NULL);
}
}
/* add check that band isn't NODATA */
CU_ASSERT_EQUAL(rt_band_check_is_nodata(band), FALSE);
gdal = rt_raster_to_gdal(raster, srs, "PNG", NULL, &gdalSize);
/*printf("gdalSize: %d\n", (int) gdalSize);*/
CU_ASSERT(gdalSize);
if (gdal) CPLFree(gdal);
cu_free_raster(raster);
}
开发者ID:NianYue,项目名称:pipelinedb,代码行数:69,代码来源:cu_gdal.c
示例10: test_patch_wkb
static void
test_patch_wkb()
{
int i;
int npts = 20;
PCPOINTLIST *pl1;
PCPATCH_UNCOMPRESSED *pu1, *pu2;
PCPATCH *pa1, *pa2, *pa3, *pa4;
size_t z1, z2;
uint8_t *wkb1, *wkb2;
pl1 = pc_pointlist_make(npts);
for ( i = 0; i < npts; i++ )
{
PCPOINT *pt = pc_point_make(simpleschema);
pc_point_set_double_by_name(pt, "x", i*2.123);
pc_point_set_double_by_name(pt, "y", i*2.9);
pc_point_set_double_by_name(pt, "Z", i*0.3099);
pc_point_set_double_by_name(pt, "intensity", 13);
pc_pointlist_add_point(pl1, pt);
}
pa1 = (PCPATCH*)pc_patch_dimensional_from_pointlist(pl1);
wkb1 = pc_patch_to_wkb(pa1, &z1);
// str = hexbytes_from_bytes(wkb1, z1);
// printf("str\n%s\n",str);
pa2 = pc_patch_from_wkb(simpleschema, wkb1, z1);
// printf("pa2\n%s\n",pc_patch_to_string(pa2));
pa3 = pc_patch_compress(pa2, NULL);
// printf("pa3\n%s\n",pc_patch_to_string(pa3));
wkb2 = pc_patch_to_wkb(pa3, &z2);
pa4 = pc_patch_from_wkb(simpleschema, wkb2, z2);
pcfree(wkb2);
// printf("pa4\n%s\n",pc_patch_to_string(pa4));
pu1 = (PCPATCH_UNCOMPRESSED*)pc_patch_uncompressed_from_dimensional((PCPATCH_DIMENSIONAL*)pa1);
pu2 = (PCPATCH_UNCOMPRESSED*)pc_patch_uncompressed_from_dimensional((PCPATCH_DIMENSIONAL*)pa4);
// printf("pu1\n%s\n", pc_patch_to_string((PCPATCH*)pu1));
// printf("pu2\n%s\n", pc_patch_to_string((PCPATCH*)pu2));
CU_ASSERT_EQUAL(pu1->datasize, pu2->datasize);
CU_ASSERT_EQUAL(pu1->npoints, pu2->npoints);
CU_ASSERT(memcmp(pu1->data, pu2->data, pu1->datasize) == 0);
pc_pointlist_free(pl1);
pc_patch_free(pa1);
pc_patch_free(pa2);
pc_patch_free(pa3);
pc_patch_free(pa4);
pc_patch_free((PCPATCH*)pu1);
pc_patch_free((PCPATCH*)pu2);
pcfree(wkb1);
}
开发者ID:caomw,项目名称:pointcloud,代码行数:61,代码来源:cu_pc_patch.c
示例11: test_endian_flip
static void
test_endian_flip()
{
PCPOINT *pt;
double a1, a2, a3, a4, b1, b2, b3, b4;
int rv;
uint8_t *ptr;
/* All at once */
pt = pc_point_make(schema);
a1 = 1.5;
a2 = 1501500.12;
a3 = 19112;
a4 = 200;
rv = pc_point_set_double_by_name(pt, "X", a1);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_set_double_by_name(pt, "Z", a2);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_set_double_by_name(pt, "Intensity", a3);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_set_double_by_name(pt, "UserData", a4);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "X", &b1);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "Z", &b2);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "Intensity", &b3);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "UserData", &b4);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);
CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);
CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);
CU_ASSERT_DOUBLE_EQUAL(a4, b4, 0.0000001);
ptr = uncompressed_bytes_flip_endian(pt->data, schema, 1);
pcfree(pt->data);
pt->data = uncompressed_bytes_flip_endian(ptr, schema, 1);
pcfree(ptr);
rv = pc_point_get_double_by_name(pt, "X", &b1);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "Z", &b2);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "Intensity", &b3);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
rv = pc_point_get_double_by_name(pt, "UserData", &b4);
CU_ASSERT_EQUAL(rv, PC_SUCCESS);
CU_ASSERT_DOUBLE_EQUAL(a1, b1, 0.0000001);
CU_ASSERT_DOUBLE_EQUAL(a2, b2, 0.0000001);
CU_ASSERT_DOUBLE_EQUAL(a3, b3, 0.0000001);
CU_ASSERT_DOUBLE_EQUAL(a4, b4, 0.0000001);
pc_point_free(pt);
}
开发者ID:caomw,项目名称:pointcloud,代码行数:55,代码来源:cu_pc_patch.c
示例12: lingot_config_test
void lingot_config_test() {
lingot_config_create_parameter_specs();
LingotConfig* config = lingot_config_new();
CU_ASSERT_PTR_NOT_NULL_FATAL(config);
lingot_config_load(config, "resources/lingot-001.conf");
CU_ASSERT_EQUAL(config->audio_system, AUDIO_SYSTEM_PULSEAUDIO);
CU_ASSERT(
!strcmp(config->audio_dev[config->audio_system], "alsa_input.pci-0000_00_1b.0.analog-stereo"));
CU_ASSERT_EQUAL(config->sample_rate, 44100);
CU_ASSERT_EQUAL(config->oversampling, 25);
CU_ASSERT_EQUAL(config->root_frequency_error, 0.0);
CU_ASSERT_EQUAL(config->min_frequency, 15.0);
CU_ASSERT_EQUAL(config->sample_rate, 44100);
CU_ASSERT_EQUAL(config->fft_size, 512);
CU_ASSERT_EQUAL(config->temporal_window, ((FLT) 0.32));
CU_ASSERT_EQUAL(config->min_overall_SNR, 20.0);
CU_ASSERT_EQUAL(config->calculation_rate, 20.0);
CU_ASSERT_EQUAL(config->visualization_rate, 30.0);
CU_ASSERT_EQUAL(config->peak_number, 3);
CU_ASSERT_EQUAL(config->peak_half_width, 1);
lingot_config_destroy(config);
}
开发者ID:ronignc,项目名称:lingot,代码行数:27,代码来源:lingot-config-test.c
示例13: test_ofp_packet_input_gre_processed_inner_pkt_forwarded
static void
test_ofp_packet_input_gre_processed_inner_pkt_forwarded(void)
{
odp_packet_t pkt;
odp_event_t ev;
int res;
struct ofp_ether_header *eth;
struct ofp_ip *ip;
struct ofp_ip *ip_encap;
uint32_t dst_ip;
uint8_t dst_mac_addr[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
my_test_val = TEST_LOCAL_HOOK_GRE;
/* Call ofp_packet_input using a GRE pkt with destination ip
* that matches the local ip on ifnet, tunnel found, GRE processed.
* Inner packet does not match local ip, route found,
* packet forwarded */
ifnet->ip_addr = local_ip;
if (create_odp_packet_ip4(&pkt, gre_frame, sizeof(gre_frame),
local_ip, tun_rem_ip)) {
CU_FAIL("Fail to create packet");
return;
}
ip_encap = (struct ofp_ip *)&in_pkt_data[38];
dst_ip = local_ip + 10;
test_ofp_add_route(port, vrf, vlan, ip_encap->ip_dst.s_addr, 24, 4,
dst_ip);
ofp_arp_ipv4_insert(dst_ip, dst_mac_addr, ifnet);
res = ofp_packet_input(pkt, interface_queue[port],
ofp_eth_vlan_processing);
CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);
CU_ASSERT_NOT_EQUAL_FATAL(ev = odp_queue_deq(ifnet->outq_def),
ODP_EVENT_INVALID);
#ifdef SP
CU_ASSERT_EQUAL(odp_queue_deq(ifnet->spq_def), ODP_EVENT_INVALID);
#endif
CU_ASSERT_EQUAL(odp_queue_deq(ifnet->outq_def), ODP_EVENT_INVALID);
pkt = odp_packet_from_event(ev);
eth = odp_packet_data(pkt);
ip = odp_packet_l3_ptr(pkt, NULL);
if (memcmp(eth->ether_dhost, dst_mac_addr, OFP_ETHER_ADDR_LEN))
CU_FAIL("Bad destination mac address.");
if (memcmp(eth->ether_shost, ifnet->mac, OFP_ETHER_ADDR_LEN))
CU_FAIL("Bad source mac address.");
CU_ASSERT_EQUAL(ip->ip_src.s_addr, ip_encap->ip_src.s_addr);
CU_ASSERT_EQUAL(ip->ip_dst.s_addr, ip_encap->ip_dst.s_addr);
if (memcmp(ip + (ip->ip_hl << 2), ip_encap + (ip->ip_hl << 2),
odp_be_to_cpu_16(ip_encap->ip_len) - (ip->ip_hl << 2)))
CU_FAIL("corrupt l3 + data");
odp_packet_free(odp_packet_from_event(ev));
ifnet->ip_addr = 0;
CU_PASS("ofp_packet_input_gre_processed_inner_pkt_to_sp");
}
开发者ID:abhinayramesh,项目名称:ofp,代码行数:64,代码来源:ofp_test_packet_input.c
示例14: test_ofp_packet_input_forwarding_to_output
static void
test_ofp_packet_input_forwarding_to_output(void)
{
odp_packet_t pkt;
odp_event_t ev;
int res;
/* Call ofp_packet_input using a pkt with destination ip
* that does NOT match the local ip on ifnet and a route is found.
* ARP is found for gateway IP.
* Function returns OFP_PKT_PROCESSED and
* packet is forwarded to ofp_ip_output.*/
unsigned char ll_addr[13] = "123456789012";
my_test_val = TEST_FORWARD_HOOK;
CU_ASSERT_EQUAL(
ofp_ipv4_lookup_mac(dst_ipaddr + 1, ll_addr, ifnet), -1);
CU_ASSERT_EQUAL(
ofp_arp_ipv4_insert(dst_ipaddr + 1, ll_addr, ifnet), 0);
if (create_odp_packet_ip4(&pkt, test_frame, sizeof(test_frame),
dst_ipaddr, 0)) {
CU_FAIL("Fail to create packet");
return;
}
res = ofp_packet_input(pkt, interface_queue[port],
ofp_eth_vlan_processing);
CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);
CU_ASSERT_NOT_EQUAL(ev = odp_queue_deq(ifnet->outq_def),
ODP_EVENT_INVALID);
CU_ASSERT_EQUAL(odp_queue_deq(ifnet->outq_def), ODP_EVENT_INVALID);
#ifdef SP
CU_ASSERT_EQUAL(odp_queue_deq(ifnet->spq_def), ODP_EVENT_INVALID);
#endif /* SP */
CU_ASSERT_EQUAL(odp_packet_len(pkt), sizeof(test_frame));
pkt = odp_packet_from_event(ev);
struct ofp_ip *ip_in_pkt_data =
(struct ofp_ip *)(in_pkt_data + OFP_ETHER_HDR_LEN);
ip_in_pkt_data->ip_ttl--;
#ifdef OFP_PERFORMANCE
/*checksum is not filled on ip_output*/
ip_in_pkt_data->ip_sum =
((struct ofp_ip *)odp_packet_l3_ptr(pkt, NULL))->ip_sum;
#else
ip_in_pkt_data->ip_sum = 0;
ip_in_pkt_data->ip_sum = ofp_cksum_buffer((uint16_t *)ip_in_pkt_data,
ip_in_pkt_data->ip_hl<<2);
#endif
if (memcmp((uint8_t *)odp_packet_data(pkt) + odp_packet_l3_offset(pkt),
in_pkt_data + OFP_ETHER_HDR_LEN,
sizeof(test_frame) - OFP_ETHER_HDR_LEN))
CU_FAIL("corrupt l3 + data forwarded");
struct ofp_ether_header *eth =
(struct ofp_ether_header *)odp_packet_l2_ptr(pkt, NULL);
if (memcmp(eth->ether_dhost, ll_addr, OFP_ETHER_ADDR_LEN))
CU_FAIL("Bad destination mac address on the forwarded packet");
CU_ASSERT_EQUAL(eth->ether_type, odp_cpu_to_be_16(OFP_ETHERTYPE_IP));
CU_PASS("ofp_packet_input_forwarding_to_output");
}
开发者ID:abhinayramesh,项目名称:ofp,代码行数:69,代码来源:ofp_test_packet_input.c
示例15: test_binop_cf
void test_binop_cf(void)
{
/* + */
CALC_ELEMENT *e1 = create_number(3.0), *e2 = create_number(-4.0);
CALC_ELEMENT *expr = create_bin_op('+', e1, e2);
CU_ASSERT_PTR_NOT_NULL(expr);
CU_ASSERT_EQUAL(expr->calc_t, CALC_BIN_OP);
CU_ASSERT_EQUAL(expr->bin_op, '+');
CU_ASSERT_EQUAL(expr->status, 0);
CU_ASSERT_EQUAL(expr->value, 1.0);
CU_ASSERT_PTR_NOT_NULL(expr->left);
CU_ASSERT_PTR_NOT_NULL(expr->right);
free_calc_element(expr);
/* - */
e1 = create_number(-7.0);
e2 = create_number(9.0);
expr = create_bin_op('-', e1, e2);
CU_ASSERT_PTR_NOT_NULL(expr);
CU_ASSERT_EQUAL(expr->calc_t, CALC_BIN_OP);
CU_ASSERT_EQUAL(expr->bin_op, '+');
CU_ASSERT_EQUAL(expr->status, 0);
CU_ASSERT_EQUAL(expr->value, 1.0);
CU_ASSERT_PTR_NOT_NULL(expr->left);
CU_ASSERT_PTR_NOT_NULL(expr->right);
CU_ASSERT_EQUAL(expr->right->value, -9.0);
free_calc_element(expr);
/* * */
e1 = create_number(3.0);
e2 = create_number(11.5);
expr = create_bin_op('*', e1, e2);
CU_ASSERT_PTR_NOT_NULL(expr);
CU_ASSERT_EQUAL(expr->calc_t, CALC_BIN_OP);
CU_ASSERT_EQUAL(expr->bin_op, '*');
CU_ASSERT_EQUAL(expr->status, 0);
CU_ASSERT_EQUAL(expr->value, 1.0);
CU_ASSERT_PTR_NOT_NULL(expr->left);
CU_ASSERT_PTR_NOT_NULL(expr->right);
free_calc_element(expr);
/* /, only numbers */
e1 = create_number(-7.0);
e2 = create_number(5.0);
expr = create_bin_op('/', e1, e2);
CU_ASSERT_PTR_NOT_NULL(expr);
CU_ASSERT_EQUAL(expr->calc_t, CALC_BIN_OP);
CU_ASSERT_EQUAL(expr->bin_op, '/');
CU_ASSERT_EQUAL(expr->status, 0);
CU_ASSERT_EQUAL(expr->value, 1.0);
CU_ASSERT_PTR_NOT_NULL(expr->left);
CU_ASSERT_PTR_NOT_NULL(expr->right);
free_calc_element(expr);
/* /, with an x */
e1 = create_x();
e2 = create_number(2.0);
expr = create_bin_op('/', e1, e2);
CU_ASSERT_PTR_NOT_NULL(expr);
CU_ASSERT_EQUAL(expr->calc_t, CALC_BIN_OP);
CU_ASSERT_EQUAL(expr->bin_op, '/');
CU_ASSERT_EQUAL(expr->status, STATUS_X_PRESENT | STATUS_X_IN_DIV);
CU_ASSERT_EQUAL(expr->value, 1.0);
CU_ASSERT_PTR_NOT_NULL(expr->left);
CU_ASSERT_PTR_NOT_NULL(expr->right);
free_calc_element(expr);
}
开发者ID:nikola-jelic,项目名称:calculator,代码行数:67,代码来源:suite.c
示例16: test_gdal_to_raster
static void test_gdal_to_raster() {
rt_pixtype pixtype = PT_64BF;
rt_band band = NULL;
rt_raster raster;
rt_raster rast;
const uint32_t width = 100;
const uint32_t height = 100;
uint32_t x;
uint32_t y;
int v;
double values[width][height];
int rtn = 0;
double value;
GDALDriverH gddrv = NULL;
int destroy = 0;
GDALDatasetH gdds = NULL;
raster = rt_raster_new(width, height);
CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
band = cu_add_band(raster, pixtype, 1, 0);
CU_ASSERT(band != NULL);
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
values[x][y] = (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1);
rt_band_set_pixel(band, x, y, values[x][y], NULL);
}
}
gdds = rt_raster_to_gdal_mem(raster, NULL, NULL, NULL, 0, &gddrv, &destroy);
CU_ASSERT(gddrv != NULL);
CU_ASSERT_EQUAL(destroy, 0);
CU_ASSERT(gdds != NULL);
CU_ASSERT_EQUAL(GDALGetRasterXSize(gdds), width);
CU_ASSERT_EQUAL(GDALGetRasterYSize(gdds), height);
rast = rt_raster_from_gdal_dataset(gdds);
CU_ASSERT(rast != NULL);
CU_ASSERT_EQUAL(rt_raster_get_num_bands(rast), 1);
band = rt_raster_get_band(rast, 0);
CU_ASSERT(band != NULL);
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
rtn = rt_band_get_pixel(band, x, y, &value, NULL);
CU_ASSERT_EQUAL(rtn, ES_NONE);
CU_ASSERT_DOUBLE_EQUAL(value, values[x][y], DBL_EPSILON);
}
}
GDALClose(gdds);
gdds = NULL;
gddrv = NULL;
cu_free_raster(rast);
cu_free_raster(raster);
raster = rt_raster_new(width, height);
CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
pixtype = PT_8BSI;
band = cu_add_band(raster, pixtype, 1, 0);
CU_ASSERT(band != NULL);
v = -127;
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
values[x][y] = v++;
rt_band_set_pixel(band, x, y, values[x][y], NULL);
if (v == 128)
v = -127;
}
}
gdds = rt_raster_to_gdal_mem(raster, NULL, NULL, NULL, 0, &gddrv, &destroy);
CU_ASSERT(gddrv != NULL);
CU_ASSERT_EQUAL(destroy, 0);
CU_ASSERT(gdds != NULL);
CU_ASSERT_EQUAL(GDALGetRasterXSize(gdds), width);
CU_ASSERT_EQUAL(GDALGetRasterYSize(gdds), height);
rast = rt_raster_from_gdal_dataset(gdds);
CU_ASSERT(rast != NULL);
CU_ASSERT_EQUAL(rt_raster_get_num_bands(rast), 1);
band = rt_raster_get_band(rast, 0);
CU_ASSERT(band != NULL);
CU_ASSERT_EQUAL(rt_band_get_pixtype(band), PT_16BSI);
for (x = 0; x < width; x++) {
for (y = 0; y < height; y++) {
rtn = rt_band_get_pixel(band, x, y, &value, NULL);
CU_ASSERT_EQUAL(rtn, ES_NONE);
CU_ASSERT_DOUBLE_EQUAL(value, values[x][y], 1.);
}
}
//.........这里部分代码省略.........
开发者ID:NianYue,项目名称:pipelinedb,代码行数:101,代码来源:cu_gdal.c
示例17: test_lexer
void test_lexer(void)
{
strcpy(in_line, "14.5");
line_len = 4;
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(14.5, get_current_number());
clear_line();
strcpy(in_line, "(3+(4-1))*5");
line_len = 11;
CU_ASSERT_TRUE(accept(PARSE_LPAREN));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(3, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_ADD));
CU_ASSERT_TRUE(accept(PARSE_LPAREN));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(4, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_SUB));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(1, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_RPAREN));
CU_ASSERT_TRUE(accept(PARSE_RPAREN));
CU_ASSERT_TRUE(accept(PARSE_MULT));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(5, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_NLINE));
clear_line();
strcpy(in_line, "2 * x + 0.5 = 1");
line_len = 15;
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(2, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_MULT));
CU_ASSERT_TRUE(accept(PARSE_X));
CU_ASSERT_TRUE(accept(PARSE_ADD));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(0.5, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_EQUAL));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(1, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_NLINE));
clear_line();
strcpy(in_line, "2x + 1 = 2(1-x)");
line_len = 15;
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(2, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_MULT));
CU_ASSERT_TRUE(accept(PARSE_X));
CU_ASSERT_TRUE(accept(PARSE_ADD));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(1, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_EQUAL));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(2, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_MULT));
CU_ASSERT_TRUE(accept(PARSE_LPAREN));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(1, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_SUB));
CU_ASSERT_TRUE(accept(PARSE_X));
CU_ASSERT_TRUE(accept(PARSE_RPAREN));
CU_ASSERT_TRUE(accept(PARSE_NLINE));
clear_line();
strcpy(in_line, "8a - 4b = 3");
line_len = 11;
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(8, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_BAD));
CU_ASSERT_TRUE(accept(PARSE_SUB));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(4, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_BAD));
CU_ASSERT_TRUE(accept(PARSE_EQUAL));
CU_ASSERT_TRUE(accept(PARSE_NUMBER));
CU_ASSERT_EQUAL(3, get_current_number());
CU_ASSERT_TRUE(accept(PARSE_NLINE));
clear_line();
}
开发者ID:nikola-jelic,项目名称:calculator,代码行数:80,代码来源:suite.c
示例18: test_writesame16_unmap
void
test_writesame16_unmap(void)
{
int i, ret;
unsigned int j;
unsigned char *buf;
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
CHECK_FOR_LBPWS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
buf = malloc(65536 * block_size);
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
ret = write16(iscsic, tgt_lun, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
ret = writesame16(iscsic, tgt_lun, 0,
block_size, i,
0, 1, 0, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
goto finished;
}
CU_ASSERT_EQUAL(ret, 0);
if (rc16->lbprz) {
logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
"blocks back and verify they are all zero");
logging(LOG_VERBOSE, "Read %d blocks and verify they "
"are now zero", i);
ret = read16(iscsic, tgt_lun, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
for (j = 0; j < block_size * i; j++) {
if (buf[j] != 0) {
CU_ASSERT_EQUAL(buf[j], 0);
}
}
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
}
}
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff,
|
请发表评论