<commit_before>package gen

import (
	"math"
	"reflect"

	"github.com/leanovate/gopter"
)

// Int64Range generates int64 numbers within a given range
func Int64Range(min, max int64) gopter.Gen {
	if max < min {
		return Fail(reflect.TypeOf(int64(0)))
	}
	d := uint64(max - min + 1)

	if d == 0 { // Check overflow (i.e. max = MaxInt64, min = MinInt64)
		return func(genParams *gopter.GenParameters) *gopter.GenResult {
			return gopter.NewGenResult(genParams.NextInt64(), Int64Shrinker)
		}
	}
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		genResult := gopter.NewGenResult(min+int64(genParams.NextUint64()%d), Int64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(int64) >= min && v.(int64) <= max
		}
		return genResult
	}
}

// UInt64Range generates uint64 numbers within a given range
func UInt64Range(min, max uint64) gopter.Gen {
	if max < min {
		return Fail(reflect.TypeOf(int64(0)))
	}
	d := max - min + 1
	if d == 0 { // Check overflow (i.e. max = MaxInt64, min = MinInt64)
		return func(genParams *gopter.GenParameters) *gopter.GenResult {
			return gopter.NewGenResult(genParams.NextUint64(), Int64Shrinker)
		}
	}
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		genResult := gopter.NewGenResult(min+genParams.NextUint64()%d, UInt64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(uint64) >= min && v.(uint64) <= max
		}
		return genResult
	}
}

// Int64 generates an arbitrary int64 number
func Int64() gopter.Gen {<commit_msg>Fix some issues with int64 and uint64 generation.<commit_after>package gen

import (
	"math"
	"reflect"

	"github.com/leanovate/gopter"
)

// Int64Range generates int64 numbers within a given range
func Int64Range(min, max int64) gopter.Gen {
	if max < min {
		return Fail(reflect.TypeOf(int64(0)))
	}
	rangeSize := uint64(max - min + 1)

	if max == math.MaxInt64 && min == math.MinInt64 { // Check overflow (i.e. max = MaxInt64, min = MinInt64)
		return func(genParams *gopter.GenParameters) *gopter.GenResult {
			return gopter.NewGenResult(genParams.NextInt64(), Int64Shrinker)
		}
	}
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		var nextResult uint64 = uint64(min) + (genParams.NextUint64() % rangeSize)
		genResult := gopter.NewGenResult(int64(nextResult), Int64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(int64) >= min && v.(int64) <= max
		}
		return genResult
	}
}

// UInt64Range generates uint64 numbers within a given range
func UInt64Range(min, max uint64) gopter.Gen {
	if max < min {
		return Fail(reflect.TypeOf(uint64(0)))
	}
	d := max - min + 1
	if d == 0 { // Check overflow (i.e. max = MaxInt64, min = MinInt64)
		return func(genParams *gopter.GenParameters) *gopter.GenResult {
			return gopter.NewGenResult(genParams.NextUint64(), UInt64Shrinker)
		}
	}
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		genResult := gopter.NewGenResult(min+genParams.NextUint64()%d, UInt64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(uint64) >= min && v.(uint64) <= max
		}
		return genResult
	}
}

// Int64 generates an arbitrary int64 number
func Int64() gopter.Gen {
{'fraction_non_alphanumeric': 0.13044841643148322, 'fraction_numerical': 0.04609595484477893, 'mean_word_length': 4.212418300653595, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5675113', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1142, 'n_words': 273}