本文整理汇总了Python中SortingStudy.Sortings类的典型用法代码示例。如果您正苦于以下问题:Python Sortings类的具体用法?Python Sortings怎么用?Python Sortings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sortings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sort_desc_bubble_load_test
def test_sort_desc_bubble_load_test(self):
"""
Expected result: The timing should not exceed following numbers:
1 4.05311584473e-06
1001 0.4536049366
2001 1.79013895988
3001 3.99529099464
4001 7.08103489876
5001 11.0427498817
6001 15.9283699989
7001 21.6802170277
8001 28.3089148998
9001 35.8479449749
"""
i = 1
while i < 10000:
sortings = Sortings(i)
start = time.time()
sortings.sort_desc_bubble()
end = time.time()
print i, end - start
i += 1000
示例2: test_sort_asc_heap_sort_load_test
def test_sort_asc_heap_sort_load_test(self):
i = 1
while i < 10000:
sortings = Sortings(i)
start = time.time()
sortings.sort_asc_heap_sort()
end = time.time()
print i, end - start
i += 1000
示例3: test_calculate_total_product__if_one_positive_value__returns_this_value
def test_calculate_total_product__if_one_positive_value__returns_this_value(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with one positive value
3. Call calculate_total_product()
Expected result: This value returned
"""
sortings = Sortings()
sortings.list = [11]
actual_result = sortings.calculate_total_product()
self.assertEqual(11, actual_result)
示例4: test_calculate_total__total_is_calculated
def test_calculate_total__total_is_calculated(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with int values
3. Call calculate_total()
Expected result: Total of int values returned
"""
sortings = Sortings()
sortings.list = [20202, 1, 2, 3]
actual_result = sortings.calculate_total()
self.assertEqual(20208, actual_result)
示例5: test__find_minimum__if_float_values__returns_minimum
def test__find_minimum__if_float_values__returns_minimum(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with float values
3. Call find_minimum()
Expected result: The minimal value returned
"""
sortings = Sortings()
sortings.list = [0.333, 0, 1 / 3, 1.0 / 3.0]
actual_result = sortings.find_minimum()
self.assertEqual(0, actual_result)
示例6: test__find_minimum__if_negative_values__returns_minimum
def test__find_minimum__if_negative_values__returns_minimum(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with negative values
3. Call find_minimum()
Expected result: The minimal negative value returned
"""
sortings = Sortings()
sortings.list = [-2, 2, -1, 0]
actual_result = sortings.find_minimum()
self.assertEqual(-2, actual_result)
示例7: test_calculate_total_product__if_0_among_values__returns_0
def test_calculate_total_product__if_0_among_values__returns_0(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with positive values and 0
3. Call calculate_total_product()
Expected result: 0 returned
"""
sortings = Sortings()
sortings.list = [2, 10, 3, 0]
actual_result = sortings.calculate_total_product()
self.assertEqual(0, actual_result)
示例8: test__find_maximum__if_all_values_are_identical__returns_one_value
def test__find_maximum__if_all_values_are_identical__returns_one_value(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with equal values
3. Call find_maximum()
Expected result: Single initialized value returned
"""
sortings = Sortings()
sortings.list = [2, 2, 2, 2, 2, 2]
actual_result = sortings.find_maximum()
self.assertEqual(2, actual_result)
示例9: test_sort_asc_bubble__if_mixed_int_values__returns_list_sorted_asc
def test_sort_asc_bubble__if_mixed_int_values__returns_list_sorted_asc(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with mix of negative and non-negative int values
3. Call sort_asc_bubble()
Expected result: This list sorted asc returned
"""
sortings = Sortings()
sortings.list = [-1, -600, 564, -3224, 333, -208, 34, 1, 0]
actual_result = sortings.sort_asc_bubble()
self.assertEqual([-3224, -600, -208, -1, 0, 1, 34, 333, 564], actual_result)
示例10: test_sort_asc_bubble__if_equal_values__returns_this_list
def test_sort_asc_bubble__if_equal_values__returns_this_list(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with equal values
3. Call sort_asc_v()
Expected result: Same list returned
"""
sortings = Sortings()
sortings.list = [2, 2, 2, 2, 2, 2]
actual_result = sortings.sort_asc_bubble()
self.assertEqual([2, 2, 2, 2, 2, 2], actual_result)
示例11: test__calculate_total__if_float_values__returns_total
def test__calculate_total__if_float_values__returns_total(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with float values and float resulting expressions
3. Call calculate_total()
Expected result: Correct total returned
"""
sortings = Sortings()
sortings.list = [0.333, 0, 1 / 3, 1.0 / 3.0]
actual_result = sortings.calculate_total()
self.assertEqual(0.6663333333333333, actual_result)
示例12: test_sort_asc_bubble__if_negative_values__returns_list_sorted_asc
def test_sort_asc_bubble__if_negative_values__returns_list_sorted_asc(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with negative int values
3. Call sort_asc_bubble()
Expected result: This list sorted asc returned
"""
sortings = Sortings()
sortings.list = [-5098, -6000, -564, -324, -13, -28, -45, -1]
actual_result = sortings.sort_asc_bubble()
self.assertEqual([-6000, -5098, -564, -324, -45, -28, -13, -1], actual_result)
示例13: test_calculate_total_product__if_3_negative_values__returns_negative_product
def test_calculate_total_product__if_3_negative_values__returns_negative_product(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with mix of negative and positive values
3. Call calculate_total_product()
Expected result: Correct total returned
"""
sortings = Sortings()
sortings.list = [-2, -10, -3]
actual_result = sortings.calculate_total_product()
self.assertEqual(-60, actual_result)
示例14: test_sort_desc_bubble__if_non_negative_values__returns_list_sorted_desc
def test_sort_desc_bubble__if_non_negative_values__returns_list_sorted_desc(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with non_negative int values
3. Call sort_desc_bubble()
Expected result: This list sorted desc returned
"""
sortings = Sortings()
sortings.list = [5098, 6000, 564, 324, 0, 13, 28, 45, 1]
actual_result = sortings.sort_desc_bubble()
self.assertEqual([6000, 5098, 564, 324, 45, 28, 13, 1, 0], actual_result)
示例15: test_calculate_total_product__returns_total_product
def test_calculate_total_product__returns_total_product(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with int values
3. Call calculate_total_product()
Expected result: Correct value of total product returned
"""
sortings = Sortings()
sortings.list = [444, 1, 2, 3]
actual_result = sortings.calculate_total_product()
self.assertEqual(2664, actual_result)