func convertToRanges(sizes strmap) rngmap {
	ranges := rngmap{}
	for k, s := range sizes {
		ranges[k], _ = memory.NewRangeFromString(s)
	}
	return ranges
}
func validateSizes(sizes string) map[string]memory.Range {
	rs := map[string]memory.Range{}

	if sizes == "" {
		return rs
	}

	rangeClauses := strings.Split(sizes, ",")
	for _, clause := range rangeClauses {
		if parts := strings.Split(clause, ":"); len(parts) == 2 {
			var err error
			if rs[parts[0]], err = memory.NewRangeFromString(parts[1]); err != nil {
				fmt.Fprintf(os.Stderr, "Bad range in -%s flag, clause '%s' : %s", sizesFlag, clause, err)
				os.Exit(1)
			}
		} else {
			fmt.Fprintf(os.Stderr, "Bad clause '%s' in -%s flag", clause, sizesFlag)
			os.Exit(1)
		}
	}

	return rs
}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("MemoryRange", func() {

	Context("string constructor", func() {
		var (
			itWorks func(str string, lo memory.MemSize) memory.Range
			itFails func(str string)
		)

		BeforeEach(func() {
			itWorks = func(str string, lo memory.MemSize) memory.Range {
				rnge, err := memory.NewRangeFromString(str)
				Ω(err).ShouldNot(HaveOccurred())
				Ω(rnge).ShouldNot(BeNil())
				Ω(rnge.Floor()).Should(Equal(lo))
				return rnge
			}

			itFails = func(str string) {
				_, err := memory.NewRangeFromString(str)
				Ω(err).Should(HaveOccurred())
			}
		})

		Context("succeeds", func() {
			It("creates a degenerate range correctly", func() {
				rnge := itWorks(" 3m ", getMs(3*mEGA))