1// Copyright 2015 Jean Niklas L'orange.  All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package edn
6
7import (
8	"bytes"
9	"testing"
10)
11
12func TestPPrint(t *testing.T) {
13	inputs := map[string]string{
14		"{}":          "{}",
15		"[]":          "[]",
16		"{:a 42}":     "{:a 42}",
17		"{:a 1 :b 2}": "{:a 1,\n :b 2}",
18	}
19
20	for input, expected := range inputs {
21		buff := bytes.NewBuffer(nil)
22		if err := PPrint(buff, []byte(input), &PPrintOpts{}); err != nil {
23			t.Errorf(`PPrint(%q) failed, but expected success: %v`, input, err)
24		}
25
26		output := string(buff.Bytes())
27		if output != expected {
28			t.Errorf(`Expected PPrint(%q) to be %q; was %q`, input, expected, output)
29		}
30	}
31}
32