package main

import (
	"testing"
)

func TestSwap(t *testing.T) {
	testIndex := 0
	expected := []int{1, 3, 5, 9, 7}
	actual := []int{3, 1, 5, 9, 7}
	Swap(actual, testIndex)

	if expected[testIndex] != actual[testIndex] && expected[testIndex+1] != actual[testIndex+1] {
		t.Errorf("Swap function failed to swap elements at index %d and %d", testIndex, testIndex+1)
	}

}

func TestBubbleSort(t *testing.T) {
	expected := []int{1, 3, 5, 7, 9}
	actual := []int{3, 1, 5, 9, 7}
	BubbleSort(actual)

	if len(expected) != len(actual) {
		t.Errorf("Error: Expected len: %d, Actual len: %d", len(expected), len(actual))
	}

	for i, v := range actual {
		if v != expected[i] {
			t.Errorf("Value: %d at actual[%d] does not match %d at expected[%d]", v, i, expected[i], i)
		}
	}

}
