コード例 #1
0
ファイル: SimpleString.cpp プロジェクト: auser/cpputest
SimpleString VStringFromFormat(const char* format, va_list args)
{
	va_list argsCopy;
	va_copy(argsCopy, args);
	enum
	{
		sizeOfdefaultBuffer = 100
	};
	char defaultBuffer[sizeOfdefaultBuffer];
	SimpleString resultString;

	int size = PlatformSpecificVSNprintf(defaultBuffer, sizeOfdefaultBuffer,
			format, args);
	if (size < sizeOfdefaultBuffer) {
		resultString = SimpleString(defaultBuffer);
	}
	else {
		char* newBuffer = new char[size + 1];
		PlatformSpecificVSNprintf(newBuffer, size + 1, format, argsCopy);
		resultString = SimpleString(newBuffer);

		delete[] newBuffer;
	}
	return resultString;
}
コード例 #2
0
ファイル: SimpleString.cpp プロジェクト: uecasm/cpputest
SimpleString VStringFromFormat(const char* format, va_list args)
{
    va_list argsCopy;
    va_copy(argsCopy, args);
    enum
    {
        sizeOfdefaultBuffer = 100
    };
    char defaultBuffer[sizeOfdefaultBuffer];
    SimpleString resultString;

    size_t size = (size_t)PlatformSpecificVSNprintf(defaultBuffer, sizeOfdefaultBuffer, format, args);
    if (size < sizeOfdefaultBuffer) {
        resultString = SimpleString(defaultBuffer);
    }
    else {
        size_t newBufferSize = size + 1;
        char* newBuffer = SimpleString::allocStringBuffer(newBufferSize, __FILE__, __LINE__);
        PlatformSpecificVSNprintf(newBuffer, newBufferSize, format, argsCopy);
        resultString = SimpleString(newBuffer);

        SimpleString::deallocStringBuffer(newBuffer, __FILE__, __LINE__);
    }
    va_end(argsCopy);
    return resultString;
}
コード例 #3
0
ファイル: positioning_test.cpp プロジェクト: 31415us/beacons
static SimpleString StringFrom(const Vec2D & v)
{
    SimpleString s = SimpleString();
    s += SimpleString("(");
    s += StringFrom(v.get_x());
    s += SimpleString(",");
    s += StringFrom(v.get_y());
    s += SimpleString(")");

    return s;
}
コード例 #4
0
ファイル: Failure.cpp プロジェクト: ccanan/BladeMaster
Failure::Failure (const SimpleString&	theTestName, 
			 	  const SimpleString&	theFileName, 
				  long					theLineNumber,
				  const SimpleString&	expected,
				  const SimpleString&	actual) 
: testName (theTestName), 
  fileName (theFileName), 
  lineNumber (theLineNumber)
{
	TCHAR *part1 = TEXT("expected ");
	TCHAR *part3 = TEXT(" but was: ");

	//[guyu modify
	size_t buflen = _tcslen (part1) 
					+ expected.size () 
					+ _tcslen (part3)
					+ actual.size ()
					+ 1;
	TCHAR *stage = new TCHAR [buflen];

	_stprintf_s (stage, buflen, TEXT("%s%s%s%s"), 
		part1, 
		expected.asCharString(), 
		part3, 
		actual.asCharString());
	//]guyu

	message = SimpleString(stage);

	delete stage;
}
コード例 #5
0
SimpleString ConsoleInput::GetUserInput() const
{
	char Buffer[256];
	DWORD OutNum = 0;

	if( ReadConsole( m_hConsoleInput, Buffer, 256, &OutNum, NULL ) )
	{
		// The last two characters should be a CRLF, unless we Ctrl+C or Ctrl+Break out of the zinput.
		OutNum = OutNum >= 2 ? OutNum - 2 : OutNum;

		Buffer[ OutNum ] = '\0';
		return SimpleString( Buffer );
	}

	return SimpleString( "" );
}
コード例 #6
0
ファイル: Failure.cpp プロジェクト: brindza/phys-anim
Failure::Failure (const SimpleString&	theTestName, 
			 	  const SimpleString&	theFileName, 
				  long					theLineNumber,
				  const SimpleString&	expected,
				  const SimpleString&	actual) 
: testName (theTestName), 
  fileName (theFileName), 
  lineNumber (theLineNumber)
{
	char *part1 = "expected ";
	char *part3 = " but was: ";

	char *stage = new char [strlen (part1) 
					+ expected.size () 
					+ strlen (part3)
					+ actual.size ()
					+ 1];

	sprintf(stage, "%s%s%s%s", 
		part1, 
		expected.asCharString(), 
		part3, 
		actual.asCharString());

	message = SimpleString(stage);

	delete stage;
}
コード例 #7
0
TEST(SimpleString, CollectionWritingToEmptyString)
{
	SimpleStringCollection col;
	col.allocate(3);
	col[3] = SimpleString("HAH");
	STRCMP_EQUAL("", col[3].asCharString());
}
コード例 #8
0
ファイル: SimpleString.cpp プロジェクト: mpetri/OrderedSet
SimpleString StringFrom(double value)
{
    char buffer [DEFAULT_SIZE];
    sprintf(buffer, "%lf", value);

    return SimpleString(buffer);
}
コード例 #9
0
void EldritchFramework::WritePrefsConfig() {
  const SimpleString PrefsConfigFilename =
      GetSaveLoadPath() + SimpleString("prefs.cfg");
  const FileStream PrefsConfigStream =
      FileStream(PrefsConfigFilename.CStr(), FileStream::EFM_Write);

  PrefsConfigStream.PrintF(
      "# This file is automatically generated.\n# You may delete it to restore "
      "defaults.\n\n");

  ConfigManager::BeginWriting();

  ConfigManager::Write(PrefsConfigStream, "Language");
  ConfigManager::Write(PrefsConfigStream, "DisplayWidth");
  ConfigManager::Write(PrefsConfigStream, "DisplayHeight");
  ConfigManager::Write(PrefsConfigStream, "Fullscreen");
  ConfigManager::Write(PrefsConfigStream, "OpenGL");
  ConfigManager::Write(PrefsConfigStream, "Brightness");
  ConfigManager::Write(PrefsConfigStream, "FOV");
  ConfigManager::Write(PrefsConfigStream, "VSync");
  ConfigManager::Write(PrefsConfigStream, "MouseSpeed");
  ConfigManager::Write(PrefsConfigStream, "ControllerSpeed");
  ConfigManager::Write(PrefsConfigStream, "InvertY");
  ConfigManager::Write(PrefsConfigStream, "MasterVolume");
  ConfigManager::Write(PrefsConfigStream, "MusicVolume");

  m_InputSystem->WriteConfigBinds(PrefsConfigStream);
}
コード例 #10
0
ファイル: SimpleString.cpp プロジェクト: mpetri/OrderedSet
SimpleString StringFrom(long value)
{
    char buffer [DEFAULT_SIZE];
    sprintf(buffer, "%ld", value);

    return SimpleString(buffer);
}
コード例 #11
0
// Save to working directory on Windows and Linux. On Mac, save in proper
// location.
/*virtual*/ SimpleString EldritchFramework::GetSaveLoadPath() {
#if BUILD_MAC
  return ObjCJunk::GetUserDirectory();
#else
  return SimpleString("./");
#endif
}
コード例 #12
0
ファイル: main.cpp プロジェクト: MinorKeyGames/Eldritch
void SaveCommandLineArguments( int argc, char* argv[] )
{
	for( int ArgumentIndex = 0; ArgumentIndex < argc; ++ArgumentIndex )
	{
		g_CommandLineArguments.PushBack( SimpleString( argv[ ArgumentIndex ] ) );
	}
}
コード例 #13
0
ファイル: Utest.cpp プロジェクト: KisImre/cpputest
void UtestShell::assertCstrContains(const char* expected, const char* actual, const char* text, const char* fileName, int lineNumber)
{
    getTestResult()->countCheck();
    if (actual == NULLPTR && expected == NULLPTR) return;
    if (actual == NULLPTR || expected == NULLPTR)
        failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text));
    if (!SimpleString(actual).contains(expected))
        failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text));
}
コード例 #14
0
ファイル: Utest.cpp プロジェクト: KevinWMatthews/cpputest
void UtestShell::assertCstrNoCaseContains(const char* expected, const char* actual, const char* fileName, int lineNumber)
{
    getTestResult()->countCheck();
    if (actual == 0 && expected == 0) return;
    if(actual == 0 || expected == 0)
    	failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
    if (!SimpleString(actual).containsNoCase(expected))
    	failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
}
コード例 #15
0
ファイル: MockNamedValue.cpp プロジェクト: CNCBASHER/mri
bool MockNamedValue::equals(const MockNamedValue& p) const
{
	if (type_ != p.type_) return false;

	if (type_ == "int")
		return value_.intValue_ == p.value_.intValue_;
	else if (type_ == "char*")
		return SimpleString(value_.stringValue_) == SimpleString(p.value_.stringValue_);
	else if (type_ == "void*")
		return value_.pointerValue_ == p.value_.pointerValue_;
	else if (type_ == "double")
		return (doubles_equal(value_.doubleValue_, p.value_.doubleValue_, 0.005));

	if (comparator_)
		return comparator_->isEqual(value_.objectPointerValue_, p.value_.objectPointerValue_);

	return false;
}
コード例 #16
0
void EldritchFramework::LoadPrefsConfig() {
  const SimpleString PrefsConfigFilename =
      GetSaveLoadPath() + SimpleString("prefs.cfg");
  if (FileUtil::Exists(PrefsConfigFilename.CStr())) {
    const FileStream PrefsConfigStream =
        FileStream(PrefsConfigFilename.CStr(), FileStream::EFM_Read);
    ConfigManager::Load(PrefsConfigStream);
  }
}
コード例 #17
0
ファイル: Utest.cpp プロジェクト: DynonAvionics/cpputest
void UtestShell::assertCstrNoCaseEqual(const char* expected, const char* actual, const char* text, const char* fileName, int lineNumber)
{
    getTestResult()->countCheck();
    if (actual == 0 && expected == 0) return;
    if (actual == 0 || expected == 0)
        failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual, text));
    if (!SimpleString(expected).equalsNoCase(actual))
        failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual, text));
}
コード例 #18
0
SimpleString ReverseHash::ReversedHash( const HashedString& Hash )
{
	if( gReverseHashEnabled )
	{
		const Map<HashedString, SimpleString>::Iterator HashIter = gReverseHashMap.Search( Hash );
		if( HashIter.IsValid() )
		{
			return HashIter.GetValue();
		}
		else
		{
			WARN;
			return SimpleString( "(Hash)" );
		}
	}
	else
	{
		WARNDESC( "ReverseHash: Not enabled." );
		return SimpleString( "" );
	}
}
コード例 #19
0
ファイル: SimpleString.cpp プロジェクト: uecasm/cpputest
void SimpleString::padStringsToSameLength(SimpleString& str1, SimpleString& str2, char padCharacter)
{
    if (str1.size() > str2.size()) {
        padStringsToSameLength(str2, str1, padCharacter);
        return;
    }

    char pad[2];
    pad[0] = padCharacter;
    pad[1] = 0;
    str1 = SimpleString(pad, str2.size() - str1.size()) + str1;
}
コード例 #20
0
void NormalMemoryReportFormatter::report_testgroup_start(TestResult* result, UtestShell& test)
{
	const size_t line_size = 80;

	SimpleString groupName = StringFromFormat("TEST GROUP(%s)", test.getGroup().asCharString());
	size_t beginPos = (line_size/2) - (groupName.size()/2);

	SimpleString line("-", beginPos);
	line += groupName;
	line += SimpleString("-", line_size - line.size());
	line += "\n";
	result->print(line.asCharString());
}
コード例 #21
0
ファイル: SimpleString.cpp プロジェクト: uecasm/cpputest
void SimpleString::split(const SimpleString& delimiter, SimpleStringCollection& col) const
{
    size_t num = count(delimiter);
    size_t extraEndToken = (endsWith(delimiter)) ? 0 : 1U;
    col.allocate(num + extraEndToken);

    char* str = buffer_;
    char* prev;
    for (size_t i = 0; i < num; ++i) {
        prev = str;
        str = StrStr(str, delimiter.buffer_) + 1;
        col[i] = SimpleString(prev).subString(0, size_t (str - prev));
    }
    if (extraEndToken) {
        col[num] = str;
    }
}
コード例 #22
0
ファイル: main.cpp プロジェクト: Johnicholas/EldritchCopy
int main( int argc, char* argv[] )
{
	if( argc > 1 )
	{
		bool SuppressedOutput = false;
		uint8* FileContents = NULL;
		int Length = 0;

		if( argc > 2 )
		{
			if( SimpleString( "-s" ) == argv[2] )
			{
				SuppressedOutput = true;
			}
		}

		{
			FileStream ChecksumFile( argv[1], FileStream::EFM_Read );
			Length = ChecksumFile.Size();
			FileContents = new uint8[ Length ];
			ChecksumFile.Read( Length, FileContents );
		}

		if( FileContents && Length )
		{
			uint32 FileChecksum = Checksum::Adler32( FileContents, Length );
			delete FileContents;

			if( SuppressedOutput )
			{
				PRINTF( "%s\n", argv[1] );
				PRINTF( "%d\n", Length );
				PRINTF( "0x%08X\n", FileChecksum );
			}
			else
			{
				PRINTF( "Filename: %s\n", argv[1] );
				PRINTF( "Length:   %d\n", Length );
				PRINTF( "Checksum: 0x%08X\n", FileChecksum );
			}
		}
	}

	return 0;
}
コード例 #23
0
ファイル: StackMain.cpp プロジェクト: josephgreer/ultrasteer
int main(int argc, char *argv[])
{
  TestResult tr;

  if(argc == 1) {
    TestRegistry::runAllTests(tr);
  } else if(argc > 1) {
    SimpleString test(argv[1]);
    if(argc == 3) {
      test = SimpleString(strcat(argv[2], argv[1]));
    }
    TestRegistry::runSpecificTest(tr, test);
  } else {
    printUsage();
  }

  return 0;
}
コード例 #24
0
ファイル: TestFailure.cpp プロジェクト: dreadlock/cpputest
SimpleString TestFailure::createDifferenceAtPosString(const SimpleString& actual, size_t position)
{
	SimpleString result;
	const size_t extraCharactersWindow = 20;
	const size_t halfOfExtraCharactersWindow = extraCharactersWindow / 2;

	SimpleString paddingForPreventingOutOfBounds (" ", halfOfExtraCharactersWindow);
	SimpleString actualString = paddingForPreventingOutOfBounds + actual + paddingForPreventingOutOfBounds;
	SimpleString differentString = StringFromFormat("difference starts at position %lu at: <", (unsigned long) position);

	result += "\n";
	result += StringFromFormat("\t%s%s>\n", differentString.asCharString(), actualString.subString(position, extraCharactersWindow).asCharString());

	SimpleString markString = actualString.subString(position, halfOfExtraCharactersWindow+1);
	markString = removeAllPrintableCharactersFrom(markString);
	markString = addMarkerToString(markString, halfOfExtraCharactersWindow);

	result += StringFromFormat("\t%s%s", SimpleString(" ", differentString.size()).asCharString(), markString.asCharString());
	return result;
}
コード例 #25
0
SimpleString SimpleString::Replace( const char* const Find, const char* const Replace ) const
{
	DEVASSERT( Find );
	DEVASSERT( Replace );

	Array<char> NewStringBuffer;
	NewStringBuffer.Resize( m_Length + 1 );
	memcpy( NewStringBuffer.GetData(), m_String, m_Length + 1	);

	const size_t FindLength		= strlen( Find );
	const size_t ReplaceLength	= strlen( Replace );
	const size_t Difference		= ReplaceLength - FindLength;

	for( size_t Iterator = 0; Iterator < NewStringBuffer.Size(); )
	{
		const char* const		SubStr	= strstr( NewStringBuffer.GetData() + Iterator, Find );
		if( SubStr )
		{
			const char* const	Base	= NewStringBuffer.GetData();
			const size_t		Offset	= SubStr - Base;

			for( size_t DifferenceIndex = 0; DifferenceIndex < Difference; ++DifferenceIndex )
			{
				NewStringBuffer.Insert( 0, static_cast<uint>( Offset ) );
			}

			memcpy( NewStringBuffer.GetData() + Offset, Replace, ReplaceLength );

			Iterator += ReplaceLength;
		}
		else
		{
			break;
		}
	}

	return SimpleString( NewStringBuffer );
}
コード例 #26
0
bool LuaNetworkClient::Open(const char* id, const char* registryKey, 
					   lua_State* state, SockAddr* outSockAddr, DWORD serverPort)
{
	m_registryKey = SimpleString("Software\\") + registryKey;
	m_state = state;
	m_id = id;
	m_serverPort = serverPort;

	m_listenerThread = new LuaClientListenerThread(this);
	m_listenerThread->ThreadCreate();
	WaitForSingleObject( ((LuaClientListenerThread*)m_listenerThread)->m_socketCreatedEvent, INFINITE );

	SockAddr sockAddr;
	if (outSockAddr)
		sockAddr = *outSockAddr;
	else
		sockAddr = SockAddr("127.0.0.1", 0);
	m_connectSockAddr = sockAddr;

	m_autoConnectThread = new AutoConnectThread(this);
	m_autoConnectThread->ThreadCreate();
	
	return true;
}
コード例 #27
0
ファイル: main.cpp プロジェクト: MinorKeyGames/Eldritch
void SplitIntoLines( const char* Message, uint MessageLength, Array<SimpleString>& OutLines )
{
	const char* LineStart = Message;
	const char* MessageEnd = Message + MessageLength;

	while( LineStart )
	{
		const char* LineEnd = LineStart;
		while( LineEnd < MessageEnd && *LineEnd != '\n' )
		{
			++LineEnd;
		}

		if( *LineEnd == '\n' )
		{
			OutLines.PushBack( SimpleString( LineStart, ( uint )( LineEnd - LineStart ) ) );
			LineStart = LineEnd + 1;
		}
		else
		{
			LineStart = NULL;
		}
	}
}
コード例 #28
0
ファイル: SimpleString.cpp プロジェクト: uecasm/cpputest
SimpleString StringFrom(const std::string& value)
{
    return SimpleString(value.c_str());
}
コード例 #29
0
ファイル: SimpleString.cpp プロジェクト: uecasm/cpputest
SimpleString StringFrom(const SimpleString& value)
{
    return SimpleString(value);
}
コード例 #30
0
ファイル: SimpleString.cpp プロジェクト: uecasm/cpputest
SimpleString BracketsFormattedHexString(SimpleString hexString)
{
    return SimpleString("(0x") + hexString + ")" ;
}