# json-serialization # Copyright (c) 2019-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) # at your option. # This file may not be copied, modified, or distributed except according to # those terms. import strutils # `dedent` exists in newer Nim version and doesn't behave the same func test_dedent*(s: string): string = var s = s.strip(leading = false) minIndent = high(int) for l in s.splitLines: let indent = count(l, ' ') if indent == 0: continue if indent < minIndent: minIndent = indent s.unindent(minIndent)