diff --git a/pkg/util/partition_message_test.go b/pkg/util/partition_message_test.go index 31e0f643..5ce1015e 100644 --- a/pkg/util/partition_message_test.go +++ b/pkg/util/partition_message_test.go @@ -61,20 +61,20 @@ var _ = Describe("Partition Message", func() { } testString := "" - for inputLen := uint(1); inputLen < 8000; inputLen++ { + for inputLen := 1; inputLen < 8000; inputLen++ { // add a rune to the string using a repeatable pattern (single digit hex of position) testString += strconv.FormatInt(int64(inputLen%16), 16) items, omitted := PartitionMessage(testString, unalignedLimits, 7) included := 0 for ii, item := range items { - expectedSize := unalignedLimits.ChunkSize + expectedSize := int(unalignedLimits.ChunkSize) // The last chunk might be smaller than the preceeding chunks if ii == len(items)-1 { // the chunk size is the remainder of, the total size, // or the max size, whatever is smallest, // and the previous chunk sizes - chunkSize := UMin(inputLen, unalignedLimits.TotalChunkSize) % unalignedLimits.ChunkSize + chunkSize := Min(inputLen, int(unalignedLimits.TotalChunkSize)) % int(unalignedLimits.ChunkSize) // if the "rest" of the runes needs another chunk if chunkSize > 0 { // expect the chunk to contain the "rest" of the runes @@ -88,8 +88,8 @@ var _ = Describe("Partition Message", func() { for ri, r := range item.Text { runeOffset := (len(item.Text) - ri) - 1 runeVal, err := strconv.ParseUint(string(r), 16, 64) - expectedLen := UMin(inputLen, unalignedLimits.TotalChunkSize) - expectedVal := (expectedLen - uint(runeOffset)) % 16 + expectedLen := Min(inputLen, int(unalignedLimits.TotalChunkSize)) + expectedVal := (expectedLen - runeOffset) % 16 Expect(err).ToNot(HaveOccurred()) Expect(runeVal).To(BeEquivalentTo(expectedVal)) @@ -161,17 +161,17 @@ func testMessageItemsFromLines(hundreds int, limits types.MessageLimit, repeat i return } -func testPartitionMessage(hundreds uint, limits types.MessageLimit, distance int) (items []types.MessageItem, omitted int) { +func testPartitionMessage(hundreds int, limits types.MessageLimit, distance int) (items []types.MessageItem, omitted int) { builder := strings.Builder{} - for i := uint(0); i < hundreds; i++ { + for i := 0; i < hundreds; i++ { builder.WriteString(hundredChars) } items, omitted = PartitionMessage(builder.String(), limits, distance) - contentSize := UMin(hundreds*100, limits.TotalChunkSize) - expectedOmitted := UMax(0, (hundreds*100)-contentSize) + contentSize := Min(hundreds*100, int(limits.TotalChunkSize)) + expectedOmitted := Max(0, (hundreds*100)-contentSize) ExpectWithOffset(0, omitted).To(BeEquivalentTo(expectedOmitted)) diff --git a/pkg/util/util.go b/pkg/util/util.go index f06d680c..1e8cba49 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -13,14 +13,6 @@ func Min(a int, b int) int { return b } -// UMin returns the smallest of a and b -func UMin(a uint, b uint) uint { - if a < b { - return a - } - return b -} - // Max returns the largest of a and b func Max(a int, b int) int { if a > b { @@ -29,13 +21,5 @@ func Max(a int, b int) int { return b } -// UMax returns the largest of a and b -func UMax(a uint, b uint) uint { - if a > b { - return a - } - return b -} - // DiscardLogger is a logger that discards any output written to it var DiscardLogger = log.New(ioutil.Discard, "", 0)