Skip to content

Commit 66a7930

Browse files
committed
update samples
1 parent f7a4860 commit 66a7930

9 files changed

Lines changed: 71 additions & 31 deletions

utbot-python/samples/cli_utbot_tests/generated_tests__dicts.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,23 @@
33
import unittest
44
import builtins
55
import dicts
6-
import copyreg
76
import types
87

98

109
class TestDictionary(unittest.TestCase):
1110
# region Test suites for executable dicts.translate
1211
# region
1312
def test_translate(self):
14-
dictionary = dicts.Dictionary([str(), str(-123456789), str(b'\x80'), str(1.5 + 3.5j), str(b'\x80'), str(1.5 + 3.5j), str(1e+300 * 1e+300)], [{str(b'\x80'): str(1e+300 * 1e+300), str('unicode remains unicode'): str(), str(1.5 + 3.5j): str(), str(): str()}, {str(): str()}, {}, {str('unicode remains unicode'): str(), str(b'\x80'): str(1e+300 * 1e+300), str(-123456789): str(1e+300 * 1e+300), str(1.5 + 3.5j): str()}, {str('unicode remains unicode'): str()}, {str(): str()}, {str(1.5 + 3.5j): str(), str(-123456789): str(1e+300 * 1e+300), str(1e+300 * 1e+300): str(), str(id): str(), str(b'\x80'): str(1e+300 * 1e+300), str(): str()}])
13+
dictionary = dicts.Dictionary([str(-1234567890), str(-123456789), str(b'\x80'), str(id), str(id), str('unicode remains unicode'), str(-123456789)], [])
1514

16-
actual = dictionary.translate(str(), str(1.5 + 3.5j))
15+
actual = dictionary.translate(str(id), str(1.5 + 3.5j))
1716

18-
word = copyreg._reconstructor(dicts.Word, builtins.object, None)
19-
word.translations = {"b'\\x80'": 'inf', 'unicode remains unicode': '', '(1.5+3.5j)': '', '': '', }
20-
actual_translations = actual.translations
21-
expected_translations = word.translations
22-
self.assertEqual(expected_translations, actual_translations)
17+
self.assertEqual(None, actual)
2318

2419
def test_translate_throws_t(self):
25-
dictionary = dicts.Dictionary([str(-1234567890), str(1e+300 * 1e+300), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(1.5 + 3.5j), str(-123456789), str(), str()], [{str(-1234567890): str(), str('unicode remains unicode'): str(), str(-123456789): str(), str(id): str(), str(): str(1e+300 * 1e+300)}, {str(id): str(), str(1e+300 * 1e+300): str(1e+300 * 1e+300), str(): str(), str('unicode remains unicode'): str()}, {str(id): str(), str(1e+300 * 1e+300): str(1e+300 * 1e+300), str(): str(), str('unicode remains unicode'): str()}, {str(): str(), str(-1234567890): str(), str(b'\x80'): str(), str('unicode remains unicode'): str()}, {str(): str()}, {}])
20+
dictionary = dicts.Dictionary([], [{str(): str(), str(-1234567890): str(), str(id): str(1e+300 * 1e+300), str(-123456789): str(), str(1e+300 * 1e+300): str(1e+300 * 1e+300)}, {str(1e+300 * 1e+300): str(1e+300 * 1e+300), str(id): str()}, {}, {str(): str(), str(-1234567890): str(), str(id): str(1e+300 * 1e+300), str(-123456789): str(), str(1e+300 * 1e+300): str(1e+300 * 1e+300)}, {str(1e+300 * 1e+300): str(), str(b'\x80'): str(), str(-123456789): str(1e+300 * 1e+300), str('unicode remains unicode'): str()}])
2621

27-
dictionary.translate(str(-1234567890), str(1.5 + 3.5j))
22+
dictionary.translate(str('unicode remains unicode'), str(1.5 + 3.5j))
2823

2924
# raises builtins.KeyError
3025

utbot-python/samples/cli_utbot_tests/generated_tests__graph.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ class TestTopLevelFunctions(unittest.TestCase):
1111
# region Test suites for executable graph.bfs
1212
# region
1313
def test_bfs(self):
14-
actual = graph.bfs([graph.Node(str(-1234567890), []), graph.Node(str('unicode remains unicode'), [])])
14+
actual = graph.bfs([graph.Node(str(1e+300 * 1e+300), []), graph.Node(str(id), []), graph.Node(str('unicode remains unicode'), [])])
1515

1616
node = copyreg._reconstructor(graph.Node, builtins.object, None)
1717
node.name = 'unicode remains unicode'
1818
node.children = []
1919
node1 = copyreg._reconstructor(graph.Node, builtins.object, None)
20-
node1.name = '-1234567890'
20+
node1.name = '<built-in function id>'
2121
node1.children = []
22-
self.assertEqual([node, node1], actual)
22+
node2 = copyreg._reconstructor(graph.Node, builtins.object, None)
23+
node2.name = 'inf'
24+
node2.children = []
25+
self.assertEqual([node, node1, node2], actual)
2326

2427
def test_bfs1(self):
2528
actual = graph.bfs([])

utbot-python/samples/cli_utbot_tests/generated_tests__lists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TestTopLevelFunctions(unittest.TestCase):
1010
# region Test suites for executable lists.find_articles_with_author
1111
# region
1212
def test_find_articles_with_author(self):
13-
actual = lists.find_articles_with_author([lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(b'\x80'), datetime.datetime(2014, 11, 2, 1, 30)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(id), datetime.datetime(1, 1, 1)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(b'\x80'), datetime.datetime(2014, 11, 2, 1, 30)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(b'\x80'), datetime.datetime(2014, 11, 2, 1, 30)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(-1234567890), datetime.datetime(1, 2, 3, 4, 5, 6, 7)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(-123456789), datetime.datetime(2011, 1, 1)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(), datetime.datetime(2014, 11, 2, 1, 30))], str('unicode remains unicode'))
13+
actual = lists.find_articles_with_author([lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(b'\x80'), datetime.datetime(2014, 11, 2, 1, 30)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str(1.5 + 3.5j), datetime.datetime(2014, 11, 2, 1, 30)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str('unicode remains unicode'), datetime.datetime(2011, 1, 1)), lists.Article(str(-123456789), str(b'\xf0\xa3\x91\x96', 'utf-8'), str('unicode remains unicode'), datetime.datetime(2011, 1, 1))], str('unicode remains unicode'))
1414

1515
self.assertEqual([], actual)
1616

utbot-python/samples/cli_utbot_tests/generated_tests__longest_subsequence.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ class TestTopLevelFunctions(unittest.TestCase):
99
# region Test suites for executable longest_subsequence.longest_subsequence
1010
# region
1111
def test_longest_subsequence(self):
12-
actual = longest_subsequence.longest_subsequence([1, 0, 83, 1, 1])
12+
actual = longest_subsequence.longest_subsequence([1, -1])
1313

14-
self.assertEqual([0, 1, 1], actual)
14+
self.assertEqual([-1], actual)
15+
16+
def test_longest_subsequence1(self):
17+
actual = longest_subsequence.longest_subsequence([1, 0, -3, 0, 1])
18+
19+
self.assertEqual([0, 0, 1], actual)
20+
21+
def test_longest_subsequence2(self):
22+
actual = longest_subsequence.longest_subsequence([0, 2, 123])
23+
24+
self.assertEqual([0, 2, 123], actual)
1525

1626
# endregion
1727

utbot-python/samples/cli_utbot_tests/generated_tests__matrix.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class TestMatrix(unittest.TestCase):
1111
# region Test suites for executable matrix.__add__
1212
# region
1313
def test__add__(self):
14-
matrix1 = matrix.Matrix([[7.3, float(314), 7.3, 7.3, 0.0, 7.3], [float(10 ** 23)], [float('1.4')], [float(-1), float(10 ** 23), float(-1), float('nan'), 7.3], [float(-1), float('+infinity'), float(10 ** 23), float(-1), 0.0], [float(314), float('+infinity'), float(-1), float('nan'), float(10 ** 23)], [float(10 ** 23)]])
15-
self1 = matrix.Matrix([[7.3, float(314), 7.3, 7.3, 0.0, 7.3], [float(10 ** 23)], [float('1.4')], [float(-1), float(10 ** 23), float(-1), float('nan'), 7.3], [float(-1), float('+infinity'), float(10 ** 23), float(-1), 0.0], [float(314), float('+infinity'), float(-1), float('nan'), float(10 ** 23)], [float(10 ** 23)]])
14+
matrix1 = matrix.Matrix([[float(314), 7.3], [float(314), float(314), float(10 ** 23), float(10 ** 23), float('nan'), float('+infinity'), float(10 ** 23)], [float('+infinity'), float(10 ** 23), 7.3], [float(-1), 0.0]])
15+
self1 = matrix.Matrix([[float(314), 7.3], [float(314), float(314), float(10 ** 23), float(10 ** 23), float('nan'), float('+infinity'), float(10 ** 23)], [float('+infinity'), float(10 ** 23), 7.3], [float(-1), 0.0]])
1616

1717
actual = matrix1.__add__(self1)
1818

1919
matrix2 = copyreg._reconstructor(matrix.Matrix, builtins.object, None)
20-
matrix2.elements = [[14.6, 628.0, 14.6, 14.6, 0.0, 14.6], [2e+23], [2.8], [-2.0, 2e+23, -2.0, float('nan'), 14.6], [-2.0, float('inf'), 2e+23, -2.0, 0.0], [628.0, float('inf'), -2.0, float('nan'), 2e+23], [2e+23]]
21-
matrix2.dim = (7, 6)
20+
matrix2.elements = [[628.0, 14.6], [628.0, 628.0, 2e+23, 2e+23, float('nan'), float('inf'), 2e+23], [float('inf'), 2e+23, 14.6], [-2.0, 0.0]]
21+
matrix2.dim = (4, 2)
2222
self.assertEqual(matrix2, actual)
2323

2424
# endregion
@@ -39,7 +39,7 @@ def test__mul__(self):
3939

4040
def test__mul__throws_t(self):
4141
matrix1 = matrix.Matrix([])
42-
self1 = matrix.Matrix([[0.0, float('nan'), float('+infinity'), float(-1), float('1.4'), float('+infinity')]])
42+
self1 = matrix.Matrix([[float('nan'), float(10 ** 23), float('1.4'), float('nan'), float(314)], [float('+infinity'), float(314), float(10 ** 23)], [float(1970)], [0.0, float('nan'), float(314), float(1970), float('1.4'), float(-1)], [float(1970)]])
4343

4444
matrix1.__mul__(self1)
4545

utbot-python/samples/cli_utbot_tests/generated_tests__quick_sort.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class TestTopLevelFunctions(unittest.TestCase):
99
# region Test suites for executable quick_sort.quick_sort
1010
# region
1111
def test_quick_sort(self):
12-
actual = quick_sort.quick_sort([83, -3, -3, 1])
12+
actual = quick_sort.quick_sort([4294967296, 0, 1, 123, 0, (1 << 100)])
1313

14-
self.assertEqual([-3, -3, 1, 83], actual)
14+
self.assertEqual([0, 0, 1, 123, 4294967296, 1267650600228229401496703205376], actual)
1515

1616
def test_quick_sort1(self):
17-
actual = quick_sort.quick_sort([1, 1])
17+
actual = quick_sort.quick_sort([0, 0, 1])
1818

19-
self.assertEqual([1, 1], actual)
19+
self.assertEqual([0, 0, 1], actual)
2020

2121
def test_quick_sort2(self):
2222
actual = quick_sort.quick_sort([])
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sys
2+
sys.path.append('samples')
3+
import unittest
4+
import builtins
5+
import test_coverage
6+
7+
8+
class TestTopLevelFunctions(unittest.TestCase):
9+
# region Test suites for executable test_coverage.hard_function
10+
# region
11+
def test_hard_function(self):
12+
actual = test_coverage.hard_function(83)
13+
14+
self.assertEqual(2, actual)
15+
16+
def test_hard_function1(self):
17+
actual = test_coverage.hard_function(0)
18+
19+
self.assertEqual(1, actual)
20+
21+
def test_hard_function2(self):
22+
actual = test_coverage.hard_function(4294967296)
23+
24+
self.assertEqual(3, actual)
25+
26+
def test_hard_function3(self):
27+
actual = test_coverage.hard_function(float('nan'))
28+
29+
self.assertEqual(4, actual)
30+
31+
# endregion
32+
33+
# endregion
34+
35+
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# Usage:
2-
# ./generate_test_samples.sh <absolute_python_path>
3-
4-
python_path=$0
1+
python_path=/home/vyacheslav/Desktop/utbot/UTBotJava/utbot-python/samples/venv/bin/python
52

63
java -jar utbot-cli.jar generate_python samples/arithmetic.py -p $python_path -o cli_utbot_tests/generated_tests__arithmetic.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
74
java -jar utbot-cli.jar generate_python samples/deep_equals.py -p $python_path -o cli_utbot_tests/generated_tests__deep_equals.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
@@ -12,5 +9,5 @@ java -jar utbot-cli.jar generate_python samples/matrix.py -p $python_path -o cli
129
java -jar utbot-cli.jar generate_python samples/primitive_types.py -p $python_path -o cli_utbot_tests/generated_tests__primitive_types.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
1310
java -jar utbot-cli.jar generate_python samples/quick_sort.py -p $python_path -o cli_utbot_tests/generated_tests__quick_sort.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
1411
java -jar utbot-cli.jar generate_python samples/test_coverage.py -p $python_path -o cli_utbot_tests/generated_tests__test_coverage.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
15-
java -jar utbot-cli.jar generate_python samples/type_inhibition.py -p $python_path -o cli_utbot_tests/generated_tests__type_inhibition.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
12+
java -jar utbot-cli.jar generate_python samples/type_inference.py -p $python_path -o cli_utbot_tests/generated_tests__type_inference.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000
1613
java -jar utbot-cli.jar generate_python samples/using_collections.py -p $python_path -o cli_utbot_tests/generated_tests__using_collections.py -s samples/ --timeout-for-run 500 --visit-only-specified-source --timeout 10000

utbot-python/samples/run_test_samples.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_t
1212
java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__primitive_types.py -p $python_path
1313
java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__quick_sort.py -p $python_path
1414
java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__test_coverage.py -p $python_path
15-
java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__type_inhibition.py -p $python_path
15+
java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__type_inference.py -p $python_path
1616
java -jar utbot-cli.jar --verbosity DEBUG run_python cli_utbot_tests/generated_tests__using_collections.py -p $python_path

0 commit comments

Comments
 (0)