mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-02 05:30:23 +02:00
Enhancement - Att object
- Improved new Att object. - Added new constructor to accommodate integer attribute values. - Implemented unit tests.
This commit is contained in:
parent
6600f9bac4
commit
c860d58641
7 changed files with 205 additions and 47 deletions
126
src/tests/att.t.cpp
Normal file
126
src/tests/att.t.cpp
Normal file
|
@ -0,0 +1,126 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// 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 <Att.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (31);
|
||||
|
||||
Att a1 ("name", "value");
|
||||
t.is (a1.name (), "name", "Att::Att (name, value), Att.name");
|
||||
t.is (a1.value (), "value", "Att::Att (name, value), Att.value");
|
||||
|
||||
Att a2;
|
||||
a2.name ("name");
|
||||
a2.value ("value");
|
||||
t.is (a2.name (), "name", "Att::Att (), Att.name");
|
||||
t.is (a2.value (), "value", "Att::Att (), Att.value");
|
||||
|
||||
Att a3 (a2);
|
||||
t.is (a3.name (), "name", "Att::Att (Att), Att.name");
|
||||
t.is (a3.value (), "value", "Att::Att (Att), Att.value");
|
||||
|
||||
Att a4;
|
||||
a4 = a2;
|
||||
t.is (a4.name (), "name", "Att::Att (), Att.operator=, Att.name");
|
||||
t.is (a4.value (), "value", "Att::Att (), Att.operator=, Att.value");
|
||||
|
||||
Att a5 ("name", "value");
|
||||
t.is (a5.composeF4 (), "name:\"value\"", "Att::composeF4 simple");
|
||||
a5.value ("\"");
|
||||
t.is (a5.composeF4 (), "name:\""\"", "Att::composeF4 encoded \"");
|
||||
a5.value ("\t\",[]:");
|
||||
t.is (a5.composeF4 (), "name:\"&tab;",&open;&close;:\"", "Att::composeF4 fully encoded \\t\",[]:");
|
||||
|
||||
Att a6 ("name", 6);
|
||||
t.is (a6.value_int (), 6, "Att::value_int get");
|
||||
a6.value_int (7);
|
||||
t.is (a6.value_int (), 7, "Att::value_int set/get");
|
||||
t.is (a6.value (), "7", "Att::value 7");
|
||||
|
||||
// TODO Att::addMod
|
||||
|
||||
// Att::parse
|
||||
Att a7;
|
||||
a7.parse ("");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 ()");
|
||||
|
||||
a7.parse ("name:value");
|
||||
t.is (a7.composeF4 (), "name:\"value\"", "Att::composeF4 (name:value)");
|
||||
|
||||
a7.parse ("name:\"value\"");
|
||||
t.is (a7.composeF4 (), "name:\"value\"", "Att::composeF4 (name:\"value\")");
|
||||
|
||||
a7.parse ("name:\"one two\"");
|
||||
t.is (a7.composeF4 (), "name:\"one two\"", "Att::composeF4 (name:\"one two\")");
|
||||
|
||||
a7.parse ("name:\""\"");
|
||||
t.is (a7.composeF4 (), "name:\""\"", "Att::composeF4 (name:\""\")");
|
||||
|
||||
a7.parse ("name:\"&tab;",&open;&close;:\"");
|
||||
t.is (a7.composeF4 (), "name:\"&tab;",&open;&close;:\"",
|
||||
"Att::composeF4 (name:\"&tab;",&open;&close;:\")");
|
||||
|
||||
a7.parse ("total gibberish");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (total gibberish)");
|
||||
|
||||
a7.parse ("malformed");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (malformed)");
|
||||
|
||||
a7.parse (":malformed");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (:malformed)");
|
||||
|
||||
a7.parse (":\"\"");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (:\"\")");
|
||||
|
||||
a7.parse (":\"");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (:\")");
|
||||
|
||||
a7.parse ("name:");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (name:)");
|
||||
|
||||
a7.parse ("name:\"value");
|
||||
t.is (a7.composeF4 (), "name:\"value\"", "Att::composeF4 (name:\"value)");
|
||||
|
||||
a7.parse ("name:value\"");
|
||||
t.is (a7.composeF4 (), "name:\"value\"", "Att::composeF4 (name:value\")");
|
||||
|
||||
a7.parse ("name:val\"ue");
|
||||
t.is (a7.composeF4 (), "name:\"value\"", "Att::composeF4 (name:val\"ue)");
|
||||
|
||||
a7.parse ("name:\"\"va\"\"\"\"\"lu\"\"\"e\"\"");
|
||||
t.is (a7.composeF4 (), "name:\"value\"", "Att::composeF4 (name:\"\"va\"\"\"\"\"lu\"\"\"e\"\")");
|
||||
|
||||
a7.parse ("name\"");
|
||||
t.is (a7.composeF4 (), "", "Att::composeF4 (name\")");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue