Skip to content

Commit 55e0211

Browse files
committed
Add string tests.
#1
1 parent aa51d8d commit 55e0211

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/unit/string_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import unittest
2+
3+
from pyvalueobjects.errors.ValueObjectError import ValueObjectError
4+
from pyvalueobjects.strings.string import String
5+
6+
7+
class TestStringValueObject(unittest.TestCase):
8+
def test_value_return_input_value(self):
9+
vo = String('')
10+
self.assertEqual('', vo.value())
11+
12+
def test_from_string_method_returns_string(self):
13+
vo = String.from_int(39)
14+
self.assertEqual('39', vo.value())
15+
16+
def test_from_float_method_returns_int_format_string(self):
17+
vo = String.from_float(39.0)
18+
self.assertEqual('39.0', vo.value())
19+
20+
def test_zero_value_return_input_value(self):
21+
vo = String.from_int(0)
22+
self.assertEqual('0', vo.value())
23+
24+
def test_basic_string(self):
25+
vo = String('patata')
26+
self.assertEqual('patata', vo.value())
27+
28+
def test_none_raise_error(self):
29+
self.assertRaises(ValueObjectError, String, None)

0 commit comments

Comments
 (0)