package sentry

  1. Overview
  2. Docs

Source file capped_string_4k.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
open Base
open Sexplib.Conv

type t = string [@@deriving sexp_of]

let unwrap t = Util.cap_string_length ~max_len:4096 t
let wrap t = t

let%test_unit "round-trip" =
  let expect = "adsfasdfsdsd131" in
  expect |> wrap |> unwrap |> [%test_result: string] ~expect
;;

let%test_unit "long string round trip" =
  let input = String.init 5000 ~f:(Fn.const 'a') in
  let expect = String.sub ~pos:0 ~len:4096 input in
  input |> wrap |> unwrap |> [%test_result: string] ~expect
;;