Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Added a test for string pattern format
Demonstrates all the format features of String::patternFormat() (and therefore String::operator %()).
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* The Doomsday Engine Project | ||
* | ||
* Copyright (c) 2009-2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <de/TextApp> | ||
#include <de/math.h> | ||
#include <QDebug> | ||
|
||
using namespace de; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
try | ||
{ | ||
TextApp app(argc, argv); | ||
app.initSubsystems(App::DisablePlugins); | ||
|
||
LOG_MSG("Escaped %%: arg %i") << 1; | ||
LOG_MSG("Escaped %%: arg %%%i%%") << 1; | ||
//LOG_MSG("Error: %") << 1; // incomplete formatting | ||
//LOG_MSG("Error: %i %i") << 1; // ran out of arguments | ||
|
||
LOG_MSG("String: '%s'") << "Hello World"; | ||
LOG_MSG(" Min width 8: '%8s'") << "Hello World"; | ||
LOG_MSG(" Max width .8: '%.8s'") << "Hello World"; | ||
LOG_MSG(" Left align: '%-.8s'") << "Hello World"; | ||
LOG_MSG("String: '%s'") << "Hello"; | ||
LOG_MSG(" Min width 8: '%8s'") << "Hello"; | ||
LOG_MSG(" Max width .8: '%.8s'") << "Hello"; | ||
LOG_MSG(" Left align: '%-8s'") << "Hello"; | ||
|
||
LOG_MSG("Integer (64-bit signed): %i") << 0x1000000000; | ||
LOG_MSG("Integer (64-bit signed): %d") << 0x1000000000; | ||
LOG_MSG("Integer (64-bit unsigned): %u") << 0x123456789abc; | ||
LOG_MSG("Boolean: %b %b") << true << false; | ||
LOG_MSG("16-bit Unicode character: %c") << 0x44; | ||
LOG_MSG("Hexadecimal (64-bit): %x") << 0x123456789abc; | ||
LOG_MSG("Hexadecimal (64-bit): %X") << 0x123456789abc; | ||
LOG_MSG("Pointer: %p") << &app; | ||
LOG_MSG("Double precision floating point: %f") << PI; | ||
LOG_MSG("Decimal places .4: %.4f") << PI; | ||
LOG_MSG("Decimal places .10: %.10f") << PI; | ||
} | ||
catch(Error const &err) | ||
{ | ||
qWarning() << err.asText() << "\n"; | ||
} | ||
|
||
qDebug() << "Exiting main()...\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include(../config_test.pri) | ||
|
||
TEMPLATE = app | ||
TARGET = test_string | ||
|
||
SOURCES += main.cpp | ||
|
||
deployTest($$TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ deng_tests: SUBDIRS += \ | |
log \ | ||
record \ | ||
script \ | ||
string \ | ||
stringpool \ | ||
vectors | ||
#basiclink |