def test_border_cases(self): n = random.randrange(1, (10 ^ 3) + 1) a = list() b = list() for i in range(0, n): a.append(random.randrange(-(10 ^ 5), 10 ^ 5)) b.append(random.randrange(-(10 ^ 5), 10 ^ 5)) print(a) print(b) print(max_dot_product(a, b))
def test_max_dot_product_2(): assert (max_dot_product([1, 3, -5], [-2, 4, 1]) == 23)
def test_max_dot_product_1(): assert (max_dot_product([23], [39]) == 897)
from dot_product import max_dot_product from test.asserts import assert_equal """ Sample 1. Input: 1 23 39 Output: 897 897 = 23 · 39. Sample 2. Input: 3 1 3 -5 -2 4 1 Output: 23 23 = 3 · 4 + 1 · 1 + (−5) · (−2). """ assert_equal(897, max_dot_product([23], [39]), "sample 1") assert_equal(23, max_dot_product([1, 3, -5], [-2, 4, 1]), "sample 2")
from random import randint import os import sys from dot_product import max_dot_product os.system("javac DotProduct.java") for i in range(100): n = randint(1, 100) arr1, arr2 = [], [] for j in range(n): arr1.append(randint(-100, 100)) arr2.append(randint(-100, 100)) str1 = ' '.join(str(e) for e in arr1) str2 = ' '.join(str(e) for e in arr2) os.system('echo "{} {} {}" > input.txt'.format(n, str1, str2)) os.system("java DotProduct < input.txt") file = open("out.txt", "r") input = int(file.read()) resultP = max_dot_product(arr1, arr2) if resultP == input: print("YES") else: print("NO {} {} rjava={} rpy={}".format(arr1, arr2, input, resultP)) break
def test_max_dot_product(a, b, expected): assert max_dot_product(a, b) == expected
def test_with_negative(self): self.assertEqual(23, max_dot_product([1, 3, -5], [-2, 4, 1]))
def test_single(self): self.assertEqual(897, max_dot_product([23], [39]))