⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_subsplit_paren_match.cxx

📁 mgcp协议源代码。支持多种编码:g711
💻 CXX
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const test_subsplit_paren_match_cxx_Version =    "$Id: test_subsplit_paren_match.cxx,v 1.6 2000/12/18 23:42:38 bko Exp $";/// test the subsplit code for parentheses matching#include "global.h"#include <iostream>#include <deque>#include <string>#include "substring.h"#include "support.hxx"const int NUM_TESTCASES = 6;int main(void){    bool pass[NUM_TESTCASES];    int i;    for (i = 0; i < NUM_TESTCASES; i++)    {        pass[i] = false;    }    string test_1("this,is,a,test,that,may,work");    string test_2("this");    string test_3("this(is,a,test,that),is(a),a(long,long(long,long(long,long(long,long)))),test()");    string test_4("hd(E(R([0-9#T](D),hu(N)),S(dl)))");    string test_5("hd(E(R([0-9#T](D),hu(N)),S(dl),D([0-9].[#T])))");    string test_6("R([0-9#T](D),hu(N)),S(dl),D([0-9].[#T])");    string test_7("hd(R([0-9#T](D),hu(N)),S(dl),D([0-9].[#T]))");    deque < substring > test_1_vector;    deque < substring > test_2_vector;    deque < substring > vector_3;    deque < substring > vector_4;    deque < substring > vector_5;    deque < substring > vector_6;    deque < substring > vector_7;    test_1_vector = sub_split_paren_match(test_1, ",");    test_2_vector = sub_split_paren_match(test_2, ",");    vector_3 = sub_split_paren_match(test_3, ",");    vector_4 = sub_split_paren_match(test_4, ",");    vector_5 = sub_split_paren_match(test_5, ",");    vector_6 = sub_split_paren_match(test_6, ",");    vector_7 = sub_split_paren_match(test_7, ",");    if (test_1_vector.size() != 7)    {        for (i = 0; i < test_1_vector.size(); i++)        {            cerr << ":" << test_1_vector[i].str() << ":" << endl;        }    }    else    {        if (            !(test_1_vector[0] == "this")            || !(test_1_vector[1] == "is")            || !(test_1_vector[2] == "a")            || !(test_1_vector[3] == "test")            || !(test_1_vector[4] == "that")            || !(test_1_vector[5] == "may")            || !(test_1_vector[6] == "work")        )        {            for (i = 0; i < test_1_vector.size(); i++)            {                cerr << ":" << test_1_vector[i].str() << ":" << endl;            }        }        else        {            pass[0] = true;        }    }    if ((test_2_vector.size() == 1) && (test_2_vector[0] == "this"))    {        pass[1] = true;    }    //    string test_3("this(is,a,test,that),is(a),a(long,long(long,long(long,long(long,long)))),test()");    if (        !(vector_3[0] == "this(is,a,test,that)") ||        !(vector_3[1] == "is(a)") ||        !(vector_3[2] == "a(long,long(long,long(long,long(long,long))))") ||        !(vector_3[3] == "test()")    )    {        for (i = 0; i < vector_3.size(); i++)        {            cerr << ":" << vector_3[i].str() << ":" << endl;        }    }    else    {        pass[2] = true;    }    if (        !(vector_4[0] == "hd(E(R([0-9#T](D),hu(N)),S(dl)))")    )    {        for (i = 0; i < vector_4.size(); i++)        {            cerr << ":" << vector_4[i].str() << ":" << endl;        }    }    else    {        pass[3] = true;    }    if (        !(vector_5[0] == "hd(E(R([0-9#T](D),hu(N)),S(dl),D([0-9].[#T])))")    )    {        for (i = 0; i < vector_5.size(); i++)        {            cerr << ":" << vector_5[i].str() << ":" << endl;        }    }    else    {        pass[4] = true;    }    if (        !(vector_6[0] == "R([0-9#T](D),hu(N))") ||        !(vector_6[1] == "S(dl)") ||        !(vector_6[2] == "D([0-9].[#T])")    )    {        for (i = 0; i < vector_6.size(); i++)        {            cerr << ":" << vector_6[i].str() << ":" << endl;        }    }    else    {        pass[5] = true;    }#if 0    if (        !(vector_7[0] == "R([0-9#T](D),hu(N))") ||        !(vector_7[1] == "S(dl)") ||        !(vector_7[2] == "D([0-9].[#T])")    )    {        for (i = 0; i < vector_7.size(); i++)        {            cerr << ":" << vector_7[i].str() << ":" << endl;        }    }    else    {        pass[6] = true;    }#endif    bool pass_all = true;    for (i = 0; i < NUM_TESTCASES; i++)    {        if (pass[i])        {            cout << "passed " << i << "\n";        }        else        {            cout << "failed " << i << "\n";            pass_all = false;        }    }    if (pass_all)        exit(0);    else        exit( -1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -