<commit_before>// Copyright 2015 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package autoinc

import (
	"math"
	"sync"
	"testing"
	"time"

	"github.com/issue9/assert"
)

func TestAutoInc_overflow(t *testing.T) {
	a := assert.New(t)

	ai := New(math.MaxInt64-1, 2, 2)
	a.NotNil(ai)
	id, ok := ai.ID()
	a.True(ok).Equal(0, len(ai.channel))

	id, ok = ai.ID()
	a.False(ok).Equal(id, 0)

	id, ok = ai.ID()
	a.False(ok).Equal(id, 0)

	a.Panic(func() {
		id = ai.MustID()
		a.Equal(id, 0)
	})
}

func TestAutoInc_ID_1(t *testing.T) {
	a := assert.New(t)

	a.Panic(func() {
		ai := New(0, 0, 2)
		a.Nil(ai)<commit_msg>修正测试错误<commit_after>// Copyright 2015 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package autoinc

import (
	"math"
	"sync"
	"testing"
	"time"

	"github.com/issue9/assert"
)

func TestAutoInc_overflow(t *testing.T) {
	a := assert.New(t)

	ai := New(math.MaxInt64-1, 2, 2)
	a.NotNil(ai)
	id, ok := ai.ID()
	a.True(ok).Equal(math.MaxInt64-1, id)

	id, ok = ai.ID()
	a.False(ok).Equal(id, 0)

	id, ok = ai.ID()
	a.False(ok).Equal(id, 0)

	a.Panic(func() {
		id = ai.MustID()
		a.Equal(id, 0)
	})
}

func TestAutoInc_ID_1(t *testing.T) {
	a := assert.New(t)

	a.Panic(func() {
		ai := New(0, 0, 2)
		a.Nil(ai)
{'fraction_non_alphanumeric': 0.18371757925072046, 'fraction_numerical': 0.027377521613832854, 'mean_word_length': 3.2607361963190185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2919324', 'n_tokens_mistral': 673, 'n_tokens_neox': 627, 'n_words': 151}