package com.prodhack.moscow2025.presentation.utils

import org.junit.Test
import org.junit.Assert.*

class SetUtilsTest {

	@Test
	fun `toggleItem adds item when not present`() {
		val set = mutableSetOf<Int>()
		set.toggleItem(1)
		assertTrue(set.contains(1))
		assertEquals(1, set.size)
	}

	@Test
	fun `toggleItem removes item when present`() {
		val set = mutableSetOf(1, 2, 3)
		set.toggleItem(2)
		assertFalse(set.contains(2))
		assertTrue(set.contains(1))
		assertTrue(set.contains(3))
		assertEquals(2, set.size)
	}

	@Test
	fun `toggleItem works with empty set`() {
		val set = mutableSetOf<String>()
		set.toggleItem("test")
		assertTrue(set.contains("test"))
	}

	@Test
	fun `toggleItem can toggle same item multiple times`() {
		val set = mutableSetOf<Int>()
		set.toggleItem(5)
		assertTrue(set.contains(5))
		set.toggleItem(5)
		assertFalse(set.contains(5))
		set.toggleItem(5)
		assertTrue(set.contains(5))
	}

	@Test
	fun `toggleItem works with strings`() {
		val set = mutableSetOf("a", "b")
		set.toggleItem("c")
		assertTrue(set.contains("c"))
		set.toggleItem("a")
		assertFalse(set.contains("a"))
	}
}

