changeset 41312:d60bd5c71cbb

fuzz: exercise more of the lazymanifest code Differential Revision: https://phab.mercurial-scm.org/D5643
author Augie Fackler <raf@durin42.com>
date Tue, 22 Jan 2019 11:41:22 -0500
parents 44cd432aed9f
children d3cc9a8df63a
files contrib/fuzz/manifest.cc
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/fuzz/manifest.cc	Tue Jan 22 11:41:09 2019 -0500
+++ b/contrib/fuzz/manifest.cc	Tue Jan 22 11:41:22 2019 -0500
@@ -20,11 +20,19 @@
   lm = lazymanifest(mdata)
   # iterate the whole thing, which causes the code to fully parse
   # every line in the manifest
-  list(lm.iterentries())
+  for e, _, _ in lm.iterentries():
+      # also exercise __getitem__ et al
+      lm[e]
+      e in lm
+      (e + 'nope') in lm
   lm[b'xyzzy'] = (b'\0' * 20, 'x')
   # do an insert, text should change
   assert lm.text() != mdata, "insert should change text and didn't: %r %r" % (lm.text(), mdata)
+  cloned = lm.filtercopy(lambda x: x != 'xyzzy')
+  assert cloned.text() == mdata, 'cloned text should equal mdata'
+  cloned.diff(lm)
   del lm[b'xyzzy']
+  cloned.diff(lm)
   # should be back to the same
   assert lm.text() == mdata, "delete should have restored text but didn't: %r %r" % (lm.text(), mdata)
 except Exception as e: