本文整理汇总了C++中Member::SetiButtonAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ Member::SetiButtonAddr方法的具体用法?C++ Member::SetiButtonAddr怎么用?C++ Member::SetiButtonAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member::SetiButtonAddr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void){
unsigned char testAddr1[IBUTTON_BYTES] = { 1, 2, 66, 78, 52, 6, 7 };
unsigned char testAddr2[8] = { 6, 6, 8, 9, 5, 8, 78, 90 };
unsigned char testAddr3[4] = { 7, 9, 7, 5 };
unsigned char * testAddr4 = NULL;
int arraySize[4] = {7, 8, 4, 0};
std::string firstName("Ian");
std::string lastName("Campbell");
std::string errorFirstName("");
std::string newFirstName;
std::string newLastName;
unsigned char newAddr[IBUTTON_BYTES] = {0};
bool testResult = false;
printf("Testing class Member:\n");
/*
Testing the default constructor
*/
printf("\tTesting default constructor... \n\n");
Member azend;
Member otherMember;
/*
Testing the mutators
*/
printf("\tTesting setters..... \n\n");
/* Normal Tests */
printf ("\tNormal Tests..... All should pass\n");
//firstname
testResult = azend.SetFirstName(firstName.c_str());
if (testResult == true){
printf ("\tResult 1 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 1 - FAIL\n");
}
//lastname
testResult = azend.SetLastName(lastName.c_str());
if (testResult == true){
printf ("\tResult 2 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 2 - FAIL\n");
}
//ibutton
testResult = azend.SetiButtonAddr(testAddr1, arraySize[0]);
if (testResult == true){
printf ("\tResult 3 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 3 - FAIL\n");
}
/* Error Tests */
printf ("\tError Tests...... All should fail.\n");
//firstname high
printf("\tThese values are too large to be valid\n");
testResult = azend.SetFirstName("01234567890123456789012345678901234");
if (testResult == true){
printf ("\tResult 1 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 1 - FAIL\n");
}
//lastname high
testResult = azend.SetLastName("holygadimtrappedinacrappyc++programgetmethehelloutofhere");
if (testResult == true){
printf ("\tResult 2 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 2 - FAIL\n");
}
//firstname zero
printf("\tThese are empty strings therefore invalid\n");
testResult = azend.SetFirstName("");
if (testResult == true){
printf ("\tResult 1 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 1 - FAIL\n");
}
//lastname zero
testResult = azend.SetLastName("");
if (testResult == true){
printf ("\tResult 2 - PASS\n");
testResult = false;
}
else {
printf ("\tResult 2 - FAIL\n");
}
//.........这里部分代码省略.........