diff --git a/testsuite/.cvsignore b/testsuite/.cvsignore
index 5e269efb6967b2adc92751230153db83ff576d00..0d066cd7e60235a3345cd2059efbc04f171d1f7c 100644
--- a/testsuite/.cvsignore
+++ b/testsuite/.cvsignore
@@ -18,6 +18,7 @@ md5-test
 rsa-keygen-test
 rsa-test
 serpent-test
+sexp-test
 sha1-test
 sha256-test
 twofish-test
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index b20bae51ac36673db8cb638e8e9888587abe6d0a..6a3f61baf282037782970ca319dfde63a27e2936 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -18,6 +18,7 @@
 /rsa-keygen-test
 /rsa-test
 /serpent-test
+/sexp-test
 /sha1-test
 /sha256-test
 /twofish-test
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index af607e3e9c7ee7980dc036744591b241b713d697..cf111469ebb6bc2c30953fef5594530d9d34ee10 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -6,6 +6,7 @@ TS_PROGS = aes-test arcfour-test blowfish-test cast128-test \
 	   des-test des3-test des-compat-test \
 	   md5-test md5-compat-test sha1-test sha256-test \
 	   serpent-test twofish-test \
+	   sexp-test \
 	   knuth-lfib-test \
 	   cbc-test hmac-test bignum-test \
 	   rsa-test rsa-keygen-test yarrow-test
diff --git a/testsuite/sexp-test.c b/testsuite/sexp-test.c
new file mode 100644
index 0000000000000000000000000000000000000000..dc8c269341202c6cab8965e2a158855fe5f16255
--- /dev/null
+++ b/testsuite/sexp-test.c
@@ -0,0 +1,61 @@
+#include "testutils.h"
+#include "sexp.h"
+
+int
+test_main(void)
+{
+  struct sexp_iterator i;
+
+  sexp_iterator_init(&i, LDATA(""));
+  ASSERT(sexp_iterator_next(&i) && i.type == SEXP_END);
+
+  sexp_iterator_init(&i, LDATA("()"));
+  ASSERT(sexp_iterator_next(&i) && i.type == SEXP_LIST
+	 && sexp_iterator_enter_list(&i)
+	 && sexp_iterator_next(&i) && i.type == SEXP_END
+	 && sexp_iterator_exit_list(&i)
+	 && sexp_iterator_next(&i) && i.type == SEXP_END);
+
+  sexp_iterator_init(&i, LDATA("("));
+  ASSERT(sexp_iterator_next(&i) && i.type == SEXP_LIST
+	 && sexp_iterator_enter_list(&i)
+	 && !sexp_iterator_next(&i));
+
+  sexp_iterator_init(&i, LDATA("3:foo0:[3:bar]1:x"));
+  ASSERT(sexp_iterator_next(&i) && i.type == SEXP_ATOM
+	 && !i.display_length && !i.display
+	 && i.atom_length == 3 && MEMEQ(3, "foo", i.atom)
+
+	 && sexp_iterator_next(&i) && i.type == SEXP_ATOM
+	 && !i.display_length && !i.display
+	 && !i.atom_length && i.atom
+
+	 && sexp_iterator_next(&i) && i.type == SEXP_ATOM
+	 && i.display_length == 3 && MEMEQ(3, "bar", i.display)
+	 && i.atom_length == 1 && MEMEQ(1, "x", i.atom));
+
+  {
+    struct sexp_assoc_key keys[2] =
+      { { LDATA("n") }, { LDATA("e") } };
+    struct sexp_iterator v[2];
+
+    sexp_iterator_init(&i, LDATA("((1:n))"));
+    ASSERT(!sexp_iterator_assoc(&i, 2, keys, v));
+    sexp_iterator_init(&i, LDATA("((1:n)(1:n3:foo))"));
+    ASSERT(!sexp_iterator_assoc(&i, 2, keys, v));
+    
+    sexp_iterator_init(&i, LDATA("((1:n2:xx3:foo)0:(1:y)(1:e))"));
+    ASSERT(sexp_iterator_assoc(&i, 2, keys, v));
+
+    ASSERT(sexp_iterator_next(&v[0]) && v[0].type == SEXP_ATOM
+	   && !v[0].display_length && !v[0].display
+	   && v[0].atom_length == 2 && MEMEQ(2, "xx", v[0].atom)
+
+	   && sexp_iterator_next(&v[0]) && v[0].type == SEXP_ATOM
+	   && !v[0].display_length && !v[0].display
+	   && v[0].atom_length == 3 && MEMEQ(3, "foo", v[0].atom)
+
+	   && sexp_iterator_next(&v[0]) && v[0].type == SEXP_END);
+  }
+  SUCCESS();
+}