Compare commits
No commits in common. "forge/iss-1ac610bafd4c" and "main" have entirely different histories.
forge/iss-
...
main
9 changed files with 1 additions and 107 deletions
|
|
@ -1,3 +0,0 @@
|
|||
# iss-1ac610bafd4c
|
||||
|
||||
Forge 이슈 작업 브랜치 `forge/iss-1ac610bafd4c`.
|
||||
|
|
@ -1,8 +1,2 @@
|
|||
# Utility Functions
|
||||
# ssot-live
|
||||
|
||||
This repository contains a collection of utility functions that can be used across various projects.
|
||||
|
||||
## Modules
|
||||
- `math_utils`: Contains basic mathematical operations.
|
||||
- `string_utils`: Provides string manipulation functions.
|
||||
- `date_utils`: Handles date-related utilities.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import unittest
|
||||
from utils.date_utils import get_current_date, format_date
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class TestDateUtils(unittest.TestCase):
|
||||
def test_get_current_date(self):
|
||||
self.assertEqual(get_current_date(), datetime.now().strftime('%Y-%m-%d'))
|
||||
|
||||
def test_format_date(self):
|
||||
date = datetime(2023, 1, 1)
|
||||
self.assertEqual(format_date(date, '%d-%m-%Y'), '01-01-2023')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import unittest
|
||||
from utils.math_utils import add, subtract, multiply, divide
|
||||
|
||||
|
||||
class TestMathUtils(unittest.TestCase):
|
||||
def test_add(self):
|
||||
self.assertEqual(add(1, 2), 3)
|
||||
|
||||
def test_subtract(self):
|
||||
self.assertEqual(subtract(5, 3), 2)
|
||||
|
||||
def test_multiply(self):
|
||||
self.assertEqual(multiply(3, 4), 12)
|
||||
|
||||
def test_divide(self):
|
||||
self.assertEqual(divide(10, 2), 5)
|
||||
with self.assertRaises(ValueError):
|
||||
divide(10, 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
import unittest
|
||||
from utils.string_utils import capitalize_first_letter, reverse_string
|
||||
|
||||
|
||||
class TestStringUtils(unittest.TestCase):
|
||||
def test_capitalize_first_letter(self):
|
||||
self.assertEqual(capitalize_first_letter('hello'), 'Hello')
|
||||
self.assertEqual(capitalize_first_letter(''), '')
|
||||
|
||||
def test_reverse_string(self):
|
||||
self.assertEqual(reverse_string('hello'), 'olleh')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Utility Functions Package
|
||||
|
||||
# This package contains various utility functions for different purposes.
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
from datetime import datetime
|
||||
|
||||
|
||||
def get_current_date():
|
||||
"""Returns the current date as a string in YYYY-MM-DD format."""
|
||||
return datetime.now().strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
def format_date(date, format='%Y-%m-%d'):
|
||||
"""Formats a given date to the specified format."""
|
||||
return date.strftime(format)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
def add(a, b):
|
||||
"""Returns the sum of two numbers."""
|
||||
return a + b
|
||||
|
||||
|
||||
def subtract(a, b):
|
||||
"""Returns the difference of two numbers."""
|
||||
return a - b
|
||||
|
||||
|
||||
def multiply(a, b):
|
||||
"""Returns the product of two numbers."""
|
||||
return a * b
|
||||
|
||||
|
||||
def divide(a, b):
|
||||
"""Returns the quotient of two numbers. Raises ValueError on division by zero."""
|
||||
if b == 0:
|
||||
raise ValueError('Cannot divide by zero')
|
||||
return a / b
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
def capitalize_first_letter(s):
|
||||
"""Capitalizes the first letter of a string."""
|
||||
if not s:
|
||||
return s
|
||||
return s[0].upper() + s[1:]
|
||||
|
||||
|
||||
def reverse_string(s):
|
||||
"""Reverses the given string."""
|
||||
return s[::-1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue