Coverage(test) - First batch of test function & coverage

This commit is contained in:
Dandaedre 2023-03-01 04:16:59 +01:00
parent c0aafa15bd
commit 4321cb1a6a
29 changed files with 25398 additions and 3 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ expected_values.md
releases/*
.whl
pyinstaller_log.txt
llvm/*
# Byte-compiled / optimized / DLL files
__pycache__/

44
Cargo.lock generated
View File

@ -63,6 +63,22 @@ dependencies = [
"os_str_bytes",
]
[[package]]
name = "ctor"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "diff"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
[[package]]
name = "errno"
version = "0.2.8"
@ -192,6 +208,15 @@ version = "6.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
[[package]]
name = "output_vt100"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
dependencies = [
"winapi",
]
[[package]]
name = "parking_lot"
version = "0.12.1"
@ -215,6 +240,18 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "pretty_assertions"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
dependencies = [
"ctor",
"diff",
"output_vt100",
"yansi",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@ -557,9 +594,16 @@ version = "0.1.5"
dependencies = [
"clap",
"lazy_static",
"pretty_assertions",
"pyo3",
"strum",
"strum_macros",
"threadpool",
"toml",
]
[[package]]
name = "yansi"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"

View File

@ -27,6 +27,9 @@ pyo3 = { version = "0.18.0", features = ["extension-module"] }
# [build]
# target = ["x86_64-unknown-linux-gnu", "x86_64-unknown-windows-gnu"]
[dev-dependencies]
pretty_assertions = "1"
[profile.release]
panic = 'abort'
opt-level = 3

View File

@ -23,6 +23,16 @@ install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]
[tasks.testcov]
script_runner = "@shell"
ignore_errors = true
script = [
"mkdir -p coverage",
"mkdir -p coverage/html",
"CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='llvm/cargo-test-%p-%m.profraw' cargo test",
"grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore '/*' -o coverage/html/"
]
[tasks.clean]
command = "cargo"
args = ["clean"]

View File

@ -4,6 +4,9 @@ A rust program for solving FFXIV craft recipe.
Originaly written by [RikaKagurasaka](https://github.com/RikaKagurasaka/xiv_craft_solver),
it now is widely improved and provides python bindings for a GUI (or anything else really)
![coverage/html/badges/flat.svg](coverage/html/badges/flat.svg)
### Basic RUST CLI Usage
Everything is done through the regular cargo interface
1. Download the latest release.
@ -43,6 +46,7 @@ Options:
-V, --version
Print version
```
## Developpement
Please remember to set and use a venv before building
While not mandatory, using ``cargo-make`` will provide you with the commands:

View File

@ -0,0 +1,23 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 10%">
<title>coverage: 10%</title>
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<clipPath id="r">
<rect width="96" height="20" rx="3" fill="#fff"/>
</clipPath>
<g clip-path="url(#r)">
<rect width="61" height="20" fill="#555"/>
<rect x="61" width="35" height="20" fill="#e05d44"/>
<rect width="96" height="20" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text>
<text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
<text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">10%</text>
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">10%</text>
</g>
<script xmlns=""/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 10%">
<title>coverage: 10%</title>
<g shape-rendering="crispEdges">
<rect width="61" height="20" fill="#555"/>
<rect x="61" width="35" height="20" fill="#e05d44"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">10%</text>
</g>
<script xmlns=""/>
</svg>

After

Width:  |  Height:  |  Size: 712 B

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="142.5" height="28" role="img" aria-label="COVERAGE: 10%">
<title>COVERAGE: 10%</title>
<g shape-rendering="crispEdges">
<rect width="91" height="28" fill="#555"/>
<rect x="91" width="51.5" height="28" fill="#e05d44"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100">
<text fill="#fff" x="455" y="175" transform="scale(.1)" textLength="670">COVERAGE</text>
<text fill="#fff" x="1167.5" y="175" font-weight="bold" transform="scale(.1)" textLength="275">10%</text>
</g>
<script xmlns=""/>
</svg>

After

Width:  |  Height:  |  Size: 739 B

View File

@ -0,0 +1,25 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="18" role="img" aria-label="coverage: 10%">
<title>coverage: 10%</title>
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#fff" stop-opacity=".7"/>
<stop offset=".1" stop-color="#aaa" stop-opacity=".1"/>
<stop offset=".9" stop-color="#000" stop-opacity=".3"/>
<stop offset="1" stop-color="#000" stop-opacity=".5"/>
</linearGradient>
<clipPath id="r">
<rect width="96" height="18" rx="4" fill="#fff"/>
</clipPath>
<g clip-path="url(#r)">
<rect width="61" height="18" fill="#555"/>
<rect x="61" width="35" height="18" fill="#e05d44"/>
<rect width="96" height="18" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text aria-hidden="true" x="315" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text>
<text x="315" y="130" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
<text aria-hidden="true" x="775" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">10%</text>
<text x="775" y="130" transform="scale(.1)" fill="#fff" textLength="250">10%</text>
</g>
<script xmlns=""/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,27 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="99" height="20" role="img" aria-label="Coverage: 10%">
<title>Coverage: 10%</title>
<style>a:hover #llink{fill:url(#b);stroke:#ccc}a:hover #rlink{fill:#4183c4}</style>
<linearGradient id="a" x2="0" y2="100%">
<stop offset="0" stop-color="#fcfcfc" stop-opacity="0"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#ccc" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<g stroke="#d5d5d5">
<rect stroke="none" fill="#fcfcfc" x="0.5" y="0.5" width="61" height="19" rx="2"/>
<rect x="67.5" y="0.5" width="31" height="19" rx="2" fill="#fafafa"/>
<rect x="67" y="7.5" width="0.5" height="5" stroke="#fafafa"/>
<path d="M67.5 6.5 l-3 3v1 l3 3" stroke="d5d5d5" fill="#fafafa"/>
</g>
<g aria-hidden="true" fill="#333" text-anchor="middle" font-family="Helvetica Neue,Helvetica,Arial,sans-serif" text-rendering="geometricPrecision" font-weight="700" font-size="110px" line-height="14px">
<rect id="llink" stroke="#d5d5d5" fill="url(#a)" x=".5" y=".5" width="61" height="19" rx="2"/>
<text aria-hidden="true" x="305" y="150" fill="#fff" transform="scale(.1)" textLength="510">Coverage</text>
<text x="305" y="140" transform="scale(.1)" textLength="510">Coverage</text>
<text aria-hidden="true" x="825" y="150" fill="#fff" transform="scale(.1)" textLength="230">10%</text>
<text id="rlink" x="825" y="140" transform="scale(.1)" textLength="230">10%</text>
</g>
<script xmlns=""/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1 @@
{"schemaVersion":1,"label":"coverage","message":"10%","color":"red"}

129
coverage/html/index.html Normal file
View File

@ -0,0 +1,129 @@
<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grcov report - top_level </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"></head>
<body>
<div class="container">
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
<ul><li class="is-active"><a href="#">top_level</a></li>
</ul>
</nav>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Lines</p>
<p class="title has-text-danger">
<abbr title="118 / 1124">10.5 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Functions</p>
<p class="title has-text-danger">
<abbr title="32 / 347">9.22 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Branches</p>
<p class="title has-text-success">
<abbr title="0 / 0">100 %</abbr></p>
</div>
</div>
</nav>
<table class="table is-fullwidth">
<thead>
<tr>
<th>Directory</th>
<th class="has-text-centered" colspan="3">Line Coverage</th>
<th class="has-text-centered" colspan="2">Functions</th>
<th class="has-text-centered" colspan="2">Branches</th>
</tr>
</thead>
<tbody><tr>
<th><a href="src&#x2F;index.html">src</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="10.838831291234683"
max="100">
10.84%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
10.84%
</td>
<td class="has-text-centered has-background-danger p-2">
115 / 1061
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">8.53%</td>
<td class="has-text-centered has-background-danger p-2">29 / 340 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="src&#x2F;bin&#x2F;index.html">src&#x2F;bin</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="1.639344262295082"
max="100">
1.64%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
1.64%
</td>
<td class="has-text-centered has-background-danger p-2">
1 / 61
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">20%</td>
<td class="has-text-centered has-background-danger p-2">1 / 5 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="tests&#x2F;index.html">tests</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-success is-large"
value="100"
max="100">
100%
</progress>
</td>
<td class="has-text-centered has-background-success p-2">
100%
</td>
<td class="has-text-centered has-background-success p-2">
2 / 2
</td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">2 / 2 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
</tbody>
</table></div>
<footer class="footer">
<div class="content has-text-centered">
<p class="heading">Date: 2023-03-01 03:16</p>
</div>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grcov report - src&#x2F;bin </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"></head>
<body>
<div class="container">
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
<ul><li><a href="../index.html">top_level</a></li><li class="is-active"><a href="#">src&#x2F;bin</a></li>
</ul>
</nav>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Lines</p>
<p class="title has-text-danger">
<abbr title="1 / 61">1.64 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Functions</p>
<p class="title has-text-danger">
<abbr title="1 / 5">20 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Branches</p>
<p class="title has-text-success">
<abbr title="0 / 0">100 %</abbr></p>
</div>
</div>
</nav>
<table class="table is-fullwidth">
<thead>
<tr>
<th>File</th>
<th class="has-text-centered" colspan="3">Line Coverage</th>
<th class="has-text-centered" colspan="2">Functions</th>
<th class="has-text-centered" colspan="2">Branches</th>
</tr>
</thead>
<tbody><tr>
<th><a href="xiv_csolver.rs.html">xiv_csolver.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="1.639344262295082"
max="100">
1.64%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
1.64%
</td>
<td class="has-text-centered has-background-danger p-2">
1 / 61
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">20%</td>
<td class="has-text-centered has-background-danger p-2">1 / 5 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
</tbody>
</table></div>
<footer class="footer">
<div class="content has-text-centered">
<p class="heading">Date: 2023-03-01 03:16</p>
</div>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,201 @@
<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grcov report - src </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"></head>
<body>
<div class="container">
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
<ul><li><a href="../index.html">top_level</a></li><li class="is-active"><a href="#">src</a></li>
</ul>
</nav>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Lines</p>
<p class="title has-text-danger">
<abbr title="115 / 1061">10.84 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Functions</p>
<p class="title has-text-danger">
<abbr title="29 / 340">8.53 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Branches</p>
<p class="title has-text-success">
<abbr title="0 / 0">100 %</abbr></p>
</div>
</div>
</nav>
<table class="table is-fullwidth">
<thead>
<tr>
<th>File</th>
<th class="has-text-centered" colspan="3">Line Coverage</th>
<th class="has-text-centered" colspan="2">Functions</th>
<th class="has-text-centered" colspan="2">Branches</th>
</tr>
</thead>
<tbody><tr>
<th><a href="action.rs.html">action.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="0"
max="100">
0%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
0%
</td>
<td class="has-text-centered has-background-danger p-2">
0 / 239
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">0%</td>
<td class="has-text-centered has-background-danger p-2">0 / 36 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="craft.rs.html">craft.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="0"
max="100">
0%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
0%
</td>
<td class="has-text-centered has-background-danger p-2">
0 / 102
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">0%</td>
<td class="has-text-centered has-background-danger p-2">0 / 14 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="io.rs.html">io.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="53.77358490566038"
max="100">
53.77%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
53.77%
</td>
<td class="has-text-centered has-background-danger p-2">
114 / 212
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">13.4%</td>
<td class="has-text-centered has-background-danger p-2">28 / 209 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="lib.rs.html">lib.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="0.43478260869565216"
max="100">
0.43%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
0.43%
</td>
<td class="has-text-centered has-background-danger p-2">
1 / 230
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">4.76%</td>
<td class="has-text-centered has-background-danger p-2">1 / 21 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="solver.rs.html">solver.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="0"
max="100">
0%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
0%
</td>
<td class="has-text-centered has-background-danger p-2">
0 / 203
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">0%</td>
<td class="has-text-centered has-background-danger p-2">0 / 12 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="specs.rs.html">specs.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-danger is-large"
value="0"
max="100">
0%
</progress>
</td>
<td class="has-text-centered has-background-danger p-2">
0%
</td>
<td class="has-text-centered has-background-danger p-2">
0 / 75
</td>
<!-- -->
<td class="has-text-centered has-background-danger p-2">0%</td>
<td class="has-text-centered has-background-danger p-2">0 / 48 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
</tbody>
</table></div>
<footer class="footer">
<div class="content has-text-centered">
<p class="heading">Date: 2023-03-01 03:16</p>
</div>
</footer>
</body>
</html>

5296
coverage/html/src/io.rs.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,105 @@
<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grcov report - tests </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"></head>
<body>
<div class="container">
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
<ul><li><a href="../index.html">top_level</a></li><li class="is-active"><a href="#">tests</a></li>
</ul>
</nav>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Lines</p>
<p class="title has-text-success">
<abbr title="2 / 2">100 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Functions</p>
<p class="title has-text-success">
<abbr title="2 / 2">100 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Branches</p>
<p class="title has-text-success">
<abbr title="0 / 0">100 %</abbr></p>
</div>
</div>
</nav>
<table class="table is-fullwidth">
<thead>
<tr>
<th>File</th>
<th class="has-text-centered" colspan="3">Line Coverage</th>
<th class="has-text-centered" colspan="2">Functions</th>
<th class="has-text-centered" colspan="2">Branches</th>
</tr>
</thead>
<tbody><tr>
<th><a href="io.rs.html">io.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-success is-large"
value="100"
max="100">
100%
</progress>
</td>
<td class="has-text-centered has-background-success p-2">
100%
</td>
<td class="has-text-centered has-background-success p-2">
1 / 1
</td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">1 / 1 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
<tr>
<th><a href="lib.rs.html">lib.rs</a></th>
<!-- -->
<td class="p-2">
<progress
class="progress is-success is-large"
value="100"
max="100">
100%
</progress>
</td>
<td class="has-text-centered has-background-success p-2">
100%
</td>
<td class="has-text-centered has-background-success p-2">
1 / 1
</td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">1 / 1 </td>
<!-- -->
<td class="has-text-centered has-background-success p-2">100%</td>
<td class="has-text-centered has-background-success p-2">0 / 0</td>
</tr>
</tbody>
</table></div>
<footer class="footer">
<div class="content has-text-centered">
<p class="heading">Date: 2023-03-01 03:16</p>
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grcov report - io.rs </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"></head>
<body>
<div class="container">
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
<ul><li><a href="../index.html">top_level</a></li><li><a href="./index.html">tests</a></li><li class="is-active"><a href="#">io.rs</a></li>
</ul>
</nav>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Lines</p>
<p class="title has-text-success">
<abbr title="1 / 1">100 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Functions</p>
<p class="title has-text-success">
<abbr title="1 / 1">100 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Branches</p>
<p class="title has-text-success">
<abbr title="0 / 0">100 %</abbr></p>
</div>
</div>
</nav>
<div role="table" aria-label="Coverage report"><div class="columns p-0 m-0" role="row">
<div
class="column is-1 is-narrow p-0 has-text-centered"
id="1"
role="cell">
<a href="#1">1</a>
</div>
<div
class="column is-1 is-narrow p-0 has-text-centered has-text-success-light has-background-success"
role="cell" aria-label="10">
10
</div>
<div class="column has-background-success-light p-0"
role="cell">
<pre class="has-background-success-light py-0 px-2"></pre>
</div>
</div></div>
</div>
<footer class="footer">
<div class="content has-text-centered">
<p class="heading">Date: 2023-03-01 03:16</p>
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grcov report - lib.rs </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css"></head>
<body>
<div class="container">
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
<ul><li><a href="../index.html">top_level</a></li><li><a href="./index.html">tests</a></li><li class="is-active"><a href="#">lib.rs</a></li>
</ul>
</nav>
<nav class="level">
<div class="level-item has-text-centered">
<div>
<p class="heading">Lines</p>
<p class="title has-text-success">
<abbr title="1 / 1">100 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Functions</p>
<p class="title has-text-success">
<abbr title="1 / 1">100 %</abbr></p>
</div>
</div>
<div class="level-item has-text-centered">
<div>
<p class="heading">Branches</p>
<p class="title has-text-success">
<abbr title="0 / 0">100 %</abbr></p>
</div>
</div>
</nav>
<div role="table" aria-label="Coverage report"><div class="columns p-0 m-0" role="row">
<div
class="column is-1 is-narrow p-0 has-text-centered"
id="1"
role="cell">
<a href="#1">1</a>
</div>
<div
class="column is-1 is-narrow p-0 has-text-centered has-text-success-light has-background-success"
role="cell" aria-label="10">
10
</div>
<div class="column has-background-success-light p-0"
role="cell">
<pre class="has-background-success-light py-0 px-2"></pre>
</div>
</div></div>
</div>
<footer class="footer">
<div class="content has-text-centered">
<p class="heading">Date: 2023-03-01 03:16</p>
</div>
</footer>
</body>
</html>

View File

@ -1,4 +1,5 @@
// #![warn(missing_docs,unsafe_code,unstable_features,)]
// #![feature(no_coverage)]
use clap::Parser;
use std::time::Instant;

View File

@ -85,9 +85,8 @@ pub struct SolverResult {
/// Pretty display for SolverResult
impl Display for SolverResult {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
println!("{:?}", self.actions);
Ok(())
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{:?}", self.actions)
}
}
@ -238,3 +237,92 @@ pub fn solve_from_python(values: &PyAny) -> PyResult<Option<Vec<SolverResult>>>
let res = solve_craft(recipe, stats, param);
Ok(res)
}
#[cfg(test)]
mod tests {
use crate::io::Args;
use crate::{Parameters, SolverResult};
use pretty_assertions::{assert_eq, assert_ne};
use clap::Parser;
impl PartialEq for Parameters {
fn eq(&self, rhs: &Parameters) -> bool {
(self.byregot_step == rhs.byregot_step)
& (self.depth == rhs.depth)
& (self.desperate == rhs.desperate)
& (self.threads == rhs.threads)
}
}
#[test]
pub fn test_parameters_derived_attributes() {
let def = Parameters {
byregot_step: 0,
depth: 0,
desperate: false,
threads: 42,
verbose: 1,
};
let def2 = def;
let def3 = def2.clone();
assert_eq!(def2, def3);
}
#[test]
pub fn test_display() {
let def = SolverResult::default();
assert_ne!(def.to_string(), "");
assert_eq!(def.to_string(), "[\"Act1\", \"Act2\"]");
def.pretty_print();
}
#[test]
pub fn test_debug() {
let def = SolverResult::default();
assert_eq!(format!("{:?}", def),"SolverResult { steps: 0, quality: 0, progression: 0, durability: 0, cp: 0, total_cp: 0, total_progression: 0, total_quality: 0, total_durability: 0, actions: [\"Act1\", \"Act2\"], step1_solutions: 0, step2_solutions: 0, found_100_percent: false }");
}
#[test]
pub fn test_arguments() {
// Create false argument parameter
let a = Args {
character_name: "Bob GZ".to_string(),
depth: 77,
desperate: false,
file_name: "test.toml".to_string(),
long: false,
recipe_name: "Belladone".to_string(),
threads: 11,
verbose: 1,
};
let a2 = a.clone();
println!("{:?}",a2);
// Test Custom recipe
let a3 = Args::parse_from(["ultraman","-r", "recipe","-c","dan","-f","bigfile.toml","-d","45","-t","4","-D","-l","-vvv"]);
let _ = Args::parse_from(["-V"]);
let _ = Args::parse_from(["-H"]);
assert_eq!(a3.recipe_name,"recipe");
assert_eq!(a3.character_name,"dan");
assert_eq!(a3.file_name,"bigfile.toml");
assert_eq!(a3.verbose,3);
assert_eq!(a3.depth,45);
assert_eq!(a3.threads,4);
assert_eq!(a3.desperate,true);
assert_eq!(a3.long,true);
// Test default parameters
let a4 = Args::parse_from(["bobGZ"]);
assert_eq!(a4.recipe_name,"default_recipe");
assert_eq!(a4.character_name,"default_character");
assert_eq!(a4.file_name,"craft.toml");
assert_eq!(a4.verbose,0);
assert_eq!(a4.depth,8);
assert_eq!(a4.threads,4);
assert_eq!(a4.desperate,false);
assert_eq!(a4.long,false);
}
#[test]
pub fn test_parameters() {}
}

0
src/tests/lib.rs Normal file
View File

1
tests/io.rs Normal file
View File

@ -0,0 +1 @@

1
tests/lib.rs Normal file
View File

@ -0,0 +1 @@