<commit_before>package view

import (
	"testing"
)

func TestViewEqual(t *testing.T) {
	v1 := New()
	v2 := New()

	if !v1.Equal(v2) {
		t.Fatalf("Empty views v1 and v2 should be equal")
	}

	v1.AddUpdate(Update{Join, Process{"1"}})
	v1.AddUpdate(Update{Join, Process{"2"}})
	v1.AddUpdate(Update{Join, Process{"3"}})
	v1.AddUpdate(Update{Leave, Process{"1"}})

	if v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be different")
	}

	v2.AddUpdate(Update{Join, Process{"1"}})
	v2.AddUpdate(Update{Join, Process{"2"}})
	v2.AddUpdate(Update{Join, Process{"3"}})
	v2.AddUpdate(Update{Leave, Process{"1"}})

	if !v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be equal")
	}

	v2.AddUpdate(Update{Leave, Process{"2"}})

	if v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be different")
	}
}

func TestViewSet(t *testing.T) {
	v1 := New()
	v2 := New()

	v1.AddUpdate(Update{Join, Process{"1"}})
	v1.AddUpdate(Update{Join, Process{"2"}})
	v1.AddUpdate(Update{Join, Process{"3"}})
	v1.AddUpdate(Update{Leave, Process{"1"}})

	if v1.N() != 2 {
		t.Fatalf("v1 should have 2 members")
	}

	v2.Set(v1)

	if !v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be equal")
	}
}

func TestViewGetMembers(t *testing.T) {
	v1 := New()

	v1.AddUpdate(Update{Join, Process{"1"}})
	v1.AddUpdate(Update{Join, Process{"2"}})
	v1.AddUpdate(Update{Join, Process{"3"}})
	v1.AddUpdate(Update{Leave, Process{"1"}})

	processes := v1.GetMembers()
	processes2 := []Process{Process{"2"}, Process{"3"}}

	for i, p := range processes {
		if p != processes2[i] {<commit_msg>Fix view_test.go relying on order<commit_after>package view

import (
	"testing"
)

func TestViewEqual(t *testing.T) {
	v1 := New()
	v2 := New()

	if !v1.Equal(v2) {
		t.Fatalf("Empty views v1 and v2 should be equal")
	}

	v1.AddUpdate(Update{Join, Process{"1"}})
	v1.AddUpdate(Update{Join, Process{"2"}})
	v1.AddUpdate(Update{Join, Process{"3"}})
	v1.AddUpdate(Update{Leave, Process{"1"}})

	if v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be different")
	}

	v2.AddUpdate(Update{Join, Process{"1"}})
	v2.AddUpdate(Update{Join, Process{"2"}})
	v2.AddUpdate(Update{Join, Process{"3"}})
	v2.AddUpdate(Update{Leave, Process{"1"}})

	if !v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be equal")
	}

	v2.AddUpdate(Update{Leave, Process{"2"}})

	if v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be different")
	}
}

func TestViewSet(t *testing.T) {
	v1 := New()
	v2 := New()

	v1.AddUpdate(Update{Join, Process{"1"}})
	v1.AddUpdate(Update{Join, Process{"2"}})
	v1.AddUpdate(Update{Join, Process{"3"}})
	v1.AddUpdate(Update{Leave, Process{"1"}})

	if v1.N() != 2 {
		t.Fatalf("v1 should have 2 members")
	}

	v2.Set(v1)

	if !v1.Equal(v2) {
		t.Fatalf("Views v1 and v2 should be equal")
	}
}

func TestViewGetMembers(t *testing.T) {
	v1 := New()

	v1.AddUpdate(Update{Join, Process{"1"}})
	v1.AddUpdate(Update{Join, Process{"2"}})
	v1.AddUpdate(Update{Join, Process{"3"}})
	v1.AddUpdate(Update{Leave, Process{"1"}})

	processes := v1.GetMembers()
	processes2 := []Process{Process{"2"}, Process{"3"}}

	if len(processes) != len(processes2) {
		t.Fatalf("Array of processes should be equal")
	}

	for _, p := range processes {
		found := false
		for _, p2 := range processes2 {
			if p == p2 {
				found = true
				break
			}
		}
		if !found {
{'fraction_non_alphanumeric': 0.19592952612393683, 'fraction_numerical': 0.04343863912515188, 'mean_word_length': 4.648370497427101, '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': '1837931', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1361, 'n_words': 273}