<commit_before>package main

import (
	"fmt"
	"testing"
)

func TestLocalLoadCalendarParsing(t *testing.T) {
	LoadCalendar()
	//fmt.Println(events.hacknight.Time.Unix())
	if events.talknight.Time.Unix() == -62135596800 || events.hacknight.Time.Unix() == -62135596800 {
		t.Errorf("Events nil!: %#v", events)
	}
}

func TestEventResponse(t *testing.T) {
	c := make(chan Event)
	go parseEvent("testing/resources/talking.json", c)
	jsn := <-c

	out := EventResponse(jsn, "ropes", "Talk Night")
	fmt.Printf("%#v\n", out)
	if len(out) != 3 {
		t.Errorf("Three strings not returned!")
	}
	for i, v := range out {
		if v == "" {
			t.Errorf("String %d empty!: '%s'", i, v)
		}
	}
}

func TestTalkTargetEventParsing(t *testing.T) {
	c := make(chan Event)
	go parseEvent("testing/resources/talking.json", c)
	jsn := <-c<commit_msg>Added functions found online to aid testing<commit_after>package main

import (
	"fmt"
	"path/filepath"
	"reflect"
	"runtime"
	"testing"
)

// assert fails the test if the condition is false.
func assert(tb testing.TB, condition bool, msg string, v ...interface{}) {
	if !condition {
		_, file, line, _ := runtime.Caller(1)
		fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{filepath.Base(file), line}, v...)...)
		tb.FailNow()
	}
}

// ok fails the test if an err is not nil.
func ok(tb testing.TB, err error) {
	if err != nil {
		_, file, line, _ := runtime.Caller(1)
		fmt.Printf("\033[31m%s:%d: unexpected error: %s\033[39m\n\n", filepath.Base(file), line, err.Error())
		tb.FailNow()
	}
}

// equals fails the test if exp is not equal to act.
func equals(tb testing.TB, exp, act interface{}) {
	if !reflect.DeepEqual(exp, act) {
		_, file, line, _ := runtime.Caller(1)
		fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, exp, act)
		tb.FailNow()
	}
}

func TestLocalLoadCalendarParsing(t *testing.T) {
	LoadCalendar()
	//fmt.Println(events.hacknight.Time.Unix())
	if events.talknight.Time.Unix() == -62135596800 || events.hacknight.Time.Unix() == -62135596800 {
		t.Errorf("Events nil!: %#v", events)
	}
}

func TestEventResponse(t *testing.T) {
	c := make(chan Event)
	go parseEvent("testing/resources/talking.json", c)
	jsn := <-c

	out := EventResponse(jsn, "ropes", "Talk Night")
	fmt.Printf("%#v\n", out)
	if len(out) != 3 {
		t.Errorf("Three strings not returned!")
	}
	for i, v := range out {
		if v == "" {
			t.Errorf("String %d empty!: '%s'", i, v)
		}
	}
}

func TestTalkTargetEventParsing(t *testing.T) {
	c := make(chan Event)
	go parseEvent("testing/resources/talking.json", c)
	jsn := <-c
{'fraction_non_alphanumeric': 0.19252984212552945, 'fraction_numerical': 0.030419715055833654, 'mean_word_length': 3.9580152671755724, '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': '1014688', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1029, 'n_words': 233}