Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackusay committed May 1, 2023
1 parent 7734a3f commit d7da58b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
id_img = image_proc(0, IMAGE_CREATE)

def log(s):
print(s)
#print(s)
pass

def get_url(txt):
Expand Down
30 changes: 30 additions & 0 deletions test-geturl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import unittest
#from . import __init__ as home #error
#from . import __init__ #error
#from . import init #error
#from __init__ import get_url #error
#from .mdimg import * #error
from cuda_markdown_image.__init__ import get_url
#if use exec(open("filename.py").read()) to execute script, import part need to use absolute path!!!


class GetUrlTestCase(unittest.TestCase):
def test_get_url(self):
expected = r"https://octodex.github.com/images/stormtroopocat.jpg"
result = get_url(r'some idea ![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat") do it.')
self.assertEqual(result, expected)
def test_get_url_include_space(self):
expected = r"https://octodex.github.com/Ims/ca t"
result = get_url(r'some idea ![Stocat](https://octodex.github.com/Ims/ca t "The Storocat") do it.')
self.assertEqual(result, expected)
def test_get_url_include_backslash(self):
expected = r"C:\Users\Downloads\New folder\cuda_hilite"
result = get_url(r'some idea ![Stocat](C:\Users\Downloads\New folder\cuda_hilite "The Storocat") do it.')
self.assertEqual(result, expected)

suite = unittest.TestSuite()
suite.addTest(GetUrlTestCase('test_get_url'))
suite.addTest(GetUrlTestCase('test_get_url_include_space'))
suite.addTest(GetUrlTestCase('test_get_url_include_backslash'))

unittest.TextTestRunner(verbosity=2).run(suite)

0 comments on commit d7da58b

Please sign in to comment.