~ubuntu-branches/ubuntu/trusty/wvstreams/trusty

« back to all changes in this revision

Viewing changes to uniconf/t/uniconfroot.t.cc

  • Committer: Bazaar Package Importer
  • Author(s): Peter Eisentraut
  • Date: 2008-04-05 14:47:52 UTC
  • mfrom: (0.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080405144752-gka8v86xuo52fmto
Tags: 4.4.1-0.2
* Non-maintainer upload.
* Fixed dependency information LSB header in init.d script
  (closes: #470067)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "wvtest.h"
2
2
#include "uniconfroot.h"
 
3
#include "wvstream.h"
3
4
 
4
5
WVTEST_MAIN("no generator")
5
6
{
141
142
    cfg.xsetint("hello", 1);
142
143
    cfg.xsetint("hello/world", 2);
143
144
 
144
 
    WVPASSEQ(cfg["hello"].fullkey().cstr(), "cfg/hello");
145
 
    WVPASSEQ(cfg["hello/world"].fullkey(cfg).cstr(), "hello/world");
146
 
    WVPASSEQ(cfg["hello/world"].fullkey("cfg").cstr(), "hello/world");
147
 
    WVPASSEQ(cfg["hello/world"].fullkey("cfg/").cstr(), "hello/world");
 
145
    WVPASSEQ(cfg["hello"].fullkey().printable(), "cfg/hello");
 
146
    WVPASSEQ(cfg["hello/world"].fullkey(cfg).printable(), "hello/world");
 
147
    WVPASSEQ(cfg["hello/world"].fullkey("cfg").printable(), "hello/world");
 
148
    WVPASSEQ(cfg["hello/world"].fullkey("cfg/").printable(), "hello/world");
148
149
}
149
150
 
150
151
static int itcount(const UniConf &cfg)
164
165
    
165
166
    UniConf::RecursiveIter i(cfg);
166
167
    for (i.rewind(); i.next(); )
167
 
    {
168
 
        fprintf(stderr, "key: '%s'\n", i->fullkey(cfg).cstr());
169
168
        count++;
170
 
    }
171
169
    return count;
172
170
}
173
171
 
205
203
// bug 6869
206
204
static int compare(const UniConf &_a, const UniConf &_b)
207
205
{
208
 
    return strcmp(_a.key().cstr(), _b.key().cstr());
 
206
    return _a.key().compareto(_b.key());
209
207
}
210
208
WVTEST_MAIN("sorted iterators")
211
209
{
216
214
    root["4"].setme("foo4");
217
215
 
218
216
    UniConf sub(root);
 
217
    UniConf::Iter j(sub);
 
218
    for (j.rewind(); j.next(); )
 
219
        wverr->print("fullkey=%s\n", j->fullkey());
 
220
 
219
221
    UniConf::SortedIter i(sub, &compare);
220
222
    i.rewind();
221
223
    i.next();
308
310
    UniConf::RecursiveIter i(root);
309
311
    i.rewind(); 
310
312
    WVPASS(i.next());
311
 
    WVPASS(strcmp(i().key().cstr(), "subt") == 0);
312
 
    WVPASS(strcmp(i().getme().cstr(), "") == 0);
 
313
    WVPASSEQ(i().key().printable().cstr(), "subt");
 
314
    WVPASSEQ(i().getme(), "");
313
315
    WVPASS(i.next());
314
 
    WVPASS(strcmp(i().key().cstr(), "mayo") == 0);
315
 
    WVPASS(strcmp(i().getme().cstr(), "baz") == 0);
 
316
    WVPASSEQ(i().key().printable().cstr(), "mayo");
 
317
    WVPASSEQ(i().getme(), "baz");
316
318
    WVFAIL(i.next());
317
319
 
318
320
    // verify that non-recursive iteration doesn't go over keys
320
322
    UniConf::Iter j(root);
321
323
    j.rewind(); 
322
324
    WVPASS(j.next());
323
 
    WVPASS(strcmp(j().key().cstr(), "subt") == 0);
324
 
    WVPASS(strcmp(j().getme().cstr(), "") == 0);
 
325
    WVPASSEQ(j().key().printable().cstr(), "subt");
 
326
    WVPASSEQ(j().getme(), "");
325
327
    WVFAIL(j.next());
326
328
}
327
329