<commit_before>package stats_test

import (
	"math"
	"testing"
	"github.com/mbu/stats"
	"github.com/shirou/gopsutil/mem"
	"github.com/shirou/gopsutil/disk"
	"github.com/stretchr/testify/assert"
)

func TestGetAverage_OK(t *testing.T) {

	float64Array := []float64{ 11.904762, 27.5, 5, 2.5, 7.692308, 31.707317, 2.4390242, 7.317073 }

	expected := float64(12.007560525)
	actual := stats.GetAverage(float64Array)
	difference := math.Abs(float64(expected - actual))

	if (difference >= 1) {
		t.Error("Expected a difference less than 1, got: ", difference)
	}
}

func TestGetAverage_NOK_emptyArray(t *testing.T) {

	float64Array := []float64{}

	expected := float64(0)
	actual := stats.GetAverage(float64Array)
	assert.Equal(t, expected, actual)
}

func TestBuildCPUMultipleStat_OK(t *testing.T) {

	float64Array := []float64{ 11.904762, 27.5, 5, 2.5, 7.692308, 31.707317, 2.4390242, 7.317073 }
	cpu := stats.BuildCPUMultipleStat(float64Array)

	assert := assert.New(t)
	assert.NotNil(cpu)
	assert.Equal(stats.GetAverage(float64Array), cpu.AverageUsagePercentage)
	assert.Equal(len(float64Array), len(cpu.UsagePercentagePerCore))
}

func TestBuildCPUMultipleStat_NOK_emptyArray(t *testing.T) {

	float64Array := []float64{}
	cpu := stats.BuildCPUMultipleStat(float64Array)

	assert := assert.New(t)
	assert.NotNil(cpu)
	assert.Equal(stats.GetAverage(float64Array), cpu.AverageUsagePercentage)
	assert.Equal(float64(0), cpu.AverageUsagePercentage)
	assert.Equal(len(float64Array), len(cpu.UsagePercentagePerCore))
	assert.Equal(0, len(cpu.UsagePercentagePerCore))
}<commit_msg>Add number of cores to factory tests.<commit_after>package stats_test

import (
	"math"
	"testing"
	"github.com/mbu/stats"
	"github.com/shirou/gopsutil/mem"
	"github.com/shirou/gopsutil/disk"
	"github.com/stretchr/testify/assert"
)

func TestGetAverage_OK(t *testing.T) {

	float64Array := []float64{ 11.904762, 27.5, 5, 2.5, 7.692308, 31.707317, 2.4390242, 7.317073 }

	expected := float64(12.007560525)
	actual := stats.GetAverage(float64Array)
	difference := math.Abs(float64(expected - actual))

	if (difference >= 1) {
		t.Error("Expected a difference less than 1, got: ", difference)
	}
}

func TestGetAverage_NOK_emptyArray(t *testing.T) {

	float64Array := []float64{}

	expected := float64(0)
	actual := stats.GetAverage(float64Array)
	assert.Equal(t, expected, actual)
}

func TestBuildCPUMultipleStat_OK(t *testing.T) {

	float64Array := []float64{ 11.904762, 27.5, 5, 2.5, 7.692308, 31.707317, 2.4390242, 7.317073 }
	cpu := stats.BuildCPUMultipleStat(float64Array)

	assert := assert.New(t)
	assert.NotNil(cpu)
	assert.Equal(len(float64Array), cpu.NumberOfCores)
	assert.Equal(stats.GetAverage(float64Array), cpu.AverageUsagePercentage)
	assert.Equal(len(float64Array), len(cpu.UsagePercentagePerCore))
}

func TestBuildCPUMultipleStat_NOK_emptyArray(t *testing.T) {

	float64Array := []float64{}
	cpu := stats.BuildCPUMultipleStat(float64Array)

	assert := assert.New(t)
	assert.NotNil(cpu)
	assert.Equal(len(float64Array), cpu.NumberOfCores)
	assert.Equal(stats.GetAverage(float64Array), cpu.AverageUsagePercentage)
	assert.Equal(float64(0), cpu.AverageUsagePercentage)
	assert.Equal(len(float64Array), len(cpu.UsagePercentagePerCore))
	assert.Equal(0, len(cpu.UsagePercentagePerCore))
}
{'fraction_non_alphanumeric': 0.14386072083078802, 'fraction_numerical': 0.08918753817959682, 'mean_word_length': 5.938559322033898, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4081872', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1237, 'n_words': 194}