- Added several overloaded positional string formatters.  May need
  more.
This commit is contained in:
Paul Beckingham 2011-05-26 21:56:23 -04:00
parent 5e71003558
commit 32e7af4610
5 changed files with 195 additions and 13 deletions

1
test/.gitignore vendored
View file

@ -12,6 +12,7 @@ dom.t
duration.t
file.t
filt.t
i18n.t
json.t
lisp.t
list.t

View file

@ -6,7 +6,7 @@ include_directories (${CMAKE_SOURCE_DIR}/src
${TASK_INCLUDE_DIRS})
set (test_SRCS att.t autocomplete.t color.t config.t date.t directory.t dom.t
duration.t file.t filt.t json.t list.t nibbler.t path.t
duration.t file.t filt.t i18n.t json.t list.t nibbler.t path.t
record.t rx.t seq.t subst.t t.benchmark.t t.t taskmod.t tdb.t
tdb2.t text.t uri.t util.t variant.t view.t json_test)

75
test/i18n.t.cpp Normal file
View file

@ -0,0 +1,75 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// 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, write to the
//
// Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor,
// Boston, MA
// 02110-1301
// USA
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <unistd.h>
#include <stdarg.h>
#include <Context.h>
#include <text.h>
#include <test.h>
Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (11);
try
{
t.is (format ("pre {1} post", "mid"), "pre mid post", "format 1a");
t.is (format ("pre {1}{1} post", "mid"), "pre midmid post", "format 1b");
t.is (format ("pre {1} post", 0), "pre 0 post", "format 1c");
t.is (format ("pre {1}{1} post", 0), "pre 00 post", "format 1d");
t.is (format ("pre {1}{2} post", "one", "two"), "pre onetwo post", "format 2a");
t.is (format ("pre {2}{1} post", "one", "two"), "pre twoone post", "format 2b");
t.is (format ("pre {1}{2} post", "one", 2), "pre one2 post", "format 2c");
t.is (format ("pre {1}{2} post", 1, "two"), "pre 1two post", "format 2d");
t.is (format ("pre {1}{2} post", 1, 2), "pre 12 post", "format 2e");
t.is (format ("pre {1}{2}{3} post", "one", "two", "three"), "pre onetwothree post", "format 3a");
t.is (format ("pre {3}{1}{2} post", "one", "two", "three"), "pre threeonetwo post", "format 3b");
}
catch (std::string& error)
{
t.diag (error);
return -1;
}
catch (...)
{
t.diag ("Unknown error.");
return -2;
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////