当前位置: 首页>>代码示例>>C++>>正文


C++ Member::SetiButtonAddr方法代码示例

本文整理汇总了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");
    }
//.........这里部分代码省略.........
开发者ID:azend,项目名称:DSAD-OOP-Assignment-2,代码行数:101,代码来源:testMember.cpp


注:本文中的Member::SetiButtonAddr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。