MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / main

Function main

example_code/item_095/my_library/my_library_test.c:23–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23int main(int argc, char** argv) {
24 {
25 double a[] = {3, 4, 5};
26 double b[] = {-1, 9, -2.5};
27 double found = dot_product(3, a, b);
28 double expected = 20.5;
29 printf("Found %f, Expected %f\n", found, expected);
30 assert(fabs(found - expected) < 0.01);
31 }
32
33 {
34 double a[] = {0, 0, 0};
35 double b[] = {1, 1, 1};
36 double found = dot_product(3, a, b);
37 double expected = 0;
38 printf("Found %f, Expected %f\n", found, expected);
39 assert(fabs(found - expected) < 0.01);
40 }
41
42 {
43 double a[] = {-1, -1, -1};
44 double b[] = {1, 1, 1};
45 double found = dot_product(3, a, b);
46 double expected = -3;
47 printf("Found %f, Expected %f\n", found, expected);
48 assert(fabs(found - expected) < 0.01);
49 }
50
51 return 0;
52}

Callers

nothing calls this directly

Calls 1

dot_productFunction · 0.70

Tested by

no test coverage detected