diff options
author | Robert Griesemer <gri@golang.org> | 2008-09-09 18:13:08 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2008-09-09 18:13:08 -0700 |
commit | 5a0ea48bf2c6d08d823eac7f9e9ae97961fd365a (patch) | |
tree | 2fbb1fde592c3586ad9aa47a93199cb87a65fb0f /test/sorting.go | |
parent | 90d23cd83ee59d537f580fe3d149f37254399843 (diff) | |
download | golang-5a0ea48bf2c6d08d823eac7f9e9ae97961fd365a.tar.gz |
- added convenience wrappers for sort
(work now with Ken's latest compiler fix)
- exoanded test cases accordingly
- fixed a type in the spec (thx r)
R=r
DELTA=65 (62 added, 2 deleted, 1 changed)
OCL=15050
CL=15050
Diffstat (limited to 'test/sorting.go')
-rw-r--r-- | test/sorting.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/sorting.go b/test/sorting.go index f55e9fddd..ae9dafb75 100644 --- a/test/sorting.go +++ b/test/sorting.go @@ -59,4 +59,54 @@ func main() { panic(); } } + + // Same tests again, this time using the convenience wrappers + + { data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586}; + + Sort.SortInts(&data); + + /* + for i := 0; i < len(data); i++ { + print(data[i], " "); + } + print("\n"); + */ + + if !Sort.IntsAreSorted(&data) { + panic(); + } + } + + { data := []float{74.3, 59.0, 238.2, -784.0, 2.3, 9845.768, -959.7485, 905, 7.8, 7.8}; + + Sort.SortFloats(&data); + + /* + for i := 0; i < len(data); i++ { + print(data[i], " "); + } + print("\n"); + */ + + if !Sort.FloatsAreSorted(&data) { + panic(); + } + } + + { data := []string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "***"}; + + Sort.SortStrings(&data); + + /* + for i := 0; i < len(data); i++ { + print(data[i], " "); + } + print("\n"); + */ + + if !Sort.StringsAreSorted(&data) { + panic(); + } + } } |