Skip to content

UnitTestBot Go. Slices support #1868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 1, 2023
Merged

Conversation

egiptipavel
Copy link
Collaborator

@egiptipavel egiptipavel commented Feb 27, 2023

Description

Add slices support.

How to test

Manual tests

var ErrNotFound = errors.New("target not found in array")

func Binary(array []int, target int, lowIndex int, highIndex int) (int, error) {
	if highIndex < lowIndex {
		return -1, ErrNotFound
	}
	mid := lowIndex + (highIndex-lowIndex)/2
	if array[mid] > target {
		return Binary(array, target, lowIndex, mid-1)
	} else if array[mid] < target {
		return Binary(array, target, mid+1, highIndex)
	} else {
		return mid, nil
	}
}

func ArrayOfSliceOfUint(array [5][]uint) [5][]uint {
	return array
}

func SliceOfInt(slice []int) []int {
	return slice
}

func SliceOfUintPtr(slice []uintptr) []uintptr {
	return slice
}

func SliceOfString(slice []string) []string {
	return slice
}

type Structure struct {
	int
	int8
	int16
	int32
	int64
	uint
	uint8
	uint16
	uint32
	uint64
	uintptr
	float32
	float64
	complex64
	complex128
	byte
	rune
	string
	bool
}

func SliceOfStructs(slice []Structure) []Structure {
	return slice
}

func SliceOfStructsWithNan(slice []Structure) []Structure {
	slice[0].float64 = math.NaN()
	return slice
}

func SliceOfSliceOfByte(slice [][]byte) [][]byte {
	return slice
}

func SliceOfSliceOfStructs(slice [][]Structure) [][]Structure {
	return slice
}

func SliceOfArrayOfInt(slice [][5]int) [][5]int {
	return slice
}

Self-check list

Check off the item if the statement is true. Hint: [x] is a marked item.

Please do not delete the list or its items.

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@egiptipavel egiptipavel added ctg-enhancement New feature, improvement or change request lang-go Issue is related to Go support labels Feb 27, 2023
@egiptipavel egiptipavel self-assigned this Feb 27, 2023
@egiptipavel egiptipavel merged commit f99ceb7 into main Mar 1, 2023
@egiptipavel egiptipavel deleted the egiptipavel/go-slices-support branch March 1, 2023 13:29
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-enhancement New feature, improvement or change request lang-go Issue is related to Go support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants