code: def _roundtrip(content, format_, astype, ana=None):
      with TempStorage("roundtrip") as st:
          codec = default_codec()
          seg = codec.new_segment(st, "")
          ana = ana or analysis.StandardAnalyzer()
          field = fields.FieldType(format=format_, analyzer=ana)
  
          fw = codec.field_writer(st, seg)
          fw.start_field("f1", field)
          for text, _, weight, valuestring in sorted(
              field.index(content)
          ):
              fw.start_term(text)
              fw.add(0, weight, valuestring, None)
              fw.finish_term()
          fw.finish_field()
          fw.close()
  
          tr = codec.terms_reader(st, seg)
          ps = []
          for fieldname, btext in tr.terms():
              m = tr.matcher(fieldname, btext, format_)
              ps.append((field.from_bytes(btext), m.value_as(astype)))
          tr.close()
          return ps
  
file_path: whoosh/tests/test_postings.py
imports: from __future__ import with_statement
  from whoosh import analysis, fields
  from whoosh.compat import u
  from whoosh.codec import default_codec
  from whoosh.formats import Existence, Frequency
  from whoosh.formats import Positions, PositionBoosts
  from whoosh.formats import Characters, CharacterBoosts
  from whoosh.util.testing import TempStorage
label_desc: Use image node_id 1 for calling a global function with example usage: _roundtrip(content, format_, astype, ana) and returns: ps