mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-02 23:48:35 +02:00
Enhancement - Record::has
- Implemented Record::has which guarantees no autovivification of attributes.
This commit is contained in:
parent
1ff3e73ebc
commit
754b79afb2
3 changed files with 16 additions and 1 deletions
|
@ -116,6 +116,16 @@ void Record::parse (const std::string& input)
|
|||
"Record not recognized as format 4");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Record::has (const std::string& name) const
|
||||
{
|
||||
Record::const_iterator i = this->find (name);
|
||||
if (i != this->end ())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <Att> Record::all ()
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
std::string composeCSV ();
|
||||
void parse (const std::string&);
|
||||
|
||||
bool has (const std::string&) const;
|
||||
std::vector <Att> all ();
|
||||
const std::string get (const std::string&) const;
|
||||
int get_int (const std::string&) const;
|
||||
|
|
|
@ -35,7 +35,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (17);
|
||||
UnitTest t (19);
|
||||
|
||||
// (blank)
|
||||
bool good = true;
|
||||
|
@ -85,6 +85,10 @@ int main (int argc, char** argv)
|
|||
record.set ("name", "value");
|
||||
t.is (record.composeF4 (), "[name:\"value\"]\n", "Record::set");
|
||||
|
||||
// Record::has
|
||||
t.ok (record.has ("name"), "Record::has");
|
||||
t.notok (record.has ("woof"), "Record::has not");
|
||||
|
||||
// Record::get_int
|
||||
record.set ("one", 1);
|
||||
t.is (record.composeF4 (), "[name:\"value\" one:\"1\"]\n", "Record::set");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue