~ubuntu-branches/ubuntu/utopic/nettle/utopic

« back to all changes in this revision

Viewing changes to testsuite/sexp-test.c

  • Committer: Package Import Robot
  • Author(s): Magnus Holmgren
  • Date: 2013-03-24 11:38:21 UTC
  • mto: (1.4.6) (3.1.11 experimental)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20130324113821-3rsmekqi09c93lnh
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "testutils.h"
2
2
#include "sexp.h"
3
3
 
4
 
int
 
4
void
5
5
test_main(void)
6
6
{
7
7
  struct sexp_iterator i;
32
32
  ASSERT(sexp_iterator_get_uint32(&i, &x) && x == 0x11);
33
33
  ASSERT(sexp_iterator_get_uint32(&i, &x) && x == 0x80);
34
34
  ASSERT(sexp_iterator_get_uint32(&i, &x) && x == 0xaabbccdd);
35
 
  
 
35
 
36
36
  ASSERT(sexp_iterator_first(&i, LDATA("3:foo0:[3:bar]12:xxxxxxxxxxxx")));
37
37
  ASSERT(i.type == SEXP_ATOM
38
38
         && !i.display_length && !i.display
49
49
         && sexp_iterator_next(&i) && i.type == SEXP_END);
50
50
  
51
51
  /* Same data, transport encoded. */
52
 
  
53
 
  ASSERT(sexp_transport_iterator_first
54
 
         (&i, LDUP("{Mzpmb28=} {MDo=} {WzM6YmFyXTEyOnh4eHh4eHh4eHh4eA==}")));
 
52
 
 
53
  {
 
54
    struct tstring *s
 
55
      = tstring_data(LDATA("{Mzpmb28=} {MDo=} {WzM6YmFyXTEyOnh4eHh4eHh4eHh4eA==}"));
 
56
  ASSERT(sexp_transport_iterator_first (&i, s->length, s->data));
55
57
  ASSERT(i.type == SEXP_ATOM
56
58
         && !i.display_length && !i.display
57
59
         && i.atom_length == 3 && MEMEQ(3, "foo", i.atom)
65
67
         && i.atom_length == 12 && MEMEQ(12, "xxxxxxxxxxxx", i.atom)
66
68
 
67
69
         && sexp_iterator_next(&i) && i.type == SEXP_END);
68
 
  
 
70
 
 
71
  }
69
72
  {
70
73
    static const uint8_t *keys[2] = { "n", "e" };
71
74
    struct sexp_iterator v[2];
94
97
    ASSERT(sexp_iterator_enter_list(&i)
95
98
           && !sexp_iterator_assoc(&i, 2, keys, v));    
96
99
  }
97
 
 
98
 
  SUCCESS();
99
100
}