<commit_before>package hummingbird

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestParseRange(t *testing.T) {
	//Setting up individual test data
	tests := []struct {
		rangeHeader string
		exResBegin  int64
		exResEnd    int64
		exError     string
	}{
		{" ", 0, 0, ""},
		{"bytes=", 0, 0, "invalid range format"},
		{"bytes=-", 0, 0, "invalid range format"},
		{"bytes=-cv", 0, 0, "invalid end with no begin"},
		{"bytes=cv-", 0, 0, "invalid begin with no end"},
		{"bytes=-0", 0, 0, "zero end with no begin"},
		{"bytes=-12346", 0, 12345, ""},
		{"bytes=-12344", 1, 12345, ""},
		{"bytes=12344-", 12344, 12345, ""},
		{"bytes=12345-cv", 0, 0, "invalid end"},
		{"bytes=cv-12345", 0, 0, "invalid begin"},
		{"bytes=12346-12", 0, 12346, ""},
		{"bytes=12346-123457", 0, 0, "Begin bigger than file"},
		{"bytes=12342-12343", 12342, 12344, ""},
		{"bytes=12342-12344", 12342, 12345, ""},
	}

	//Run tests with data from above
	for _, test := range tests {
		result, err := ParseRange(test.rangeHeader, 12345)
		if test.rangeHeader == " " {
			assert.Nil(t, result)
			assert.Nil(t, err)
			continue
		}
		if test.exError == "" {
			httpResult := httpRange{test.exResBegin, test.exResEnd}
			assert.Nil(t, err)
			assert.Contains(t, result, httpResult)
		} else {
			assert.Equal(t, err.Error(), test.exError)
		}
	}
}

func TestParseRange_NoEnd_BeginLargerThanFilesize(t *testing.T) {
	result, err := ParseRange("bytes=12346-", 12345)
	assert.Nil(t, err)
	assert.Empty(t, result)
}

func TestParseDate(t *testing.T) {
	//Setup tests with individual data
	tests := []string{
		"Mon, 02 Jan 2006 15:04:05 MST",
		"Mon, 02 Jan 2006 15:04:05 -0700",
		"Mon Jan 02 15:04:05 2006",
		"Monday, 02-Jan-06 15:04:05 MST",
		"1136214245",
		"1136214245.1234",
		"2006-01-02 15:04:05",
	}<commit_msg>fix go tests<commit_after>package hummingbird

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestParseRange(t *testing.T) {
	//Setting up individual test data
	tests := []struct {
		rangeHeader string
		exResBegin  int64
		exResEnd    int64
		exError     string
	}{
		{" ", 0, 0, ""},
		{"bytes=", 0, 0, "invalid range format"},
		{"bytes=-", 0, 0, "invalid range format"},
		{"bytes=-cv", 0, 0, "invalid end with no begin"},
		{"bytes=cv-", 0, 0, "invalid begin with no end"},
		{"bytes=-0", 0, 0, "zero end with no begin"},
		{"bytes=-12346", 0, 12345, ""},
		{"bytes=-12344", 1, 12345, ""},
		{"bytes=12344-", 12344, 12345, ""},
		{"bytes=12345-cv", 0, 0, "invalid end"},
		{"bytes=cv-12345", 0, 0, "invalid begin"},
		{"bytes=12346-123457", 0, 0, "Begin bigger than file"},
		{"bytes=12342-12343", 12342, 12344, ""},
		{"bytes=12342-12344", 12342, 12345, ""},
	}

	//Run tests with data from above
	for _, test := range tests {
		result, err := ParseRange(test.rangeHeader, 12345)
		if test.rangeHeader == " " {
			assert.Nil(t, result)
			assert.Nil(t, err)
			continue
		}
		if test.exError == "" {
			httpResult := httpRange{test.exResBegin, test.exResEnd}
			assert.Nil(t, err)
			assert.Contains(t, result, httpResult)
		} else {
			assert.Equal(t, err.Error(), test.exError)
		}
	}
}

func TestParseRange_BeginAfterEnd(t *testing.T) {
	result, err := ParseRange("bytes=12346-12", 12345)
	assert.Nil(t, err)
	assert.Empty(t, result)
}

func TestParseRange_NoEnd_BeginLargerThanFilesize(t *testing.T) {
	result, err := ParseRange("bytes=12346-", 12345)
	assert.Nil(t, err)
	assert.Empty(t, result)
}

func TestParseDate(t *testing.T) {
	//Setup tests with individual data
	tests := []string{
		"Mon, 02 Jan 2006 15:04:05 MST",
		"Mon, 02 Jan 2006 15:04:05 -0700",
		"Mon Jan 02 15:04:05 2006",
		"Monday, 02-Jan-06 15:04:05 MST",
		"1136214245",
		"1136214245.1234",
		"2006-01-02 15:04:05",
	}
{'fraction_non_alphanumeric': 0.18868935942106674, 'fraction_numerical': 0.12677566336102922, 'mean_word_length': 3.846753246753247, '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': '5859620', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1443, 'n_words': 364}