📄 string_test.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: string_test.cpp,v 1.8.42.3 2004/07/09 01:45:55 hubbe Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */#include "./string_test.h"#include "hx_ut_debug.h"#include "ut_param_util.h"#include "./param_util.h"HLXStringTest::HLXStringTest() : m_pA(0), m_pB(0), m_ANthFieldState(0), m_BNthFieldState(0), m_pABuffer(0), m_pBBuffer(0){}HLXStringTest::~HLXStringTest(){ delete m_pA; delete m_pB;}const char* HLXStringTest::DefaultCommandLine() const{ return "tstring tstring.in";} void HLXStringTest::GetCommandInfo(UTVector<HLXUnitTestCmdInfo*>& cmds){ cmds.Resize(65); int i = 0; HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString()", &HLXStringTest::HandleConstruct1Cmd, 2); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString(CHXString)", &HLXStringTest::HandleConstruct2Cmd, 3); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString(char,int)", &HLXStringTest::HandleConstruct3Cmd, 4); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString(char*)", &HLXStringTest::HandleConstruct4Cmd, 3); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString(char*,int)", &HLXStringTest::HandleConstruct5Cmd, 4); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString(uchar*)", &HLXStringTest::HandleConstruct6Cmd, 3); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "GetLength", &HLXStringTest::HandleGetLengthCmd, 3); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "IsEmpty", &HLXStringTest::HandleIsEmptyCmd, 3); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "Empty", &HLXStringTest::HandleEmptyCmd, 2); HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "(char*)", &HLXStringTest::HandleCharStarOpCmd, 3,999); // (char*) A|B <expected> [... <alternate returns>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "GetAt", &HLXStringTest::HandleGetAtCmd, 4); // GetAt A|B <index> <expected char return> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "SetAt", &HLXStringTest::HandleSetAtCmd, 4); // SetAt A|B <index> <char> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "[]", &HLXStringTest::HandleSubscriptCmd, 4); // [] A|B <index> <expected char return> // XXXSAB: don't forget to verify that return value ref is same as A|B // on all these assignment ops. HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "=CHXString", &HLXStringTest::HandleAssignOp1Cmd, 3); // =CHXString A|B <from string: A|B> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "=char", &HLXStringTest::HandleAssignOp2Cmd, 3); // =char A|B <from char> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "=char*", &HLXStringTest::HandleAssignOp3Cmd, 3); // =char* A|B <from string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "=uchar*", &HLXStringTest::HandleAssignOp4Cmd, 3); // =uchar* A|B <from string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "+=CHXString", &HLXStringTest::HandleAppendTo1Cmd, 3); // +=CHXString A|B <from string: A|B> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "+=char", &HLXStringTest::HandleAppendTo2Cmd, 3); // +=char A|B <from char> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "+=char*", &HLXStringTest::HandleAppendTo3Cmd, 3); // +=char* A|B <from string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString+CHXString", &HLXStringTest::HandleAdd1Cmd, 4); // CHXString+CHXString A|B A|B <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString+char", &HLXStringTest::HandleAdd2Cmd, 4); // CHXString+char A|B <char> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "char+CHXString", &HLXStringTest::HandleAdd3Cmd, 4); // char+CHXString <char> A|B <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CHXString+char*", &HLXStringTest::HandleAdd4Cmd, 4); // CHXString+char* A|B <string> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "char*+CHXString", &HLXStringTest::HandleAdd5Cmd, 4); // char*+CHXString <string> A|B <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "Center", &HLXStringTest::HandleCenterCmd, 3); // Center A|B <length> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "Compare", &HLXStringTest::HandleCompareCmd, 4); // Compare A|B <string> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CompareNoCase", &HLXStringTest::HandleCompareNoCaseCmd, 4); // CompareNoCase A|B <string> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "Mid", &HLXStringTest::HandleMidCmd, 4, 5); // Mid A|B <index> [<length>] <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "Left", &HLXStringTest::HandleLeftCmd, 4); // Left A|B <length> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "Right", &HLXStringTest::HandleRightCmd, 4); // Right A|B <length> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "CountFields", &HLXStringTest::HandleCountFieldsCmd, 4); // CountFields A|B <delimeter char> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "NthField", &HLXStringTest::HandleNthFieldCmd, 5); // NthField A|B <delimeter char> <field index> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "GetNthField", &HLXStringTest::HandleGetNthFieldCmd, 5); // GetNthField A|B <delimeter char> <field index> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "ResetNthFieldState", &HLXStringTest::HandleResetNthFieldStateCmd, 2); // ResetNthFieldState A|B HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "SpanIncluding", &HLXStringTest::HandleSpanIncludingCmd, 4); // SpanIncluding A|B <string> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "SpanExcluding", &HLXStringTest::HandleSpanExcludingCmd, 4); // SpanExcluding A|B <string> <expected string> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "MakeUpper", &HLXStringTest::HandleMakeUpperCmd, 2); // MakeUpper A|B HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "MakeLower", &HLXStringTest::HandleMakeLowerCmd, 2); // MakeLower A|B HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "TrimRight", &HLXStringTest::HandleTrimRightCmd, 2); // TrimRight A|B HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "TrimLeft", &HLXStringTest::HandleTrimLeftCmd, 2); // TrimLeft A|B HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FindChar", &HLXStringTest::HandleFind1Cmd, 4); // FindChar A|B <char> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FindChar*", &HLXStringTest::HandleFind2Cmd, 4); // FindChar* A|B <string> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "ReverseFind", &HLXStringTest::HandleReverseFindCmd, 4); // ReverseFind A|B <char> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FindAndReplace", &HLXStringTest::HandleFindAndReplaceCmd, 6); // FindAndReplace A|B <search string> <repl string> <repl all bool> <expected value> HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatInt", &HLXStringTest::HandleFormatIntCmd, 4,13); // FormatInt A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatLong", &HLXStringTest::HandleFormatLongCmd, 4,13); // FormatLong A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatUInt", &HLXStringTest::HandleFormatUIntCmd, 4,13); // FormatUInt A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatULong", &HLXStringTest::HandleFormatULongCmd, 4,13); // FormatULong A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatChar", &HLXStringTest::HandleFormatCharCmd, 4,13); // FormatChar A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatCharStar", &HLXStringTest::HandleFormatCharStarCmd, 4,13); // FormatChar* A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatPtr", &HLXStringTest::HandleFormatPtrCmd, 4,13); // FormatPtr A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatDouble", &HLXStringTest::HandleFormatDoubleCmd, 4,13); // FormatDouble A|B <format string> <data1> [... <data10>] HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this, "FormatMixed", &HLXStringTest::HandleFormatMixedCmd, 1); // FormatMixed HX_ASSERT(i < cmds.Nelements()); cmds[i++] = new HLXUnitTestCmdInfoDisp<HLXStringTest>( this,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -