import unittest
import subprocess
import sys

SCRIPT_PATH = "/Users/einand/Code/test/nim/print_hej"

def run_script(decimals=None):
    cmd = [SCRIPT_PATH]
    if decimals is not None:
        cmd.append(str(decimals))
    result = subprocess.run(cmd, capture_output=True, text=True)
    return result.stdout.strip()

class TestPi(unittest.TestCase):
    def test_10_decimals(self):
        result = run_script(10)
        expected = "3.1415926535"
        self.assertEqual(result, expected)
    
    def test_5_decimals(self):
        result = run_script(5)
        expected = "3.14159"
        self.assertEqual(result, expected)
    
    def test_1_decimal(self):
        result = run_script(1)
        expected = "3.1"
        self.assertEqual(result, expected)
    
    def test_100_decimals(self):
        result = run_script(100)
        expected = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"
        self.assertEqual(result, expected)
    
    def test_default_100_decimals(self):
        result = run_script()
        expected = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"
        self.assertEqual(result, expected)
    
    def test_10000_decimals(self):
        result = run_script(10000)
        # Check length: "3." + 10000 digits = 10002 characters
        self.assertEqual(len(result), 10002)
        self.assertTrue(result.startswith("3.14159"))

if __name__ == "__main__":
    unittest.main()