summaryrefslogtreecommitdiff
path: root/spew/format_test.go
diff options
context:
space:
mode:
authorDave Collins <[email protected]>2013-11-14 19:11:52 -0800
committerDave Collins <[email protected]>2013-11-14 19:11:52 -0800
commitf13f098c7a759ac1c79318d6aee18426939db828 (patch)
tree88f873e88a3782c3f821c3f502611025c5bb7ba4 /spew/format_test.go
parent1fe9f5ca4b46a8247ae5939097f5cfc5d8370729 (diff)
parent8e1b34364faac53e7da8801da5baf0c0df120a42 (diff)
Merge pull request #13 from pmezard/add-option-to-sort-map-keys
config: add SortKeys option to sort native map keys before display
Diffstat (limited to 'spew/format_test.go')
-rw-r--r--spew/format_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/spew/format_test.go b/spew/format_test.go
index b151513..80c5ef9 100644
--- a/spew/format_test.go
+++ b/spew/format_test.go
@@ -1472,3 +1472,12 @@ func TestFormatter(t *testing.T) {
}
}
}
+
+func TestPrintSortedKeys(t *testing.T) {
+ cfg := spew.ConfigState{SortKeys: true}
+ s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"})
+ expected := "map[1:1 2:2 3:3]"
+ if s != expected {
+ t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
+ }
+}