<commit_before>package collect

import (
	"testing"
	"time"

	"github.com/v2ray/v2ray-core/testing/unit"
)

func TestTimedStringMap(t *testing.T) {
	assert := unit.Assert(t)

	nowSec := time.Now().UTC().Unix()
	m := NewTimedStringMap(2)
	m.Set("Key1", "Value1", nowSec)
	m.Set("Key2", "Value2", nowSec+5)

	v1, ok := m.Get("Key1")
	assert.Bool(ok).IsTrue()
	assert.String(v1.(string)).Equals("Value1")

	v2, ok := m.Get("Key2")
	assert.Bool(ok).IsTrue()
	assert.String(v2.(string)).Equals("Value2")

	tick := time.Tick(3 * time.Second)
	<-tick

	v1, ok = m.Get("Key1")
	assert.Bool(ok).IsFalse()

	v2, ok = m.Get("Key2")
	assert.Bool(ok).IsTrue()
	assert.String(v2.(string)).Equals("Value2")

	<-tick
	v2, ok = m.Get("Key2")
	assert.Bool(ok).IsFalse()<commit_msg>Update test<commit_after>package collect

import (
	"testing"
	"time"

	"github.com/v2ray/v2ray-core/testing/unit"
)

func TestTimedStringMap(t *testing.T) {
	assert := unit.Assert(t)

	nowSec := time.Now().UTC().Unix()
	m := NewTimedStringMap(2)
	m.Set("Key1", "Value1", nowSec)
	m.Set("Key2", "Value2", nowSec+5)

	v1, ok := m.Get("Key1")
	assert.Bool(ok).IsTrue()
	assert.String(v1.(string)).Equals("Value1")

	v2, ok := m.Get("Key2")
	assert.Bool(ok).IsTrue()
	assert.String(v2.(string)).Equals("Value2")

	tick := time.Tick(4 * time.Second)
	<-tick

	v1, ok = m.Get("Key1")
	assert.Bool(ok).IsFalse()

	v2, ok = m.Get("Key2")
	assert.Bool(ok).IsTrue()
	assert.String(v2.(string)).Equals("Value2")

	<-tick
	v2, ok = m.Get("Key2")
	assert.Bool(ok).IsFalse()
{'fraction_non_alphanumeric': 0.22572178477690288, 'fraction_numerical': 0.03280839895013123, 'mean_word_length': 4.565693430656935, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5086429', 'n_tokens_mistral': 678, 'n_tokens_neox': 657, 'n_words': 98}