The same for DM_COST_REFS references, written in product code, to an * operator that only test code declares -- `overloads` times over. */
| 8462 | /* The same for DM_COST_REFS references, written in product code, to an |
| 8463 | * operator that only test code declares -- `overloads` times over. */ |
| 8464 | static uint64_t dm_operator_work(int overloads) { |
| 8465 | char *src = malloc(DM_COST_TEXT * 4); |
| 8466 | size_t cap = DM_COST_TEXT * 4; |
| 8467 | char tmp[256]; |
| 8468 | snprintf(tmp, sizeof(tmp), "/tmp/cbm_dm_opcost_XXXXXX"); |
| 8469 | if (!src || !cbm_mkdtemp(tmp)) { |
| 8470 | free(src); |
| 8471 | return 0; |
| 8472 | } |
| 8473 | th_write_file(TH_PATH(tmp, "src/Vec.cs"), |
| 8474 | "namespace Geo\n{\n public partial struct Vec { }\n}\n"); |
| 8475 | size_t w = |
| 8476 | (size_t)snprintf(src, cap, "namespace Geo\n{\n public partial struct Vec\n {\n"); |
| 8477 | for (int i = 0; i < overloads; i++) { |
| 8478 | w += (size_t)snprintf( |
| 8479 | src + w, cap - w, |
| 8480 | " public static Vec operator +(Vec a, P%03d b) { return a; }\n", i); |
| 8481 | } |
| 8482 | snprintf(src + w, cap - w, " }\n}\n"); |
| 8483 | th_write_file(TH_PATH(tmp, "tests/VecOps.cs"), src); |
| 8484 | w = (size_t)snprintf(src, cap, "namespace Geo\n{\n /// <summary>"); |
| 8485 | for (int i = 0; i < DM_COST_REFS; i++) { |
| 8486 | w += (size_t)snprintf(src + w, cap - w, "<see cref=\"Vec.operator +(Vec, P%03d)\"/> ", i); |
| 8487 | } |
| 8488 | snprintf(src + w, cap - w, "</summary>\n public class Uses { }\n}\n"); |
| 8489 | th_write_file(TH_PATH(tmp, "src/Uses.cs"), src); |
| 8490 | free(src); |
| 8491 | char db[512]; |
| 8492 | snprintf(db, sizeof(db), "%s/cost.db", tmp); |
| 8493 | cbm_doclink_cs_test_work_reset(); |
| 8494 | uint64_t work = dm_index(tmp, db, NULL) == 0 ? cbm_doclink_cs_test_work() : 0; |
| 8495 | int rows = dm_count(db, "SELECT COUNT(*) FROM doc_link_unresolved WHERE reason = 'missing'"); |
| 8496 | dm_unlink_db(db); |
| 8497 | th_rmtree(tmp); |
| 8498 | return rows == DM_COST_REFS ? work : 0; /* product code sees none of them */ |
| 8499 | } |
| 8500 | |
| 8501 | /* The same for DM_COST_REFS references `Big.M(int)` to a method with 100 |
| 8502 | * overloads of `params` parameters each: none takes one parameter. */ |
no test coverage detected